@wix/mcp 1.0.93 → 1.0.95

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 (84) hide show
  1. package/README.md +2 -2
  2. package/build/bin-standalone.js +1200 -455
  3. package/build/cjs/index.cjs +3237 -1264
  4. package/build/cjs/toolkit.cjs +2177 -469
  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 +19 -10
  9. package/build/dts/api-call/site-files.d.ts +42 -0
  10. package/build/dts/api-call/site-files.js +290 -0
  11. package/build/dts/api-call/upload-headless-website-files.d.ts +118 -0
  12. package/build/dts/api-call/upload-headless-website-files.js +624 -0
  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 +4 -5
  17. package/build/dts/code-mode/attachments.js +1 -1
  18. package/build/dts/code-mode/index.d.ts +6 -1
  19. package/build/dts/code-mode/index.js +47 -13
  20. package/build/dts/code-mode/truncate-response.js +5 -1
  21. package/build/dts/config/default-config.d.ts +35 -9
  22. package/build/dts/config/default-config.js +348 -207
  23. package/build/dts/config/file-params.d.ts +22 -0
  24. package/build/dts/config/file-params.js +24 -0
  25. package/build/dts/config/param-descriptions.d.ts +14 -2
  26. package/build/dts/config/param-descriptions.js +34 -15
  27. package/build/dts/constants.d.ts +1 -0
  28. package/build/dts/constants.js +1 -0
  29. package/build/dts/docs/docs.d.ts +16 -3
  30. package/build/dts/docs/docs.js +211 -39
  31. package/build/dts/docs/fetch-article.d.ts +21 -0
  32. package/build/dts/docs/fetch-article.js +70 -5
  33. package/build/dts/docs/get-to-know.d.ts +7 -2
  34. package/build/dts/docs/get-to-know.js +37 -15
  35. package/build/dts/docs/mintlify-docs.d.ts +121 -0
  36. package/build/dts/docs/mintlify-docs.js +391 -0
  37. package/build/dts/docs/semanticSearch.d.ts +2 -1
  38. package/build/dts/docs/semanticSearch.js +14 -7
  39. package/build/dts/docs/start-deploy-website.d.ts +7 -6
  40. package/build/dts/docs/start-deploy-website.js +13 -8
  41. package/build/dts/docs/start-headless-build.d.ts +17 -0
  42. package/build/dts/docs/start-headless-build.js +60 -0
  43. package/build/dts/graphql/index.js +3 -1
  44. package/build/dts/import-claude-design-tool/index.js +2 -2
  45. package/build/dts/index.d.ts +3 -2
  46. package/build/dts/index.js +3 -2
  47. package/build/dts/infra/redact-personal-data.d.ts +4 -0
  48. package/build/dts/infra/redact-personal-data.js +79 -0
  49. package/build/dts/site-widget-tools/constants.d.ts +49 -1
  50. package/build/dts/site-widget-tools/constants.js +64 -7
  51. package/build/dts/site-widget-tools/index.d.ts +1 -0
  52. package/build/dts/site-widget-tools/index.js +1 -0
  53. package/build/dts/site-widget-tools/pick-images-tool/index.d.ts +14 -0
  54. package/build/dts/site-widget-tools/pick-images-tool/index.js +138 -0
  55. package/build/dts/site-widget-tools/search-site-templates-tool/index.js +33 -9
  56. package/build/dts/site-widget-tools/site-builder-tool/index.js +22 -2
  57. package/build/dts/site-widget-tools/site-creation-tool/index.d.ts +7 -1
  58. package/build/dts/site-widget-tools/site-creation-tool/index.js +22 -51
  59. package/build/dts/site-widget-tools/suggested-domain-tool/index.js +6 -3
  60. package/build/dts/support/index.d.ts +4 -0
  61. package/build/dts/support/index.js +13 -7
  62. package/build/dts/toolkit-entry.d.cts +19 -12
  63. package/build/dts/toolkit-entry.d.ts +19 -12
  64. package/build/dts/toolkit.d.ts +2 -2
  65. package/build/dts/toolkit.js +23 -7
  66. package/build/dts/wix-mcp-server.d.ts +11 -0
  67. package/build/dts/wix-mcp-server.js +28 -6
  68. package/build/dts/wixel/constants.d.ts +8 -1
  69. package/build/dts/wixel/constants.js +8 -1
  70. package/build/dts/wixel/index.d.ts +1 -1
  71. package/build/dts/wixel/index.js +2 -2
  72. package/build/dts/wixel/wixel-a2a-client.d.ts +83 -0
  73. package/build/dts/wixel/wixel-a2a-client.js +166 -0
  74. package/build/dts/wixel/wixel-bi.d.ts +2 -1
  75. package/build/dts/wixel/wixel-bi.js +2 -1
  76. package/build/dts/wixel/{external-agent-api.d.ts → wixel-session-entries.d.ts} +11 -33
  77. package/build/dts/wixel/{external-agent-api.js → wixel-session-entries.js} +33 -54
  78. package/build/dts/wixel/wixel-session-tools.d.ts +21 -26
  79. package/build/dts/wixel/wixel-session-tools.js +494 -599
  80. package/build/esm/index.js +3335 -1376
  81. package/build/esm/toolkit.js +2273 -565
  82. package/package.json +4 -4
  83. package/build/dts/docs/create-site-guide.d.ts +0 -3
  84. package/build/dts/docs/create-site-guide.js +0 -109
@@ -16257,6 +16257,8 @@ var runSemanticSearch = async (toolName, toolParams, maxResults = 20, rerank = f
16257
16257
  kbNames.push("VELO_DOCS_KB_ID", "VELO_METHODS_KB_ID");
16258
16258
  } else if (toolName === "CLI") {
16259
16259
  kbNames.push("CLI_KB_ID");
16260
+ } else if (toolName === "HELP_CENTER") {
16261
+ kbNames.push("HELP_CENTER_KB_ID");
16260
16262
  }
16261
16263
  logger.log(
16262
16264
  `[SemanticSearch] Tool: ${toolName}, KBs: [${kbNames.join(", ")}], Query: "${toolParams.searchTerm}"`
@@ -16289,9 +16291,9 @@ var runSemanticSearch = async (toolName, toolParams, maxResults = 20, rerank = f
16289
16291
  );
16290
16292
  return data?.results;
16291
16293
  };
16292
- var runPlatformizedSemanticSearch = async (toolName, searchTerm, maxResults = 20, linesInEachResult, extraDocumentTypes) => {
16294
+ var runPlatformizedSemanticSearch = async (toolName, searchTerm, maxResults = 20, linesInEachResult, extraDocumentTypes, documentTypesOverride) => {
16293
16295
  const startTime = Date.now();
16294
- const documentTypes = extraDocumentTypes?.length ? [toolName, ...extraDocumentTypes] : void 0;
16296
+ const documentTypes = documentTypesOverride?.length ? documentTypesOverride : extraDocumentTypes?.length ? [toolName, ...extraDocumentTypes] : void 0;
16295
16297
  logger.log(
16296
16298
  `[SemanticSearch/v2] Tool: ${documentTypes ? documentTypes.join("+") : toolName}, Query: "${searchTerm}"`
16297
16299
  );
@@ -16335,15 +16337,17 @@ var runSemanticSearchAndFormat = async ({
16335
16337
  rerank,
16336
16338
  linesInEachResult,
16337
16339
  usePlatformizedSearch = true,
16338
- extraDocumentTypes
16340
+ extraDocumentTypes,
16341
+ documentTypes
16339
16342
  }) => {
16340
- if (usePlatformizedSearch) {
16343
+ if (usePlatformizedSearch || documentTypes?.length) {
16341
16344
  return runPlatformizedSemanticSearch(
16342
16345
  toolName,
16343
16346
  toolParams.searchTerm,
16344
16347
  maxResults,
16345
16348
  linesInEachResult,
16346
- extraDocumentTypes
16349
+ extraDocumentTypes,
16350
+ documentTypes
16347
16351
  );
16348
16352
  } else {
16349
16353
  const results = await runSemanticSearch(
@@ -17263,6 +17267,7 @@ var import_http_client = __toESM(require_index_node(), 1);
17263
17267
  // src/constants.ts
17264
17268
  var RAW_DOCS_API_URL = "https://dev.wix.com/rawdocs/api";
17265
17269
  var GET_ARTICLE_CONTENT_URL = `${RAW_DOCS_API_URL}/get-article-content`;
17270
+ var GET_SOURCE_CONTENT_URL = `${RAW_DOCS_API_URL}/get-source-content`;
17266
17271
  var PORTAL_INDEX_URL = `${RAW_DOCS_API_URL}/portal-index`;
17267
17272
  var DOCS_API_BASE_URL = "https://dev.wix.com/docs/api/v1";
17268
17273
  var GET_SKILLS_BY_PORTAL_URL = `${DOCS_API_BASE_URL}/docs-web-app/menu-node/get-skills-by-portal`;
@@ -17280,10 +17285,16 @@ async function fetchArticle(articleUrl) {
17280
17285
  }
17281
17286
  var DOCS_URL_PREFIX = "https://dev.wix.com/docs/";
17282
17287
  var SKILLS_REGISTRY_URL = new RegExp(
17283
- "^https://(?:dev\\.wix\\.com(?:/docs)?|www\\.wix\\.com(?:/velo/reference)?)/skills(?:[/.?#]|$)"
17288
+ "^https://(?:dev\\.wix\\.com(?:/docs)?|www\\.wix\\.com(?:/velo/reference)?)/skills(?:[/.?#]|$)|^https://www\\.wix\\.com/headless/"
17284
17289
  );
17285
17290
  function isSkillsRegistryUrl(url) {
17286
- return SKILLS_REGISTRY_URL.test(url.trim());
17291
+ return SKILLS_REGISTRY_URL.test(normalizeSkillsUrl(url));
17292
+ }
17293
+ var GITHUB_SKILLS_URL = /^https:\/\/(?:www\.)?github\.com\/wix\/skills\/(?:blob|raw|tree)\/[^/]+\/skills\/([^#?]+)/;
17294
+ function normalizeSkillsUrl(url) {
17295
+ const apex = url.trim().replace(/^https:\/\/wix\.com\//, "https://www.wix.com/");
17296
+ const gh = apex.match(GITHUB_SKILLS_URL);
17297
+ return gh ? `https://www.wix.com/skills/${gh[1]}` : apex;
17287
17298
  }
17288
17299
  async function fetchSkillsRegistryPage(httpClient, url) {
17289
17300
  let data;
@@ -17381,6 +17392,40 @@ async function fetchArticleContentFromDigor(httpClient, articleUrl, mode, stripH
17381
17392
  }
17382
17393
  return articleContent;
17383
17394
  }
17395
+ function parseSourceContentUrl(url) {
17396
+ let parsed;
17397
+ try {
17398
+ parsed = new URL(url);
17399
+ } catch {
17400
+ return void 0;
17401
+ }
17402
+ if (`${parsed.origin}${parsed.pathname}` !== GET_SOURCE_CONTENT_URL) {
17403
+ return void 0;
17404
+ }
17405
+ const repo = parsed.searchParams.get("repo");
17406
+ const path = parsed.searchParams.get("path");
17407
+ const commitHash = parsed.searchParams.get("commitHash");
17408
+ if (!repo || !path) return void 0;
17409
+ return commitHash ? { repo, path, commitHash } : { repo, path };
17410
+ }
17411
+ async function fetchSourceContent(httpClient, repo, path, commitHash) {
17412
+ const url = new URL(GET_SOURCE_CONTENT_URL);
17413
+ url.searchParams.set("repo", repo);
17414
+ url.searchParams.set("path", path);
17415
+ if (commitHash) url.searchParams.set("commitHash", commitHash);
17416
+ let data;
17417
+ try {
17418
+ ({ data } = await httpClient.get(url.toString()));
17419
+ } catch (error) {
17420
+ const { message, status } = getHttpErrorDetails(error);
17421
+ const statusSuffix = status ? ` (status ${status})` : "";
17422
+ throw new Error(`${message}${statusSuffix}`);
17423
+ }
17424
+ if (!data?.content) {
17425
+ throw new Error("Source content is empty");
17426
+ }
17427
+ return data.content;
17428
+ }
17384
17429
  async function fetchArticleContent(httpClient, articleUrl, mode, stripHeader = false, skillsPortalUrl, repo, commitHash, fetchMcpWhiteList) {
17385
17430
  const effectiveUrl = applyPortalUrlOverride(articleUrl, skillsPortalUrl);
17386
17431
  const isOverridden = effectiveUrl !== articleUrl;
@@ -17394,7 +17439,10 @@ async function fetchArticleContent(httpClient, articleUrl, mode, stripHeader = f
17394
17439
  `[fetch] Override failed for ${effectiveUrl}, falling back to ${articleUrl}:`,
17395
17440
  error instanceof Error ? error.message : error
17396
17441
  );
17397
- content = isSkillsRegistryUrl(articleUrl) ? await fetchSkillsRegistryPage(httpClient, articleUrl) : await fetchArticleContentFromDigor(
17442
+ content = isSkillsRegistryUrl(articleUrl) ? await fetchSkillsRegistryPage(
17443
+ httpClient,
17444
+ normalizeSkillsUrl(articleUrl)
17445
+ ) : await fetchArticleContentFromDigor(
17398
17446
  httpClient,
17399
17447
  articleUrl,
17400
17448
  mode,
@@ -17402,7 +17450,10 @@ async function fetchArticleContent(httpClient, articleUrl, mode, stripHeader = f
17402
17450
  );
17403
17451
  }
17404
17452
  } else if (isSkillsRegistryUrl(articleUrl)) {
17405
- content = await fetchSkillsRegistryPage(httpClient, articleUrl);
17453
+ content = await fetchSkillsRegistryPage(
17454
+ httpClient,
17455
+ normalizeSkillsUrl(articleUrl)
17456
+ );
17406
17457
  } else if (mode === "raw") {
17407
17458
  let parsedUrl;
17408
17459
  try {
@@ -17689,56 +17740,96 @@ function rethrowIfUnauthorized(error) {
17689
17740
  var ARRAY_QUERY_PARAMS_RULE = "Repeat array query params once per value: `?fieldsets=URL&fieldsets=RICH_CONTENT`. Do NOT comma-join values (`fieldsets=URL,RICH_CONTENT`), do NOT leave a trailing comma, and do NOT use a value the method schema does not list, even if a sibling method accepts it (draft posts have no `SEO` fieldset).";
17690
17741
  var WQL_FILTER_RULE = "Query and search filters are written in WQL: each field takes a single operator, so combine conditions with the logical operators \u2014 `$and` and `$or` take an array of expressions, `$not` takes one, and they can nest.";
17691
17742
 
17743
+ // src/config/file-params.ts
17744
+ var FILE_PARAM_CLIENTS = "OpenAI clients (ChatGPT, Codex)";
17745
+ function fileParamNote(otherwise) {
17746
+ return `${FILE_PARAM_CLIENTS} only: pass each file as you have it (attached in the chat or created in your sandbox, by its file id or path) and the client swaps it for { download_url, file_id, file_name?, mime_type? } before the call reaches Wix. No other client does this swap, so elsewhere a path or file:// URL here fails at once; leave this out and ${otherwise}.`;
17747
+ }
17748
+
17749
+ // src/site-widget-tools/constants.ts
17750
+ var WIX_BUSINESS_FEATURES = "a store, bookings or appointments, rentals, events and tickets, a restaurant menu with online orders or reservations, a blog, a portfolio, pricing plans and memberships, donations, Wix Forms, members and login, a CMS, payments";
17751
+ var SITE_CREATION_DEFAULT_ACTIONS = "add products, set up bookings, and adjust your content";
17752
+ var SITE_CREATION_CUSTOM_ACTIONS_GUIDANCE = `2\u20133 specific, high-value setup actions for the site's industry, written as a comma-separated phrase (it slots into "\u2026ask me to ___ right here in the chat"). Use the following domain patterns as guidance:
17753
+ * E-commerce / Retail: "add products, set up payment methods, and organize collections"
17754
+ * Restaurants / Food / Bakeries: "add menu items, set up online ordering, and collect table reservations"
17755
+ * Services / Fitness / Salons / Consultants: "set up booking slots, add service pricing, and manage appointments"
17756
+ * Creative / Portfolios / Photographers: "upload project galleries, feature client reviews, and customize contact forms"
17757
+ * Events / Weddings / Real Estate: "add event schedules, display listings, and manage RSVP forms"
17758
+ * General / Unspecified: "${SITE_CREATION_DEFAULT_ACTIONS}"
17759
+ If none of these patterns fit the site, infer 2\u20133 actions that suit what that kind of business would manage on its site.`;
17760
+ var SITE_BUILDER_CHOICE = {
17761
+ here: {
17762
+ label: "Build it here with me",
17763
+ pitch: "I build it in code right here, and you change anything by asking me"
17764
+ },
17765
+ editor: {
17766
+ label: "Design it in Wix's editor",
17767
+ pitch: "Wix designs a first version or you start from a template, then you edit it in Wix"
17768
+ },
17769
+ /** The editor's second step, in the widget and its reply. */
17770
+ editorStart: {
17771
+ wix: {
17772
+ label: "Let Wix design it",
17773
+ pitch: "Wix designs a first version from your description for you to edit"
17774
+ },
17775
+ template: {
17776
+ label: "Browse templates",
17777
+ pitch: "start from a ready-made design and edit it in Wix"
17778
+ }
17779
+ },
17780
+ /** Asked in chat when no widget is shown: who builds it. */
17781
+ whoQuestion: "Do you want me to build it here, so you can change anything just by asking me, or do you want to design it yourself in Wix's editor?",
17782
+ /** Asked next, only when the user chose Wix's editor. */
17783
+ editorQuestion: "Should Wix design a first version for you to edit, or do you want to start from a template?",
17784
+ /** What the widget sends as the user's message when they pick "Build it here with me". */
17785
+ hereFollowUp: "Build it here with me, in code, so I can keep changing it by asking you."
17786
+ };
17787
+
17692
17788
  // src/config/default-config.ts
17693
17789
  var AGENT_GOAL = dedent_default`
17694
- You are an agent that helps the user manage their Wix site.
17695
- Your goal is to get the user's prompt/task and execute it by using the appropriate tools eventually calling the correct Wix APIs with the correct parameters until the task is completed.
17790
+ You help the user with their Wix sites and account.
17791
+ Work out what the task needs and do it: read the Wix skills, docs and API schemas that cover it, and write and run the code that calls Wix APIs, until the task is done.
17696
17792
  `;
17793
+ var CALL_WIX_SITE_API_RECONNECT_LINE = "If the Wix MCP offers no ExecuteWixAPI at all, your Wix connection is likely an old or cached version: tell the user once to reconnect the Wix connector or restart the client, and use this tool until then.";
17794
+ var CALL_WIX_SITE_API_NO_EXECUTE_LINE = "If ExecuteWixAPI isn't in your tool list, use this tool.";
17697
17795
  var DISCOVERY_FLOWS = [
17698
- "- CONVERSATION CONTEXT BASED: find relevant docs article or API example for the user's prompt/task in the conversation context -> call API using CallWixSiteAPI() based on the docs article or API example",
17699
- "- METHOD CODE EXAMPLE BASED: BrowseWixRESTDocsMenu() or SearchWixRESTDocumentation() -> find relevant method -> read method article using ReadFullDocsArticle() to get method code examples -> call API using CallWixSiteAPI() based on the method code examples",
17700
- "- FULL SCHEMA BASED: BrowseWixRESTDocsMenu() or SearchWixRESTDocumentation() -> find relevant method -> read method article using ReadFullDocsArticle() -> no method code examples found -> inspect the method schema using SearchWixAPISpec or ReadFullDocsMethodSchema -> call API using CallWixSiteAPI() based on the schema"
17796
+ "- CONVERSATION CONTEXT BASED: find relevant docs article or API example for the user's prompt/task in the conversation context -> call the API with ExecuteWixAPI based on the docs article or API example",
17797
+ "- METHOD CODE EXAMPLE BASED: BrowseWixRESTDocsMenu() or SearchWixRESTDocumentation() -> find relevant method -> read method article using ReadFullDocsArticle() to get method code examples -> call the API with ExecuteWixAPI based on the method code examples",
17798
+ "- FULL SCHEMA BASED: BrowseWixRESTDocsMenu() or SearchWixRESTDocumentation() -> find relevant method -> read method article using ReadFullDocsArticle() -> no method code examples found -> inspect the method schema using SearchWixAPISpec or ReadFullDocsMethodSchema -> call the API with ExecuteWixAPI based on the schema"
17701
17799
  ];
17800
+ function directRouteLines(includeReadme, includeImageUploadGuidance) {
17801
+ return [
17802
+ ...includeReadme ? [
17803
+ `- **Creating a new site.** Skip the docs too. A site is written in code and uploaded: StartDeployWebsite returns the upload guide; StartHeadlessBuild returns the headless guide, for a site that needs Wix business features (${WIX_BUSINESS_FEATURES}). Call one right away, without asking the user anything first: StartHeadlessBuild when the site needs Wix business features, otherwise StartDeployWebsite. WixSiteBuilder or SearchSiteTemplates only when the user asked for Wix's editor, the Wix Harmony Editor, a template, Wix Studio or the Classic Editor. Never create a site through ManageWixSite, CallWixSiteAPI or ExecuteWixAPI.`
17804
+ ] : [],
17805
+ "- **Listing, showing or finding their Wix sites**: call ListWixSites directly.",
17806
+ ...includeImageUploadGuidance ? [
17807
+ "- **Uploading local or attached image files to a Wix site**: call UploadImageToWixSite directly, with no docs, schema or API calls. Do NOT use ExecuteWixAPI, SearchWixAPISpec, or any Media Manager REST API for image uploads."
17808
+ ] : []
17809
+ ];
17810
+ }
17702
17811
  function buildSystemReminderGuidelines(includeReadme, includeImageUploadGuidance) {
17703
- const exception = includeReadme ? "**Exception:** " : "";
17704
17812
  const lines = [];
17705
- if (includeReadme) {
17706
- lines.push(
17707
- "if the WixREADME tool is available to you, YOU MUST USE IT AT THE BEGINNING OF ANY CONVERSATION and then continue with calling the other tools and calling the Wix APIs until the task is completed.",
17708
- "**Exception \u2014 creating a new Wix site/website:** For a normal creation request \u2014 and only then \u2014 skip WixREADME and the docs search, and route straight to the Wix site-creation tools available to you; their descriptions carry the routing rules. Everything else starts with WixREADME as usual.",
17709
- "If the user explicitly asks for a headless site, Wix Classic Editor site, or manual account/API-based site creation, call CreateWixBusinessGuide right away \u2014 these don't need the site's purpose first.",
17710
- "If the user \u2014 or you, earlier in this conversation \u2014 already have a finished page or site in any form (HTML/CSS/JS files, a static build, a zip, another builder's export, a design you can export to HTML) and want it live on Wix, call StartDeployWebsite right away \u2014 not a site-creation tool, not the docs.",
17711
- "Never default to AI or search templates unless the user explicitly requests it. When the user named no creation method - let the user make that choice as the site-creation tools' descriptions direct. Never route normal site creation through ManageWixSite, CallWixSiteAPI, or ExecuteWixAPI."
17712
- );
17713
- }
17714
17813
  lines.push(
17715
- `${exception}If the user asks to list, show, or find their Wix sites, ${includeReadme ? "skip WixREADME and " : ""}call ListWixSites directly.`
17814
+ includeReadme ? "Start every Wix task with WixREADME, questions included, then use the other tools and the Wix APIs until the task is done. If WixREADME is not available, follow the flows without it. These requests skip it and go straight to their own tool:" : "These requests go straight to their own tool, with no docs or API calls first:"
17716
17815
  );
17717
- if (includeImageUploadGuidance) {
17718
- lines.push(
17719
- `${exception}If the user wants to upload local or attached image files to a Wix site, skip ${includeReadme ? "WixREADME and " : ""}all docs/schema/API flows \u2014 call UploadImageToWixSite directly. Do NOT use ExecuteWixAPI, SearchWixAPISpec, or any Media Manager REST API for image uploads.`
17720
- );
17721
- }
17722
- if (includeReadme) {
17723
- lines.push(
17724
- "If the WixREADME tool is not available to you, you should use the other flows as described without using the WixREADME tool until the task is completed."
17725
- );
17726
- }
17816
+ lines.push(...directRouteLines(includeReadme, includeImageUploadGuidance));
17727
17817
  lines.push(
17728
- `This applies to QUESTIONS too, not only action tasks (the ${includeReadme ? "exceptions" : "direct-tool routes"} above still apply \u2014 question-shaped variants of those intents, e.g. "can you show my sites?", follow their ${includeReadme ? "exception's " : ""}direct tool): never answer a Wix-specific question from memory, and never reply that you lack the tools or APIs to answer, without first ${includeReadme ? "calling the WixREADME tool (if available) and checking its recipes index, searching the docs," : "searching the docs"} and reading the matching docs articles \u2014 many questions (including ones that need no API call) are answered by a ${includeReadme ? "recipe or docs article" : "docs article"}.`,
17729
- "If the user prompt / task is an instruction to do something in Wix, You should not tell the user what Docs to read or what API to call, your task is to do the work and complete the task in minimal steps and time with minimal back and forth with the user, unless absolutely necessary."
17818
+ `A question follows the same routes: one about those requests goes to its tool ("can you show my sites?" is ListWixSites). Any other Wix question is answered from ${includeReadme ? "WixREADME, the Wix skills, " : ""}the docs search and the matching docs articles, never from memory, and never with a reply that you lack the tools or APIs to answer. Many questions, including ones that need no API call, are answered by a ${includeReadme ? "Wix skill or docs article" : "docs article"}.`,
17819
+ "When the user asks you to do something in Wix, do it, in as few steps and questions as you can; don't tell them which docs to read or which API to call."
17730
17820
  );
17731
17821
  return lines.join("\n");
17732
17822
  }
17733
17823
  function buildSystemReminderFlows(includeReadme) {
17734
17824
  const lines = ["Wix MCP Site Management Flows"];
17825
+ const noSkill = "no Wix skill covers the user's prompt/task -> ";
17735
17826
  if (includeReadme) {
17736
17827
  lines.push(
17737
17828
  "With WixREADME tool:",
17738
- "- RECIPE BASED (PREFERRED!): WixREADME() -> find relevant recipe for the user's prompt/task -> read recipe using ReadFullDocsArticle() -> call Wix API using CallWixSiteAPI() based on the recipe",
17829
+ "- SKILL BASED (PREFERRED!): WixREADME() -> find the Wix skill for the user's prompt/task (WixREADME says how to read one) -> follow it -> call the API with ExecuteWixAPI based on it",
17739
17830
  DISCOVERY_FLOWS[0],
17740
- "- EXAMPLE BASED: WixREADME() -> no relevant recipe found for user's prompt/task -> BrowseWixRESTDocsMenu() or SearchWixRESTDocumentation() -> find relevant method -> read method article using ReadFullDocsArticle() to get method code examples -> call API using CallWixSiteAPI() based on the method code examples",
17741
- "- SCHEMA BASED, FALLBACK: WixREADME() -> no relevant recipe found for user's prompt/task -> BrowseWixRESTDocsMenu() or SearchWixRESTDocumentation() -> find relevant method -> read method article using ReadFullDocsArticle() -> no method code examples found -> inspect the method schema using SearchWixAPISpec or ReadFullDocsMethodSchema -> call API using CallWixSiteAPI() based on the schema",
17831
+ `- EXAMPLE BASED: WixREADME() -> ${noSkill}BrowseWixRESTDocsMenu() or SearchWixRESTDocumentation() -> find relevant method -> read method article using ReadFullDocsArticle() to get method code examples -> call the API with ExecuteWixAPI based on the method code examples`,
17832
+ `- SCHEMA BASED, FALLBACK: WixREADME() -> ${noSkill}BrowseWixRESTDocsMenu() or SearchWixRESTDocumentation() -> find relevant method -> read method article using ReadFullDocsArticle() -> no method code examples found -> inspect the method schema using SearchWixAPISpec or ReadFullDocsMethodSchema -> call the API with ExecuteWixAPI based on the schema`,
17742
17833
  "Without WixREADME tool:"
17743
17834
  );
17744
17835
  }
@@ -17756,9 +17847,8 @@ function buildSystemReminder(includeReadme, includeImageUploadGuidance = true) {
17756
17847
  );
17757
17848
  const flows = buildSystemReminderFlows(includeReadme);
17758
17849
  return dedent_default`
17759
- <agent-mandatory-instructions>
17760
- YOU MUST READ AND FOLLOW THE AGENT-MANDATORY-INSTRUCTIONS BELOW
17761
- A FAILURE TO DO SO WILL RESULT IN ERRORS AND CRITICAL ISSUES.
17850
+ <wix-usage-guide>
17851
+ How to work with Wix through these tools. Following these steps avoids failed or incorrect API calls.
17762
17852
  <goal>
17763
17853
  ${AGENT_GOAL}
17764
17854
  </goal>
@@ -17768,49 +17858,27 @@ function buildSystemReminder(includeReadme, includeImageUploadGuidance = true) {
17768
17858
  <flow-description>
17769
17859
  ${flows}
17770
17860
  </flow-description>
17771
- </agent-mandatory-instructions>
17861
+ </wix-usage-guide>
17772
17862
  `;
17773
17863
  }
17774
17864
  var SYSTEM_REMINDER = buildSystemReminder(true);
17865
+ var HELP_CENTER_IS_FOR_PEOPLE = "The Help Center is written for people doing things by hand in Wix's dashboard and editors. To act on a site yourself, the Wix developer docs come first: find the method with SearchWixRESTDocumentation or BrowseWixRESTDocsMenu.";
17775
17866
  var SITE_CREATION_COPY = {
17776
17867
  templatePick: {
17777
17868
  nonWidget: "After the user selects a template, call `CreateSiteFromTemplate`.",
17778
17869
  widget: "The gallery creates the site when the user picks one."
17779
- },
17780
- unstatedMethod: {
17781
- nonWidget: "you MUST ask whether they want to build with AI or start from a template, and create nothing and show nothing until they answer",
17782
- widget: "you MUST call `WixSiteCreation` and let them choose"
17783
- },
17784
- normalCreationRoute: {
17785
- nonWidget: "route those through `WixSiteBuilder` or `SearchSiteTemplates`",
17786
- widget: "route those through `WixSiteCreation`"
17787
17870
  }
17788
17871
  };
17789
- var SITE_GUIDANCE = dedent_default`
17790
- First decide which of two different things is being asked for:
17791
- - The site is code the user or you control — hand-written HTML/CSS/JS, a static build, a zip, another AI builder's export, or a page or design you made earlier in this conversation — and it should go live on Wix. This is also the route whenever the user wants to keep working on the site here, with you: a Wix Headless site is a regular coded site, so you keep full control of the design and can change and redeploy it from this conversation at any time, and Wix business capabilities can be added to it as a backend when they are needed. Call StartDeployWebsite: it returns the recipe to host those exact files as a Wix Headless site (updates reuse the same site and URL; the drop page is only its fallback). Do not offer AI or templates for this and do not call any site-creation tool.
17792
- - Wix should create the site — generated with AI from a description, or started from a template — and the user will design and edit it in Wix rather than through you. That is what the site-creation tools do; they never take files you already have.
17793
-
17794
- For a new site there are two things to settle: what the site is for, and how to build it. The how is AI generation vs. starting from a template, so naming templates, a template id or Wix Studio (Wix Studio is also the template side) already settles it.
17795
-
17796
- Settle what the site is for first: its purpose, topic, business type, audience, or main visitor action. Naming a method is not a description of the site, and neither is the business or industry on its own.
17797
- If you can't tell yet, ask the preferred question below and nothing else — one question, no creation-method question in the same reply, and no internal tool names.
17798
- Once the purpose is clear, unless the user already named a method, ${SITE_CREATION_COPY.unstatedMethod.nonWidget}. A method they named is settled — never re-open it. Never default to AI or to templates, and never ask the user to choose between Harmony and Wix Studio; infer that from their words.
17799
- With the purpose and the method known, that's enough to begin — route and refine the specifics with the user afterward.
17800
-
17801
- Preferred question when the user has given no site context at all:
17802
- Happy to help. To give you the right starting point, tell me a bit more about what you have in mind:
17803
- - What's the site for? (e.g. an online clothing store, a yoga studio that takes bookings, a restaurant)
17804
- - What's the vibe? (e.g. sleek and modern, cozy and rustic, bold and energetic)
17805
- Give me a quick summary and I'll take it from there
17806
-
17807
- Tone: helpful, practical, short. Speak about the user's site — what you're making and what comes next — not the tools, payloads, or routing behind it.`;
17872
+ var EDITOR_TAIL = `When the user wants Wix's editor, or to design the site themselves, without saying how to start, ask them first: "${SITE_BUILDER_CHOICE.editorQuestion}" A new site is otherwise written in code and uploaded: call StartDeployWebsite, or StartHeadlessBuild when it needs Wix business features, right away and without asking the user anything first.`;
17808
17873
  var toWidget = (text) => Object.values(SITE_CREATION_COPY).reduce(
17809
17874
  (acc, { nonWidget, widget }) => acc.replaceAll(nonWidget, widget),
17810
17875
  text
17811
17876
  );
17877
+ var WIX_API_DATA = "products, inventory, carts, checkouts, orders, bookings, services, staff, time slots, rentals, restaurant menus, online orders, reservations, events, tickets, RSVPs, blog posts, CMS collections and items, pricing plans, subscriptions, portfolios, gift cards, coupons, donations, forms, form submissions, contacts, members, loyalty points, groups, reviews, inbox messages, CRM tasks, automations, email campaigns, payments, invoices, SEO, redirects, translations, locations, analytics, media files, site properties, installed apps, and the account's sites and domains";
17812
17878
  var EXECUTE_WIX_API_INTRO = dedent_default`
17813
- Execute JavaScript code against the Wix REST API when code is useful for chaining related calls, pagination, loops, branching, or in-memory transformation.
17879
+ Reads and changes the data of a Wix site or account: query, list, count, create, update and delete it with one JavaScript function over the Wix REST API.
17880
+ One function holds the whole task: chained calls, pagination, loops, branching, and the reads that feed its writes.
17881
+ Putting a site live or changing a headless site's files starts with StartDeployWebsite; building a new site in code with StartHeadlessBuild.
17814
17882
 
17815
17883
  CODE CONTRACT:
17816
17884
  - Pass an async function expression: \`async function() { ... }\` or \`async () => { ... }\`. Put every declaration, \`await\`, and \`return\` inside it, and do not invoke it yourself.
@@ -17895,7 +17963,7 @@ var ACCOUNT_SITE_EXECUTE_SCOPE = dedent_default`
17895
17963
  declare const files: Array<{ path: string; content: string; encoding?: "base64" }>;
17896
17964
  \`\`\`
17897
17965
 
17898
- FILE UPLOADS: files never go inline in \`code\`; two params feed the \`files\` global. \`attachments\` takes files attached in the chat or created in your file sandbox, of any type and size up to 10 MB per call (a zip of a whole site, HTML, images, PDFs): pass the files themselves, all in one call, and the platform resolves each into \`{ download_url, file_id, file_name?, mime_type? }\` — the bytes are fetched for you and arrive as base64 entries named by file name. The \`files\` param takes content you have as text here: text goes raw; a small binary (icon, logo, font) rides as a \`base64\`-tagged entry — large images/video are referenced by URL (\`<img src="https://...">\`), not bundled. \`wix.multipart()\` turns the whole set into one upload body (bytes, so binary is safe):
17966
+ FILE UPLOADS: files never go inline in \`code\`; two params feed the \`files\` global. \`attachments\`: ${fileParamNote("upload from your shell if it reaches the internet")} Any type, up to 10 MB per call, all in one call: a zip of a whole site, HTML, images, PDFs; the bytes arrive as base64 entries named by file name. The \`files\` param takes content you have as text here: text goes raw; a small binary (icon, logo, font) rides as a \`base64\`-tagged entry — large images/video are referenced by URL (\`<img src="https://...">\`), not bundled. \`wix.multipart()\` turns the whole set into one upload body (bytes, so binary is safe):
17899
17967
  \`\`\`javascript
17900
17968
  // files param:
17901
17969
  // === FILE: index.html ===
@@ -17910,6 +17978,7 @@ var ACCOUNT_SITE_EXECUTE_SCOPE = dedent_default`
17910
17978
  return res.data;
17911
17979
  }
17912
17980
  \`\`\`
17981
+ HEADLESS SITE EDITS: \`wix.headless.files.list({siteId, prefix?, offset?, limit?})\` returns file metadata; \`read({siteId, path})\` returns UTF-8 text (up to 256 KB); \`patch({siteId, files?, deletePaths?, agent?})\` applies changed files and explicit deletions while preserving everything else. Patch defaults to the Execute \`files\` global (including resolved attachments and ZIPs). Paths are literal site-relative paths; no wrapping-folder stripping. It returns added/replaced/deleted/unchanged/missingDeletes path lists. List/read reuse one downloaded ZIP snapshot for the current site within an Execute call; switching sites discards the previous snapshot, and a new call downloads afresh. Patch downloads a fresh ZIP, then drops the full merged site and clears the read snapshot. Serialize edits to the same site; there is no atomic concurrency guarantee. For a full replacement, use the existing upload/drop path. See the upload-static-site recipe for examples and older-server fallback.
17913
17982
  A site zip passed through \`attachments\` is one base64 entry; unzip it and upload the entries:
17914
17983
  \`\`\`javascript
17915
17984
  // attachments: [site.zip] → files = [{ path: "site.zip", content: "<base64>", encoding: "base64" }]
@@ -18033,22 +18102,37 @@ var executeWixApiDescription = dedent_default`
18033
18102
 
18034
18103
  ${EXECUTE_WIX_API_MULTI_SITE_EXAMPLE}
18035
18104
  `;
18036
- function buildToolDescriptions(includeReadme, includeImageUploadGuidance = true) {
18037
- const reminder = buildSystemReminder(
18105
+ function buildToolDescriptions(includeReadme, includeImageUploadGuidance = true, { usageGuideOnce = false } = {}) {
18106
+ const usageGuide = buildSystemReminder(
18038
18107
  includeReadme,
18039
18108
  includeImageUploadGuidance
18040
18109
  );
18041
- return {
18110
+ const reminder = includeReadme && usageGuideOnce ? "" : usageGuide;
18111
+ const descriptions = {
18112
+ // Named in SERVER_INSTRUCTIONS: when this tool's name or what it is for changes, update them to match.
18042
18113
  WixREADME: dedent_default`
18043
18114
  # Tool: WixREADME
18044
- **Directive:** \`WixREADME\` is the **MANDATORY FIRST STEP** for all Wix-related tasks. Its output (including relevant linked documents) provides foundational context for all other Wix tools. Adherence to this protocol is **NON-NEGOTIABLE**.
18045
-
18046
- **Mid-conversation site switching:** If the user references a different site by name or ID after WixREADME has already been called, use \`GetSiteContext\` directly — no need to call WixREADME again.
18047
- ${reminder}
18115
+ The context every other Wix tool assumes. Call it first, once per conversation, for any Wix task or question; for another site later in the conversation, call \`GetSiteContext\` instead of calling this again.
18116
+ A Wix task includes reading or changing a site's or account's data: ${WIX_API_DATA}.
18117
+ These requests skip it and go straight to their own tool:
18118
+ ${directRouteLines(includeReadme, includeImageUploadGuidance).join("\n")}
18119
+ A question about one of those goes to the same tool ("can you show my sites?" is ListWixSites). Any other Wix question is answered from a Wix skill or the docs, never from memory, and never with a reply that you lack the tools to answer.
18120
+ It returns, in full:
18121
+ - **Source of truth**: nothing Wix-specific from memory. Every URL, ID, setting location, product fact, request shape and field name comes from the docs tools, a Wix skill, an earlier tool result in the conversation, or the user.
18122
+ - **The site**: the account's sites with their properties and installed apps. The \`siteId\` comes from there (ask when several fit); a business solution's API works only on a site with its app installed, and an app's version changes its endpoints.
18123
+ - **Find the method**: an earlier tool result, else a Wix skill's recipe (wix-manage to manage a site, wix-headless-kit to build a headless one), else the docs: SearchWixRESTDocumentation or BrowseWixRESTDocsMenu, then ReadFullDocsArticle; the SDK, CLI, headless and apps docs for code.
18124
+ - **The exact shape**: model a call only on an example that matches the case; fill the rest with SearchWixAPISpec on the method's docs URL (request and response schemas, \`method.publicUrl\` for REST, \`method.sdk\` for the JavaScript SDK). A query's filter and sort fields and operators are a closed list per method.
18125
+ - **The call, or the code**: ExecuteWixAPI runs one async function holding every step code can resolve, the reads and the writes they feed together, \`hasMutations: true\` when anything writes. Code the user keeps (an app, a headless site, a script over REST or the JavaScript SDK) is written from the same shapes; the headless skills are a shortcut on that path.
18126
+ - **When a call fails**: the error says what was wrong and carries a Wix request id; fix that, never resend unchanged or guess.
18127
+ - **Wix skills**, what each is for and how to read one: from disk when installed (the Wix plugin, or \`npx skills add wix/skills\`, \`--skill <name>\` for one, \`-g\` for the user's home, into \`.agents/skills/<skill>/\` or a similar folder the client reads, such as \`.claude/skills/<skill>/\`), else online with ReadFullDocsArticle at \`https://www.wix.com/skills/<skill>/<path>\`.
18128
+ - **wix-manage**: REST recipes for managing a site's business solutions, one per task; follow the recipe and make its calls with ExecuteWixAPI, its docs URL in \`sourceDocUrls\`. Its list of recipes is \`SKILL.md\` in the installed skill, or online https://dev.wix.com/docs/api-reference/articles/ai-tools/wix-mcp/skills/wix-management-recipes-index.md, and each API area has its own \`<API section>/skills.md\` (for example https://dev.wix.com/docs/api-reference/business-solutions/bookings/skills.md).
18129
+ - **wix-headless-kit**: builds a Wix Headless site on shipped, verified code from wix-headless-templates, a \`@wix/sdk\` React core or the same data layer as plain REST calls: scaffold with the CLI, deploy, seed, design on the shipped hooks, release. https://www.wix.com/skills/headless-kit/SKILL.md
18130
+ - **wix-headless-templates**: the code wix-headless-kit builds from, one folder per Wix Business Solution. https://www.wix.com/skills/headless-templates/
18131
+ When the user asks you to do something in Wix, do it yourself, in as few steps and questions as you can; don't tell them which docs to read or which API to call.
18048
18132
  `,
18049
18133
  SearchWixRESTDocumentation: dedent_default`
18050
18134
  **Searches the official Wix REST API documentation — the starting point for any Wix REST API task.** Unless you already have the exact method \`docsUrl\` in context, begin the task here; this is how you discover the right endpoint. Reach for it before \`SearchWixAPISpec\`, and avoid writing code that scans or filters \`lightIndex\` to find an endpoint (e.g. \`lightIndex.filter(...)\`, \`lightIndex.flatMap(...)\`, or substring-matching on \`docsUrl\`/\`name\`/\`summary\`) — that has no relevance ranking and silently misses composite and method-level operations. This is the ranked semantic-search discovery tool over the Wix REST API docs: describe your intent in natural language and it returns the matching REST endpoints/methods (with their \`docsUrl\`) ranked by relevance. It is the first step whenever you need to do something on a Wix site via HTTP and don't already have the exact \`docsUrl\` in context — for creating, reading, updating, or deleting any kind of Wix entity, across every business domain.
18051
- It covers all Wix REST domains equally — Stores, eCommerce/orders, Bookings, CRM/contacts, Members, CMS/data collections, Events, Blog, Forms, Marketing, Media, site settings, SEO, and the rest. Just describe the resource, action, or goal in plain words (e.g. 'add a catalog item with inventory', 'book a service', 'update a data collection item', 'create a discount', 'list contacts', 'get site details endpoint', 'REST authentication'); the ranking handles matching your wording to the right API regardless of domain.
18135
+ It covers all Wix REST domains equally, every product's data: ${WIX_API_DATA}, and the rest. Just describe the resource, action, or goal in plain words (e.g. 'add a catalog item with inventory', 'book a service', 'update a data collection item', 'create a discount', 'list contacts', 'get site details endpoint', 'REST authentication'); the ranking handles matching your wording to the right API regardless of domain.
18052
18136
  **Next step after this tool:** take the \`docsUrl\` it returns and inspect that method's exact request/response schema with \`SearchWixAPISpec\` (\`getResourceSchemaByUrl(docsUrl)\`), then execute. \`SearchWixAPISpec\` is only for INSPECTING a \`docsUrl\` you already have — it is NOT a discovery tool. Skipping this step to hand-search \`lightIndex\` yourself is a mistake: raw index filtering has no relevance ranking and misses operations this ranked search finds. Discover here first, every time.
18053
18137
  If you can't find what you need, rephrase your search term or use a bigger maxResults value.
18054
18138
  ${reminder}
@@ -18056,7 +18140,7 @@ function buildToolDescriptions(includeReadme, includeImageUploadGuidance = true)
18056
18140
  ReadFullDocsArticle: dedent_default`
18057
18141
  Fetches the full Wix docs article or method article with code examples for using the method.
18058
18142
  Docs articles looks like this: https://dev.wix.com/docs/... and they can either be general docs articles or method articles.
18059
- Also reads Wix skills pages — https://www.wix.com/skills/<skill>, https://dev.wix.com/docs/skills/<skill>, and the files they link (e.g. .../<skill>/references/<file>.md) — exactly as served.
18143
+ Also reads Wix skills pages — https://www.wix.com/skills/<skill>, https://dev.wix.com/docs/skills/<skill>, and the files they link (e.g. .../<skill>/references/<file>.md) — and Wix Headless agent pages under https://www.wix.com/headless/ (e.g. https://www.wix.com/headless/skill.md), exactly as served.
18060
18144
  Take the URL from the user's message or an earlier tool result. To reach an article you have no URL for, search or browse the docs first.
18061
18145
  For REST docs, use the URL as-is. For SDK docs, the URL SHOULD include ?apiView=SDK.
18062
18146
  ${reminder}
@@ -18070,6 +18154,7 @@ function buildToolDescriptions(includeReadme, includeImageUploadGuidance = true)
18070
18154
  `,
18071
18155
  CallWixSiteAPI: dedent_default`
18072
18156
  Call Wix apis on a business or site. Use this to create, read, update, and delete data and other Wix entities in your Wix site.
18157
+ ExecuteWixAPI is the preferred tool for Wix API calls: one function holds every call of the task, the reads and the writes they feed together, where this tool makes one call per invocation. If your client loads tools on demand (tool search, deferred tools), load ExecuteWixAPI before using this tool. ${CALL_WIX_SITE_API_RECONNECT_LINE}
18073
18158
  Site-level: this tool reads and writes inside the single site named by the required \`siteId\`.
18074
18159
  **Prefer using the "ListWixSites" tool when the user asks to list or show their sites.** Only use this tool for site listing if the user needs advanced filtering or specific site details beyond what ListWixSites provides.
18075
18160
  For POST/PATCH/PUT requests, pass the request body as a JSON object or array in the "body" parameter with all the required fields and values as described in the API schema, code examples, or docs you retrieved (e.g. body: {"name": "value", "nested": {"key": "value"}} or body: [{"key": "value"}]).
@@ -18084,6 +18169,7 @@ function buildToolDescriptions(includeReadme, includeImageUploadGuidance = true)
18084
18169
  Docs urls like https://dev.wix.com/docs/... are not api urls, if you want to read the docs, use the "ReadFullDocsArticle" tool
18085
18170
  ${reminder}
18086
18171
  `,
18172
+ // Named in SERVER_INSTRUCTIONS: when this tool's name or what it is for changes, update them to match.
18087
18173
  ListWixSites: dedent_default`
18088
18174
  **Use this tool whenever the user asks to list, show, get, or find their Wix sites.** This is the dedicated tool for listing Wix sites for the current user. By default it returns all sites, but you can filter by name.${includeReadme ? "\n\n**Do NOT use WixREADME before this tool.** When the user asks to list their sites, call this tool directly \u2014 no need to read documentation first." : ""}
18089
18175
 
@@ -18104,13 +18190,14 @@ function buildToolDescriptions(includeReadme, includeImageUploadGuidance = true)
18104
18190
  ${reminder}
18105
18191
  `,
18106
18192
  ManageWixSite: dedent_default`
18107
- Use account level API in order to create a site and update a site.
18193
+ Use account level API in order to update a site.
18108
18194
  Account-level only: this tool acts on the account itself, or on sites as objects within it, and sends no site context. Anything that reads or writes inside a site is site-level and does not belong here — use a site-level tool with that site's \`siteId\`.
18109
18195
  For POST/PATCH/PUT requests, pass the request body as a JSON object or array in the "body" parameter with all the required fields and values as described in the API schema, code examples, or docs you retrieved (e.g. body: {"name": "value", "nested": {"key": "value"}} or body: [{"key": "value"}]).
18110
18196
  The API endpoint url param MUST ALWAYS be taken from the conversation context.
18111
18197
  By conversation context we mean the endpoint url was given in the user prompt or got into the conversation context ${includeReadme ? 'by the "WixREADME" tool or ' : ""}by the "SearchWixRESTDocumentation" tool or by the "BrowseWixRESTDocsMenu" tool or by the "ReadFullDocsArticle" tool.
18112
18198
  ${reminder}
18113
18199
  `,
18200
+ // Named in SERVER_INSTRUCTIONS: when this tool's name or what it is for changes, update them to match.
18114
18201
  UploadImageToWixSite: dedent_default`
18115
18202
  Upload one or more images to a Wix site's Media Manager. Returns wixstatic.com URL and media ID.
18116
18203
  Do NOT use ExecuteWixAPI or code execution for image uploads — use this tool directly.
@@ -18120,34 +18207,39 @@ function buildToolDescriptions(includeReadme, includeImageUploadGuidance = true)
18120
18207
  NEVER call this tool with a missing, empty, or guessed siteId — ask first instead.
18121
18208
 
18122
18209
  Parameters — provide image input via image and/or imageUrls, OR imageBase64:
18123
- • image (array): chat file ATTACHMENTS — files the user attached, or files you created in your own file sandbox. Each item is an object with download_url and file_id (both required), plus optional file_name and mime_type. Pass ALL attachments in one call.
18210
+ • image (array): ${fileParamNote("send the image as imageBase64 (the whole file, one per call) or as a public URL in imageUrls")} Pass ALL of them in one call.
18124
18211
  • imageUrls (array): plain public image URLs the user pasted or other tools produced (no file_id). Pass ALL URLs in one call. Can be combined with image.
18125
18212
  • imageBase64 (string): base64-encoded image + mimeType. One image at a time. Do NOT combine with image/imageUrls.
18126
18213
 
18127
18214
  Delivering the bytes — this is where uploads most often fail:
18128
- • Pass a file as a file, in image: the platform resolves it into download_url and file_id before it reaches this tool — this includes files you created in your sandbox. This server does not share your filesystem, so a bare path string (e.g. /mnt/..., /home/user/..., /Users/...) is not a file. Without a file to pass, use a public http(s) URL (imageUrls) or the complete base64 (imageBase64).
18215
+ • This server does not share your filesystem: outside image's clients, a file you can only reach by path (e.g. /mnt/..., /home/user/..., /Users/...) goes as imageBase64 (the whole file, one per call) or, if it is public, as imageUrls.
18129
18216
  • imageBase64 must be the WHOLE file, not truncated. For large images prefer imageUrls, since long base64 is easily cut off and will be rejected as unreadable.
18130
18217
  `,
18131
- SupportAndFeedback: dedent_default`
18132
- Send the user's feedback about the experience of building with Wix — the Wix MCP tools, APIs, docs, and tooling — to Wix, attributed to the authenticated user.
18133
- This is meta-feedback about building with Wix; it is NOT a support channel and not for the user's own site content.
18218
+ // Registered for Claude clients only, beside UploadImageToWixSite.
18219
+ PickImagesForWixMedia: dedent_default`
18220
+ Shows a file picker where the user selects images from their device; they upload to the site's Media Manager and the result (each image's media ID and wixstatic URL) comes back in the conversation.
18221
+ Use it only when you can't deliver the image yourself with UploadImageToWixSite: the image is on the user's device and not in your files, or it is a file in your sandbox that you can't pass as a file, a public URL or base64. When UploadImageToWixSite can take it, use that.
18222
+ `,
18223
+ ReportIssueToWix: dedent_default`
18224
+ Report one specific problem with Wix's tools, APIs or docs to the Wix team, attributed to the authenticated user: an API error or a confusing API, wrong or missing docs, a Wix MCP tool or auth dead end. It is NOT a support channel and not for the user's own site content.
18134
18225
 
18135
18226
  When to offer it (user-approved only — NEVER auto-send):
18136
- - The user explicitly asks to send feedback / report something to Wix ("tell Wix that...", "report this", "send feedback"). Then just confirm the wording and send.
18137
- - The user complains, is frustrated, or reports a Wix bug in the course of the work ("this API is broken", "the docs are wrong", "why is this so hard"). Acknowledge, then offer to pass it on.
18138
- - The session hit substantial friction — repeated API failures, wrong/missing docs, a tooling dead end, or a workaround you had to invent. When you notice the pattern, offer: "This tripped us up a few times — want me to send it to Wix as feedback?"
18139
-
18140
- When you offer, invite the user to add anything in their own words — whatever they give you goes into the message verbatim.
18141
-
18142
- What to send — a summary of the whole run, not just the last error. Structure it in four layers:
18143
- 1. Provenance — agent/model; Wix tooling used; platform/hosting; Wix areas/APIs touched; Wix products; project type/frontend; site id; relevant links (dashboard, docs pages, live site, repos); skill areas/recipes involved; other ids created this run.
18144
- 2. Narrative — user intent and run summary (what they set out to build, what worked vs. what fought back); a condensed play-by-play of the session (key exchanges, tool calls, decisions, course-corrections).
18145
- 3. Friction points — for each friction point: the step/endpoint, HTTP status and error message, the gap, the workaround you had to invent, and what you expected instead. Include ones you recovered from silently — a retry that eventually worked is exactly the signal Wix wants.
18146
- 4. Attribution — per friction point, where the fault likely lives: API behavior / API schema / API reference docs / docs articles or examples / Wix tooling / other/unsure. Don't force a tag; "unsure" beats a wrong route.
18147
- End with a bottom line: one or two sentences on the single most important problem and its impact — a plain engineering assessment, not softened or hedged.
18148
-
18149
- **IMPORTANT**: This tool actually sends the message to Wix. Confirm the final wording with the user and call it only after an explicit yes.
18150
- Do not send on a single transient error, and never more than once for the same issue. Feedback cannot be replied to or tracked by the user.
18227
+ - The user asks to report something to Wix ("tell Wix that...", "report this", "send feedback"). Then confirm the wording and send.
18228
+ - The user complains or reports a Wix bug in the course of the work ("this API is broken", "the docs are wrong"). Acknowledge, then offer to pass it on.
18229
+ - A Wix API, tool or doc kept failing, or you had to invent a workaround for it. Offer: "This tripped us up — want me to report it to Wix?"
18230
+
18231
+ When you offer, invite the user to add anything in their own words — whatever they give you goes into the report verbatim.
18232
+
18233
+ What to send — that one issue, not the session:
18234
+ - What was being attempted, in a sentence.
18235
+ - Where it failed: the tool or endpoint, the HTTP status and error message, and the request id if there is one (pass it as requestId).
18236
+ - What you expected instead, and the workaround if you found one.
18237
+ - Where the fault likely lives: API behavior / API schema / API reference docs / docs articles or examples / Wix tooling / unsure.
18238
+ - Only the context needed to reproduce it: agent/model, site id, the Wix area or API.
18239
+ No session summary or play-by-play, and nothing unrelated to the issue. Several distinct issues are separate reports, each approved by the user.
18240
+
18241
+ **IMPORTANT**: This tool actually sends the report to Wix. Confirm the final wording with the user and call it only after an explicit yes.
18242
+ Do not send on a single transient error, and never more than once for the same issue. Reports cannot be replied to or tracked by the user.
18151
18243
  `,
18152
18244
  BrowseWixRESTDocsMenu: dedent_default`
18153
18245
  Browse the Wix REST API documentation menu hierarchy.
@@ -18169,28 +18261,11 @@ function buildToolDescriptions(includeReadme, includeImageUploadGuidance = true)
18169
18261
  ${reminder}
18170
18262
  `,
18171
18263
  WixSiteCreation: dedent_default`
18172
- ${SITE_GUIDANCE}
18173
-
18174
- Opens the in-chat Wix site creation chooser as an interactive widget where the user chooses between "Build with AI" and "Pick a template."
18175
-
18176
- **Once you can tell what the site is for, call this tool directly** — no ${includeReadme ? "WixREADME, skill," : "skill"} or docs search first.${includeReadme ? " Any other Wix request still starts with WixREADME as usual." : ""}
18177
-
18178
- Call this for normal new Wix site creation requests when the user's site intent is clear, but they have not chosen AI, templates, or Wix Studio.
18179
- Do not guess, and never default to AI — even after the user answers a clarifying question about the site's purpose or features.
18180
- This chooser is how the builder choice gets made — never ask in chat whether they want AI or a template; that choice is made in the widget.
18181
- The widget also does the creating: once the user picks, it runs that path itself and the site is created there, so never call \`WixSiteBuilder\`, \`SearchSiteTemplates\`, or \`CreateSiteFromTemplate\` yourself after opening it.
18182
- After calling, reply with the message it returns, which presents both options and the next steps.
18183
-
18184
- Do not call this if the user explicitly asks to build with AI; call \`WixSiteBuilder\` instead.
18185
- Do not call this if the user asks for templates or Wix Studio; call \`SearchSiteTemplates\` instead.
18186
-
18187
- When calling this tool, infer \`customActions\` from the user's request so the reply can be tailored — 2-3 concrete, industry-specific setup actions for the site (see the input's guidance).
18188
-
18189
- After calling, you MUST speak the message provided in the tool result to the user as your reply — do not stay silent and do not replace it with a one-line pointer to the widget. Write out ALL of it, word for word: its opening line (the "Ready to set up your … site?" question INCLUDING "Choose your path in the widget above:"), BOTH of its option bullets, and its "Next up:" line, each on its own line and in that order. Do not summarize, shorten, drop any line, invent your own opener, rename the options, or add an intro or outro.
18264
+ A new Wix site is written in code and uploaded: call StartDeployWebsite for the upload guide, or StartHeadlessBuild when the site needs Wix business features. WixSiteBuilder or SearchSiteTemplates only when the user asked for the Wix Harmony Editor, a template, Wix Studio or the Classic Editor.
18190
18265
  `,
18191
18266
  "import-claude-design-from-url": dedent_default`
18192
- Import a design created in Claude's design tool into Wix. Takes the signed claudeusercontent.com URL Claude Design produces for its self-contained HTML bundle (all images, fonts, and styles inlined); any other host is rejected. Creates a live Wix-hosted site and returns its URL.
18193
- NOT for a page or site that exists in any other form (the user's own HTML/CSS/JS, a static build, a zip, another builder's export, a page you made in this conversation) — for those call StartDeployWebsite instead; it returns the recipe to publish the files yourself.
18267
+ Import a design created in Claude's design tool into Wix. Only for the signed \`claudeusercontent.com\` bundle URL Claude Design's "Send to Wix" produces (a self-contained HTML bundle with all images, fonts, and styles inlined). Creates a live Wix-hosted site and returns its URL.
18268
+ NOT for claude.ai share or artifact links, GitHub, Drive, chatgpt.com or any other URL, and not for files: those go to StartDeployWebsite, which returns the recipe to publish the files yourself.
18194
18269
  `,
18195
18270
  RunWixCliCommand: dedent_default`
18196
18271
  Executes Wix CLI commands for Wix app development and management.
@@ -18216,6 +18291,13 @@ function buildToolDescriptions(includeReadme, includeImageUploadGuidance = true)
18216
18291
  `,
18217
18292
  SearchWixWDSDocumentation: dedent_default`
18218
18293
  Searches the Wix Design System (WDS) documentation.
18294
+ `,
18295
+ SearchWixHelpCenter: dedent_default`
18296
+ Searches the Wix Help Center (support.wix.com): how site owners do things in the Wix dashboard and editors, such as connecting a domain, managing a Premium plan, setting up a store or bookings, and fixing account or site issues.
18297
+ ${HELP_CENTER_IS_FOR_PEOPLE}
18298
+ Use it for "how do I ... in Wix" questions about the product, or to give the user click-by-click steps for something no API covers.
18299
+ Not for building with code: for Wix APIs, SDK, CLI, apps, or Headless, use the matching developer documentation search.
18300
+ Results are excerpts; read a full article by passing its support.wix.com link to \`ReadFullDocsArticle\`.
18219
18301
  `,
18220
18302
  SearchWixSDKDocumentation: dedent_default`
18221
18303
  Searches the Wix JavaScript SDK documentation.
@@ -18226,7 +18308,7 @@ function buildToolDescriptions(includeReadme, includeImageUploadGuidance = true)
18226
18308
  `,
18227
18309
  SearchDevelopmentDocumentation: dedent_default`
18228
18310
  Broad Wix development documentation (platform concepts, developer guides, getting started). **Last resort — development tasks only.**
18229
- Skip it entirely for general, business, support, or Wix-editor questions.
18311
+ Skip it entirely for general, business, support, or Wix-editor questions; for those, use \`SearchWixHelpCenter\`.
18230
18312
  Call it only after the specific search for your task returned nothing useful: \`SearchWixRESTDocumentation\` (REST), \`SearchWixSDKDocumentation\` (JS SDK), \`SearchWixCLIDocumentation\` (CLI), \`SearchBuildAppsDocumentation\` (apps), \`SearchWixHeadlessDocumentation\` (Headless), \`SearchWixWDSDocumentation\` (WDS). Never use it as a first search.
18231
18313
  `,
18232
18314
  SearchWixHeadlessDocumentation: dedent_default`
@@ -18238,7 +18320,8 @@ function buildToolDescriptions(includeReadme, includeImageUploadGuidance = true)
18238
18320
  // `sdk` is simply absent on methods the SDK docs don't list.
18239
18321
  SearchWixAPISpec: dedent_default`
18240
18322
  Inspect the Wix REST API spec, and the JavaScript SDK call for each method, by writing JavaScript code that runs in a sandboxed read-only environment.
18241
- **Precondition:** you already have a method \`docsUrl\` — from \`SearchWixRESTDocumentation\`, \`SearchWixSDKDocumentation\` (its \`?apiView=SDK\` URLs work here as-is), \`BrowseWixRESTDocsMenu\`, \`ReadFullDocsArticle\`, ${includeReadme ? "a `WixREADME` recipe, " : ""}or a prior tool result / the user's message in this conversation. If you don't have one yet, call \`SearchWixRESTDocumentation\` (or \`SearchWixSDKDocumentation\` when writing SDK code) FIRST to discover it; do not use this tool to search for or choose an endpoint.
18323
+ The spec covers every Wix product's methods and their data: ${WIX_API_DATA}.
18324
+ **Precondition:** you already have a method \`docsUrl\` — from \`SearchWixRESTDocumentation\`, \`SearchWixSDKDocumentation\` (its \`?apiView=SDK\` URLs work here as-is), \`BrowseWixRESTDocsMenu\`, \`ReadFullDocsArticle\`, ${includeReadme ? "a Wix skill, " : ""}or a prior tool result / the user's message in this conversation. If you don't have one yet, call \`SearchWixRESTDocumentation\` (or \`SearchWixSDKDocumentation\` when writing SDK code) FIRST to discover it; do not use this tool to search for or choose an endpoint.
18242
18325
  **Never pass a \`docsUrl\` you produced from memory.** If the exact URL you are about to pass to \`getResourceSchemaByUrl\` did not appear verbatim in an earlier tool result (or the user's message), it is a guess — call \`SearchWixRESTDocumentation\` first and use a URL from its ranked results. A guessed URL that merely looks plausible routinely resolves to the WRONG sibling method (e.g. \`.../products-v3/create-product\` when the task needs \`.../products-v3/create-product-with-inventory\`), sending the whole turn down a dead end. When in doubt, discover — don't guess.
18243
18326
  **This tool's job is to INSPECT the exact schema of a method you have ALREADY located — its request/response shape, nested types, and enums, and its SDK call (\`method.sdk\`). It is NOT a discovery tool for choosing which method to use.**
18244
18327
  With a method \`docsUrl\` in hand, call \`getResourceSchemaByUrl(methodDocsUrl)\` to get the resource schema, then read the target method from \`schema.methods\` and resolve any nested \`{ $circular: name }\` types via \`schema.components.schemas[name]\`.
@@ -18619,31 +18702,22 @@ function buildToolDescriptions(includeReadme, includeImageUploadGuidance = true)
18619
18702
  \`\`\`
18620
18703
  `,
18621
18704
  ExecuteWixAPI: executeWixApiDescription,
18705
+ // Named in SERVER_INSTRUCTIONS: when this tool's name or what it is for changes, update them to match.
18622
18706
  WixSiteBuilder: dedent_default`
18623
- ${SITE_GUIDANCE}
18624
-
18625
- Tool for generating a Wix site with AI (creating / building a site in Wix Harmony) from a description. It does not take pages or files you already have — those go to StartDeployWebsite.
18626
-
18627
- Call this ONLY when the user's own words name AI (for example "create a site using AI" or "build it with AI") and the site intent is clear. A description of what the site should do — reservations, online ordering, a store, bookings, menus, a portfolio, and the like — is NOT a request for AI and NOT enough to call this tool; never infer AI from features or industry.
18628
- Never default to this tool: if the user hasn't explicitly named AI, don't call this tool — ${SITE_CREATION_COPY.unstatedMethod.nonWidget}.
18629
-
18630
- For templates or Wix Studio, call \`SearchSiteTemplates\`; for a specific template by \`metaSiteId\` or \`templateId\`, call \`CreateSiteFromTemplate\`; for a headless or classic Wix Editor site, or manual/account-API creation, call \`CreateWixBusinessGuide\`.
18631
-
18632
- Do NOT suggest HTML code, prompt templates, or alternative approaches instead of building — actually build the site through this tool. (HTML the user already has is the StartDeployWebsite case, not a reason to build.)
18707
+ A secondary site-creation tool, only for a user who asked for the Wix Harmony Editor or for Wix to design the site. Don't call it for any other site request, not even to check with the flag false. A new site is otherwise written in code and uploaded, with StartDeployWebsite, or StartHeadlessBuild when it needs Wix business features.
18708
+ Builds a site with the Wix Harmony Editor: Wix designs a first version from the user's description, and the user keeps designing it in Wix's editor. Shows the build's progress and a preview.
18709
+ Call it when the user asked for the Wix Harmony Editor, or for Wix to design the site, in their own words or as their answer to your question. ${EDITOR_TAIL}
18633
18710
  `,
18711
+ // Named in SERVER_INSTRUCTIONS: when this tool's name or what it is for changes, update them to match.
18634
18712
  SearchSiteTemplates: dedent_default`
18635
- ${SITE_GUIDANCE}
18636
-
18637
- Searches Wix templates and shows the template gallery, from the Harmony or the Studio template source.
18638
-
18639
- Call this ONLY when the user's own words ask for a template or for Wix Studio (for example "start from a template", "show me some templates", "build it in Wix Studio") and you can already tell what the site is for. If they mention Wix Studio, search Studio templates; otherwise search Harmony templates.
18640
- ${SITE_CREATION_COPY.templatePick.nonWidget}
18641
-
18642
- A description of what the site should do — bookings, a store, a menu, a portfolio, and the like — is NOT a request for templates or for Wix Studio; never infer either from features or industry. Templates are not the default: if the site intent is clear but no method is named, do not guess — ${SITE_CREATION_COPY.unstatedMethod.nonWidget}.`,
18713
+ A secondary site-creation tool, only for a user who asked for a template, Wix Studio or the Classic Editor. Don't call it for any other site request, not even to check with the flag false. A new site is otherwise written in code and uploaded, with StartDeployWebsite, or StartHeadlessBuild when it needs Wix business features.
18714
+ Shows a gallery of Wix templates, from Harmony, Wix Studio or the Classic Editor, for a site the user will design in Wix's editor. Wix templates come with Wix's business features (a store, online ordering, bookings, forms), so a request for a template comes here even when the site needs them.
18715
+ Call it when the user asked for a template, Wix Studio or the Classic Editor, in their own words or as their answer to your question. ${EDITOR_TAIL} ${SITE_CREATION_COPY.templatePick.nonWidget}
18716
+ `,
18643
18717
  CreateSiteFromTemplate: dedent_default`
18644
18718
  Creates a Wix site from a specific template (by \`metaSiteId\` or \`templateId\`), publishes it when possible, and shows a live preview with links to the editor and the published site.
18645
18719
 
18646
- Call this when the user provides a specific template by \`metaSiteId\` or \`templateId\`. Use this only when the user gives a valid \`metaSiteId\` or \`templateId\` directly. To browse or choose a template first, call \`SearchSiteTemplates\`.
18720
+ Call this when the user provides a specific template by \`metaSiteId\` or \`templateId\`. Use this only when the user gives a valid \`metaSiteId\` or \`templateId\` directly. To browse or choose a template first, call \`SearchSiteTemplates\` (\`builder: classic\` for a Classic Editor site).
18647
18721
 
18648
18722
  `,
18649
18723
  SearchWixGraphQLOperations: dedent_default`
@@ -18672,113 +18746,212 @@ function buildToolDescriptions(includeReadme, includeImageUploadGuidance = true)
18672
18746
  Results: each root field fails independently — \`errors[].path\` names the failing field and \`errors[].extensions.message\` the cause (e.g. PERMISSION_DENIED); \`data\` still holds the fields that succeeded. Mutations return the created/updated entity — read the IDs from it and do not re-query to verify. Large results are truncated: narrow the selection or page size instead of re-running.
18673
18747
  Set \`hasMutations: true\` for any document containing a mutation root field.
18674
18748
  `,
18749
+ UploadHeadlessWebsiteFiles: dedent_default`
18750
+ The upload step of the StartDeployWebsite and StartHeadlessBuild guides, and nothing else: puts a finished website's files — a static site (index.html plus its CSS/JS/images, a static build, or a zip of the site) or a Wix Astro build — onto an existing Wix Headless site by its metaSiteId. Call it ONLY after one of them has returned its guide in this conversation and the site exists: for a new site, first run the recipe's provision call and pass the metaSiteId it returns; for a site deployed earlier, pass its metaSiteId. It does not create sites. Every upload replaces the whole file set and the URL stays. Returns the live URL and the dashboard link, and points back to the recipe for what comes next.
18751
+ Pass the files themselves: in ${FILE_PARAM_CLIENTS} as \`attachments\` (any type, a zip is unpacked), elsewhere as the \`files\` text bundle (\`=== FILE: <path> ===\` sections, \`base64\` tag for small binaries). A static site must contain index.html at its root. A Wix Astro build with no file handle, from a shell that reaches the internet, goes in two calls: zip the build, call with \`prepare: true\` and the zip's \`size\` in bytes, PUT the zips it names with the \`curl\` commands it returns (the build, and the project source when the site's repository accepts it), then call again with the \`uploadKey\` it returned; that releases the build. The two calls, literally: {siteId, prepare: true, size} then {siteId, uploadKey, sourceUploadId?, expectedHeadRevisionId?, releaseNotes?}. A sandbox whose network is limited to a few hosts cannot upload to those URLs. A static site does not use the two calls. A Wix Astro build (the project's .wix/ and dist/ after \`astro build\` with the Wix hosting adapter, zipped from the project root) needs no index.html: it is released to the site's Wix hosting instead, server-rendered pages, the same site and URL. The project's source is stored with the release when the upload holds the project and the site's repository accepts it.
18752
+ NOT a site-creation tool: a request to create, build, design or generate a site — with or without a description — never comes here first. Unless the user asked for Wix's editor or a template (WixSiteBuilder, SearchSiteTemplates), call StartDeployWebsite right away, without asking the user anything: it also takes files the user brought, uploaded first even when the site needs business features. StartHeadlessBuild instead for a new site with no files that needs Wix business features. Also NOT for media uploads to an existing site (UploadImageToWixSite) or any other API call (ExecuteWixAPI).
18753
+ `,
18754
+ // Named in SERVER_INSTRUCTIONS: when this tool's name or what it is for changes, update them to match.
18675
18755
  StartDeployWebsite: dedent_default`
18676
- The user — or you, earlier in this conversation — ALREADY HAVE a finished page or site, in any form, and it should be live on Wix — or an already-deployed Wix Headless site whose files should be replaced. The site can be HTML/CSS/JS files, a static build (dist/, out/), a zip, another AI builder's export, or a page/design you created in this conversation (export it to HTML first — a finished design IS a finished page). Call this when the user says deploy, host, publish, put online, make it live, get a URL, update my site, or upload my site / index.html.
18677
- Updates keep the same site and URL. Also for implementing a backend on such a site as a Wix Headless project — same site, same URL. Works with or without a Wix login (anonymous deploy with a save link), through the Wix MCP alone or from a shell.
18678
- Missing real functionality — a fake checkout, a form that goes nowhere, bookings — is NOT a reason to rebuild the site with a site-creation tool: deploy the page as is, then add the backend afterwards (the recipe covers it).
18679
- Returns the full recipe; follow it and run the flow yourself. The drop page is only the fallback when you can't.
18680
- NOT for: a screenshot, mockup or reference image of a site the user WANTS (nothing exists to deploy yet — that is site creation: WixSiteBuilder / templates); a Claude Design share URL (import-claude-design-from-url); migrating a live site by URL or CSV exports; adding HTML or code into an existing Wix site; uploading images or documents to a site's media (UploadImageToWixSite).
18756
+ Creates a website on Wix and puts it live, or replaces the files of one deployed earlier. You write the site's code, or take the files the user brought (HTML/CSS/JS, a static build, a zip, another builder's export), and this returns the guide to create the site and upload them. Updates keep the same site and URL. Works with or without a Wix login (anonymous deploy with a save link), through the Wix MCP alone or from a shell. Call it right away, without asking the user anything first.
18757
+ When a new site needs Wix business features (${WIX_BUSINESS_FEATURES}), call StartHeadlessBuild instead. When the user brought files and the site needs those features, upload the files here first; the upload's result then points to StartHeadlessBuild to connect them.
18758
+ Returns the guide; follow it and do the work yourself. Upload with UploadHeadlessWebsiteFiles once the site exists; the drop page is only the fallback.
18759
+ NOT for: a user who asked for Wix's editor, the Wix Harmony Editor, a template, Wix Studio or the Classic Editor (WixSiteBuilder, SearchSiteTemplates); a Claude Design bundle URL (import-claude-design-from-url); migrating a live site by URL or CSV exports; adding HTML or code into an existing Wix editor site; uploading images or documents to a site's media (UploadImageToWixSite).
18681
18760
  `,
18682
- CreateWixBusinessGuide: dedent_default`
18683
- Provides comprehensive documentation for creating a new Wix business (site, app, etc.).
18684
- Call this ONLY when the user explicitly asks for a headless site, a Wix Classic Editor site, or manual/advanced account/API-based site creation — these don't need the site's purpose first. For normal site-creation ${SITE_CREATION_COPY.normalCreationRoute.nonWidget}; for a specific template id, call \`CreateSiteFromTemplate\`.
18685
- Exception, even when the user says "headless": if a finished page or site already exists in any form (their own HTML/CSS/JS, a static build, a zip, an AI-builder export, a page you made in this conversation) and they want it hosted, don't call this tool — call StartDeployWebsite, which returns the recipe to publish the files yourself. This guide's CLI flow is for BUILDING a headless frontend, not for hosting ready-made files.
18686
-
18687
- ## What This Tool Contains
18688
-
18689
- This tool provides complete documentation including:
18690
- - Template selection (empty sites or designed templates)
18691
- - Wix Editor vs Wix Studio options
18692
- - Regular vs Headless site creation (CLI-based; returns setup instructions)
18693
- - API endpoint details and parameters
18694
- - Post-creation steps (OAuth for headless, publishing for regular sites)
18695
- - App installation instructions
18696
-
18697
- ## After Reading This Documentation
18698
-
18699
- **After reading this documentation:**
18700
- 1. Use ManageWixSite for account-level site creation API calls
18701
- 2. Use CallWixSiteAPI / ExecuteWixAPI for site-level follow-up API calls (like install apps if needed)`
18761
+ // Named in SERVER_INSTRUCTIONS: when this tool's name or what it is for changes, update them to match.
18762
+ StartHeadlessBuild: dedent_default`
18763
+ Returns Wix's headless guide, for a site that needs Wix business features (${WIX_BUSINESS_FEATURES}), run by Wix as a Wix Headless site. You write the site; the guide creates it, connects the features, and uploads it. Also to add those features to an existing Wix Headless site (one deployed from files is one), from a project download link, or to move a Wix site to code.
18764
+ Call it right away: it only returns the guide, and the site's details are not needed first.
18765
+ NOT for: a site that needs no Wix business feature, or files the user brought that are not live yet (StartDeployWebsite: upload them first, then come back here for the features); a user who asked for Wix's editor, the Wix Harmony Editor, a template, Wix Studio or the Classic Editor, even when the site needs business features (WixSiteBuilder, SearchSiteTemplates); a Claude Design URL (import-claude-design-from-url).
18766
+ `
18702
18767
  };
18768
+ descriptions.SupportAndFeedback = descriptions.ReportIssueToWix;
18769
+ return descriptions;
18703
18770
  }
18704
- var defaultToolDescriptions = buildToolDescriptions(true);
18771
+ var defaultToolDescriptions = buildToolDescriptions(true, true, { usageGuideOnce: true });
18705
18772
  var executeCodeModeToolDescriptions = {
18706
18773
  ExecuteWixAPI: executeWixApiDescription
18707
18774
  };
18775
+ var WIX_SKILLS_README_SECTION = dedent_default`
18776
+ ## Wix skills
18777
+
18778
+ Wix publishes agent skills: folders of instructions, scripts and shipped code for building on Wix, each with a \`SKILL.md\` at its root that says what the skill does and which of its files to read when. The source is https://github.com/wix/skills. Three of them matter here:
18779
+
18780
+ - **wix-headless-kit**: builds a Wix Headless site on shipped, verified code. In the Wix plugin. Its contents are below.
18781
+ - **wix-headless-templates**: the code wix-headless-kit builds from, one folder per Wix Business Solution. In the Wix plugin for Codex and Cursor. Its contents are below.
18782
+ - **wix-manage**: REST recipes to configure and manage a site's business solutions. In the Wix plugin. Its \`SKILL.md\` is the index of every recipe by area, with what it does and a link to read it.
18783
+
18784
+ On a site built in code (one deployed through StartDeployWebsite, started through StartHeadlessBuild, or any Wix Headless project), wix-headless-kit carries the work, with wix-headless-templates as its code, and it names the wix-manage recipes it uses as steps.
18785
+
18786
+ ### How to read a skill
18787
+
18788
+ A skill is a folder, and every file in it has a path inside that folder (\`SKILL.md\`, \`guides/api-run.md\`). The same path finds the file on disk and online, so the paths below work either way.
18789
+
18790
+ 1. **From disk, when it is already there.** This is the preferred way: the files are complete and need no network. The Wix plugin loads its skills into the client; \`npx skills add\` puts them under \`.agents/skills/<skill>/\` in the project, or in the user's home with \`-g\`; an earlier install may have left them wherever the client keeps skills (for example \`.claude/skills/\` or the plugin's folder). Open \`<skill folder>/SKILL.md\` and the files it names. An installed copy can be an older snapshot. A file whose byte size differs from the one in the skill's manifest (below) is out of date, so read it online; a matching size makes a file likely current, not certain, so when a file decides the work, read it online too.
18791
+ 2. **Install them, with a shell that reaches the internet.** \`npx skills add wix/skills\` installs every skill; \`npx skills add wix/skills --skill wix-headless-kit\` installs one. Then read them from disk. To keep them across projects, the user can install the Wix plugin instead (in Claude Code: \`/plugin marketplace add wix/skills\`, then \`/plugin install wix@wix\`).
18792
+ 3. **Read them online, with ReadFullDocsArticle**, when neither works: no shell, or a sandbox without internet. Call ReadFullDocsArticle with the URL as \`articleUrl\`; it returns the file whole, where a client's own web tool often cannot reach www.wix.com or summarizes what it fetches. The skills registry mirrors every skill from the main branch of wix/skills:
18793
+ - **A file**: \`https://www.wix.com/skills/<skill>/<path>\`, with \`<path>\` its path inside the skill folder. Start with \`<path>\` = \`SKILL.md\`, then read the files it names.
18794
+ - **A folder**: \`https://www.wix.com/skills/<skill>/<folder>\` returns the full URL of every file under it, at any depth. \`https://www.wix.com/skills/<skill>/<folder>/_content\` returns those files' contents in one response, each under a heading with its URL, Markdown first; binary files and lockfiles are left out, and past 150K characters the rest are named by URL, to read one by one.
18795
+ - **The skill's file list**: \`https://www.wix.com/skills/<skill>/\`, with the trailing slash, returns the full URL of every file in the skill; without the slash it returns the SKILL.md.
18796
+ - **Every file in the skill**: \`https://www.wix.com/skills/<skill>.manifest.json\` lists each path with its size, under a \`base\` URL.
18797
+ - **Names and hosts**: \`<skill>\` is the folder name with or without its \`wix-\` prefix (\`wix-headless-kit\` or \`headless-kit\`), and \`dev.wix.com\` works in place of \`www.wix.com\`.
18798
+ - **What comes back**: a Markdown file comes with a short note on top (it is mirrored from the main branch of wix/skills; the skill's manifest, folder listings, \`_content\`, and ReadFullDocsArticle) and its relative links turned into full URLs; code, scripts and JSON come as they are.
18799
+ - **A wrong path**: the answer names the files with that name elsewhere in the skill and the manifest URL, so one more call reaches the right file. ReadFullDocsArticle shows that answer as an error.
18800
+ - **Not served**: a whole skill as one page (\`<skill>-full\`) returns 404; read the skill's files instead.
18801
+
18802
+ The wix-manage recipes are also published in the Wix docs, as articles at \`…/skills/<recipe>\` under each API's section. Find the one that matches the task in the skill's recipe index (\`SKILL.md\`) or with SearchWixRESTDocumentation, and read it with ReadFullDocsArticle. Only wix-manage is in the docs. For example, one recipe in all three places:
18803
+ - on disk: \`<wix-manage folder>/references/sites/upload-static-site.md\`;
18804
+ - in the registry: https://www.wix.com/skills/manage/references/sites/upload-static-site.md;
18805
+ - in the docs: https://dev.wix.com/docs/api-reference/account-level/sites/skills/upload-a-website-or-html-files.
18806
+
18807
+ ### wix-manage
18808
+
18809
+ REST recipes for managing a site's business solutions: one recipe per task (installing apps, products, booking services, CMS items, SEO, domains and more), each with the exact endpoints, request bodies and order of steps. Open the recipe for a task before calling its APIs.
18810
+
18811
+ Ways to find and read a recipe, in this order:
18812
+ 1. **On disk**: the Wix plugin's wix-manage folder, or \`.agents/skills/wix-manage/\` after \`npx skills add wix/skills --skill wix-manage\`. \`SKILL.md\` lists every recipe by area with what it does; the recipe itself is under \`references/<area>/\` (ecommerce nests one more folder, such as \`references/ecommerce/shipping/\`), so open the path \`SKILL.md\` gives rather than building it. An installed copy can be an older snapshot: when a recipe decides the work, read it online too.
18813
+ 2. **Online**: the list of every recipe by area, each a link to its docs article, is https://dev.wix.com/docs/api-reference/articles/ai-tools/wix-mcp/skills/wix-management-recipes-index.md. Read it with ReadFullDocsArticle, or with \`curl\` from a shell, then read the recipe for the task the same way. It is public: no sign-in or token.
18814
+
18815
+ Using a recipe: follow its steps, and make its calls with ExecuteWixAPI, passing the recipe's docs URL in \`sourceDocUrls\`. When a recipe's example doesn't fit a call, read that method's schema with SearchWixAPISpec first. When no recipe matches the task, find the method with SearchWixRESTDocumentation or BrowseWixRESTDocsMenu, read it with ReadFullDocsArticle, and call it the same way.
18816
+ Each API area also has a page that lists only its own recipes: the area's docs section with \`/skills.md\` appended. These are the ones today, but it is not a closed list: areas are added, so look a task up in the full list first, and for an API not named here try its section URL with \`/skills.md\` appended.
18817
+ - Accessibility: https://dev.wix.com/docs/api-reference/site/accessibility/skills.md
18818
+ - Analytics: https://dev.wix.com/docs/api-reference/business-management/analytics/skills.md
18819
+ - App Installation: https://dev.wix.com/docs/api-reference/business-management/app-installation/skills.md
18820
+ - App tools: https://dev.wix.com/docs/api-reference/app-management/app-tools/skills.md
18821
+ - Automations: https://dev.wix.com/docs/api-reference/business-management/automations/skills.md
18822
+ - Blog: https://dev.wix.com/docs/api-reference/business-solutions/blog/skills.md
18823
+ - Bookings: https://dev.wix.com/docs/api-reference/business-solutions/bookings/skills.md
18824
+ - Calendar: https://dev.wix.com/docs/api-reference/business-management/calendar/skills.md
18825
+ - CMS: https://dev.wix.com/docs/api-reference/business-solutions/cms/skills.md
18826
+ - Contacts: https://dev.wix.com/docs/api-reference/crm/members-contacts/contacts/skills.md
18827
+ - Domains: https://dev.wix.com/docs/api-reference/account-level/domains/skills.md
18828
+ - eCommerce: https://dev.wix.com/docs/api-reference/business-solutions/e-commerce/skills.md
18829
+ - Events: https://dev.wix.com/docs/api-reference/business-solutions/events/skills.md
18830
+ - Forms: https://dev.wix.com/docs/api-reference/crm/forms/skills.md
18831
+ - Get Paid: https://dev.wix.com/docs/api-reference/business-management/get-paid/skills.md
18832
+ - Google Ads: https://dev.wix.com/docs/api-reference/business-management/marketing/ads/google-ads/skills.md
18833
+ - Google Business Profile: https://dev.wix.com/docs/api-reference/business-management/google-business-profile/skills.md
18834
+ - Google Search Console: https://dev.wix.com/docs/api-reference/business-management/seo/google-search-console/skills.md
18835
+ - Headless: https://dev.wix.com/docs/api-reference/business-management/headless/skills.md
18836
+ - Marketing: https://dev.wix.com/docs/api-reference/business-management/marketing/skills.md
18837
+ - Media: https://dev.wix.com/docs/api-reference/assets/media/skills.md
18838
+ - Pricing Plans: https://dev.wix.com/docs/api-reference/business-solutions/pricing-plans/skills.md
18839
+ - Restaurants: https://dev.wix.com/docs/api-reference/business-solutions/restaurants/skills.md
18840
+ - Rich Content: https://dev.wix.com/docs/api-reference/assets/rich-content/skills.md
18841
+ - SEO: https://dev.wix.com/docs/api-reference/business-management/seo/skills.md
18842
+ - SEO redirects: https://dev.wix.com/docs/api-reference/business-management/seo/redirects/skills.md
18843
+ - Site Properties: https://dev.wix.com/docs/api-reference/business-management/site-properties/skills.md
18844
+ - Sites: https://dev.wix.com/docs/api-reference/account-level/sites/skills.md
18845
+ - Stores: https://dev.wix.com/docs/api-reference/business-solutions/stores/skills.md
18846
+ - Wix MCP: https://dev.wix.com/docs/api-reference/articles/ai-tools/wix-mcp/skills.md
18847
+
18848
+ ### wix-headless-kit
18849
+
18850
+ Builds a Wix Headless site on shipped, verified code instead of writing the integration: each Wix Business Solution comes with a typed data layer, hooks, components, pages and a seed script that are already correct. The data layer ships twice, on \`@wix/sdk\` for the React core and as plain REST calls for a stack that cannot run it (\`guides/reference-mode.md\`), and the agent's work narrows to brand, layout, copy and wiring. It runs as a CLI flow from a shell that reaches Wix, and as Wix API calls through this MCP when it cannot.
18851
+
18852
+ Paths are inside the skill folder; online, each is \`https://www.wix.com/skills/headless-kit/<path>\`.
18853
+ - Before the skill: the cold start installs it, signs in and hands off. It is another skill's file, https://www.wix.com/skills/headless-cold-start/headless-kit.md, and StartHeadlessBuild returns it.
18854
+ - \`SKILL.md\`: the steps of a build and the table of Business Solutions the kit ships.
18855
+ - \`guides/api-run.md\`: the whole run as Wix API calls through this MCP, for an agent whose shell cannot reach Wix or that has no shell.
18856
+ - \`guides/capabilities.md\`: which Wix product owns which feature, and what the kit ships for it.
18857
+ - \`guides/existing-site.md\`: a new frontend for a Wix site that already has its content.
18858
+ - \`guides/migration.md\`: a site moving to code after "Go Headless" in its dashboard.
18859
+ - \`guides/reference-mode.md\`: a stack that cannot run the shipped React code (a static site, a server-rendered app in another language).
18860
+ - \`guides/feedback.md\`: sending the user's building-with-Wix feedback to Wix.
18861
+ - \`install/\`: the bootstrap, setup, deploy and templates scripts, and \`install/pins.json\` with the pinned CLI and templates versions.
18862
+
18863
+ ### wix-headless-templates
18864
+
18865
+ The code wix-headless-kit builds from, one folder per Wix Business Solution: \`storefront\`, \`bookings\`, \`rentals\`, \`blog\`, \`cms\`, \`forms\`, \`members\`, \`events\`, \`restaurants\`, \`donations\`, \`pricing-plans\`, \`portfolio\`, \`faq\`. It holds no flow of its own; wix-headless-kit fetches it and copies, deploys and seeds from it.
18866
+
18867
+ Paths are inside the skill folder; online, each is \`https://www.wix.com/skills/headless-templates/<path>\`. Every Business Solution folder has the same parts, with \`<solution>\` one of the names above:
18868
+ - \`<solution>/INSTRUCTIONS.md\`: the playbook, covering what ships, what you build, and each page's contract.
18869
+ - \`<solution>/app/\`: the typed React core: the data layer under \`wix/<solution>/\`, hooks and components.
18870
+ - \`<solution>/app-astro/\`: the Astro page skeletons for Wix-managed Astro sites (every solution but \`forms\`).
18871
+ - \`<solution>/project/\`: the whole runnable project for that solution.
18872
+ - \`<solution>/rest/\`: the same data layer as plain REST calls, for stacks that cannot run the React core.
18873
+ - \`<solution>/seed/SEED.md\`: how to seed that solution's content, with the script that creates it in the right order.
18874
+
18875
+ Shared by every solution:
18876
+ - \`shared/DESIGN.md\`: the design floor when the brief gives no design direction.
18877
+ - \`shared/CONTENT.md\`: the copy floor for every page written.
18878
+ - \`shared/SUPPLIED-CONTENT.md\`: content the user brings (a CSV, a menu, a folder of photos) as the seed plan.
18879
+ - \`shared/CUSTOM_OPERATIONS.md\`: operations beyond what the shipped code covers.
18880
+ - \`shared/rest/client.ts\`: the REST client the \`rest/\` layers use.
18881
+
18882
+ Online, a solution's folder lists everything it ships: https://www.wix.com/skills/headless-templates/storefront returns the URLs of the store's files, and \`…/storefront/app\` those of its React core. A part is often small enough to read whole in one call: https://www.wix.com/skills/headless-templates/storefront/seed/_content returns the store's seeding guide and scripts together. A whole solution passes the 150K cap, so read it part by part.
18883
+ `;
18708
18884
  var recipesIndexDoc = {
18709
18885
  url: "https://dev.wix.com/docs/api-reference/articles/ai-tools/wix-mcp/skills/wix-management-recipes-index",
18710
18886
  action: "include"
18711
18887
  };
18712
18888
  var README_INTRO = dedent_default`
18713
- <agent-mandatory-instructions>
18889
+ # How to work with Wix through these tools
18714
18890
 
18715
- YOU MUST READ AND FOLLOW THE AGENT-MANDATORY-INSTRUCTIONS BELOW:
18891
+ ## Source of truth
18716
18892
 
18717
- <source-of-truth>
18718
- Do not answer from memory about anything Wix-specific — this covers every part of your answer, not only API calls: any URL, link, ID, setting location, or product fact you give the user must come from the docs tools, the recipes below, a previous tool result in this conversation, or the user's own message (identifiers and URLs the user supplies are fine to use as given). If a recipe in the index below matches what the user asked for, read it before answering. For APIs, use the search, browse, read-docs, and schema tools as the source of truth for the exact URL, HTTP method, request body shape, response shape, field names, required fields, and enum values before calling an API.
18719
- </source-of-truth>
18893
+ Do not answer from memory about anything Wix-specific — this covers every part of your answer, not only API calls: any URL, link, ID, setting location, or product fact you give the user must come from the docs tools, a Wix skill (installed, or read online as the Wix skills section below explains), a previous tool result in this conversation, or the user's own message (identifiers and URLs the user supplies are fine to use as given). When a Wix skill covers what the user asked for, read it before answering. For APIs, use the search, browse, read-docs, and schema tools as the source of truth for the exact URL, HTTP method, request body shape, response shape, field names, required fields, and enum values before calling an API.
18720
18894
 
18721
- <management-flow>
18722
- <goal>
18895
+ ## Goal
18723
18896
  `;
18724
- var README_FLOWS_HEADING = dedent_default`
18725
- </goal>
18897
+ var README_FLOWS_HEADING = "## Wix MCP Flows";
18898
+ var README_FLOWS_SITE = dedent_default`
18899
+ ### The site
18726
18900
 
18727
- ## Wix MCP Site Management Flows
18901
+ The site context below lists the account's sites with their installed apps. Take the \`siteId\` from there; when more than one site fits and the user's words don't pick one, ask which before any read or write. A business solution's API (Stores, Bookings, CMS and the rest) works only on a site with that app installed, and some apps have versions with different endpoints (Wix Stores V1 vs V3): check the site's apps first, and when the app is missing, install it (a Wix skill has the steps) before using its API.
18728
18902
  `;
18729
- var README_BODY = dedent_default`
18730
- ### Discovery & Call Flow
18903
+ var README_FIND_SOURCES = dedent_default`
18904
+ ### Find the method
18731
18905
 
18732
- Common paths (use the highest you can satisfy for each method you'll call):
18733
- - Already have what you need from previous tool results in this conversation (not from memory) → ExecuteWixAPI
18734
- - Pick a matching article from the Recipes index below → ReadFullDocsArticle (find relevant code examples) → (probe SearchWixAPISpec for response shapes if needed) → ExecuteWixAPI
18735
- - SearchWixRESTDocumentation or BrowseWixRESTDocsMenu → ReadFullDocsArticle (find relevant code examples) → (probe SearchWixAPISpec for response shapes if needed) → ExecuteWixAPI
18736
- - SearchWixRESTDocumentation or BrowseWixRESTDocsMenu → ReadFullDocsArticle (no usable example) → SearchWixAPISpec for request schemas → ExecuteWixAPI
18906
+ A task may need several API methods. For each, take the first source that gives it:
18907
+ - A previous tool result in this conversation (not memory) already shows its request: go straight to the call.
18908
+ - A Wix skill that covers the task (the Wix skills section below says what each is for): follow it, from disk or online. When its example for a call matches your case, that is the source: pass its docs URL in \`sourceDocUrls\` instead of searching for the method pages (when it has no docs URL, one SearchWixRESTDocumentation call on its title finds the article).
18909
+ - The docs: SearchWixRESTDocumentation (semantic search) or BrowseWixRESTDocsMenu (menu hierarchy), then ReadFullDocsArticle on the method's article for its code examples. For SDK code, the CLI, a headless site or an app, start from those docs instead: SearchWixSDKDocumentation, SearchWixCLIDocumentation, SearchWixHeadlessDocumentation, SearchBuildAppsDocumentation.
18737
18910
 
18738
- Fallbacks: use ReadFullDocsMethodSchema in place of SearchWixAPISpec when SearchWixAPISpec is unavailable or didn't return enough detail; use CallWixSiteAPI in place of ExecuteWixAPI when a single REST call is enough and code adds no value.
18911
+ Keep each method's docs URL even when no source gives a usable example: the shape comes from its schema, as the next section says.
18912
+ `;
18913
+ var README_FLOWS_BODY = dedent_default`
18914
+ ### The exact shape
18739
18915
 
18740
- Tools (relevant for the management flow):
18741
- - SearchWixRESTDocumentation — semantic search over the Wix REST docs by keywords or natural-language queries.
18742
- - BrowseWixRESTDocsMenu — navigate the Wix REST docs by menu hierarchy; alternative to keyword search.
18743
- - ReadFullDocsArticle — fetch a full docs article by its docs URL; returns prose, fields, and code examples.
18744
- - SearchWixAPISpec — JS-sandboxed query over the REST API spec; returns request schema, response schema, and the executable \`method.publicUrl\`.
18745
- - ExecuteWixAPI — runs an async JS function in a sandbox with \`wix.request()\`; a single invocation can chain multiple API calls, paginate, loop, transform, and branch.
18916
+ A code example is the model for your call only when it matches your case, with every field your case needs. Fill the rest from the method's schema: SearchWixAPISpec on its docs URL (REST or SDK) returns the request and response schemas, \`method.publicUrl\` and \`method.sdk\`; ReadFullDocsMethodSchema when SearchWixAPISpec isn't available. A query's filter and sort fields and operators are a closed list per method: use only what its schema declares.
18746
18917
 
18747
- Steps:
18918
+ None of this comes from memory.
18748
18919
 
18749
- 1. A single user task may need one or more API methods. For each method you'll call, find a code example that fits the user's intent — you'll model the API call (URL, method, body) on it. An example only "fits" if it is **complete** (not truncated) AND matches your exact case — same operation and same variant/shape (e.g. the same \`productType\`), with every field your case needs actually shown. **If the closest example is truncated (it shows a \`... N more lines ...\` marker), do NOT call the API off it; continue discovery first: \`ReadFullDocsArticle\` for the complete example, or \`SearchWixAPISpec\` for the exact request schema.** Never fill in required fields from memory. Skip this step for any method you already have from a previous tool result in this conversation (not from memory):
18750
- a. First try the WixREADME Recipes index below (pre-curated guides for common tasks). If a recipe matches, ReadFullDocsArticle on its docs URL to find relevant code examples; many recipes cover multi-step flows and supply code examples for several methods in one article.
18751
- b. If no recipe matches the user's intent, or the matched recipe didn't yield the code examples you need, discover each missing method's docs URL via SearchWixRESTDocumentation (semantic search) or BrowseWixRESTDocsMenu (menu hierarchy), then ReadFullDocsArticle on each to find relevant code examples.
18752
- c. If neither path turns up a usable code example for some method, continue without one for that method — step 2 will derive its request directly from the schema. Make sure you've still captured the docs URL of each method.
18920
+ ### The call, or the code that makes it
18753
18921
 
18754
- 2. Before calling, fill any remaining gaps with SearchWixAPISpec on each method's docs URL. It returns both request and response schemas. For each method, check:
18755
- - **Request** (URL, HTTP method, body fields) — skip the probe if a code example already shows them; otherwise SearchWixAPISpec returns publicUrl + exact request shape.
18756
- - **Response shape** (field paths your code will read) — only relevant if your code reads response fields; skip the probe if the article(s) already made it clear; otherwise probe SearchWixAPISpec for the response schema.
18757
- - **Filter and sort** (query/search methods only) — an example proves only the fields and operators it uses. Each method declares which fields it can filter and sort by, and with which operators; that list is closed for fields and their operators and covers that method only — \`$and\`/\`$or\`/\`$not\` are filter syntax and never appear in it. Anything else errors or silently returns the wrong rows. A listed operator is valid on its own, since a field takes a single operator; to combine conditions, use the logical operators instead — \`$and\` and \`$or\` take an array of expressions, \`$not\` takes one, and they can nest.
18758
- - Never guess any of this from memory.
18922
+ **Call it with ExecuteWixAPI**: one async JS function with \`wix.request()\`, holding every step of the task that code can resolve. The reads that fetch an ID, check whether a record exists or list items to choose from go in the same function as the writes they feed; step numbers in a guide or skill give logical order, not separate calls. Set \`hasMutations: true\` when any step writes. Return the write's response as is and report from it; don't read again to confirm. A new invocation only for what code can't resolve: the user's answer, or a job that finishes later. One function chains calls, paginates, lists all, loops, transforms and branches. Without ExecuteWixAPI, make each call with CallWixSiteAPI (a site's APIs) or ManageWixSite (the account's), from the same exact shape.
18759
18923
 
18760
- 3. Before calling: collapse ALL planned steps — preliminary reads AND mutations — into a single async function. Step numbers in any guide or skill doc describe logical order for human comprehension — they do NOT define invocation boundaries. Steps that feed into each other belong in a single invocation: read, use the result, write, and return. A read that fetches IDs or checks existence before a create/update is part of that mutation's invocation, not a separate preceding call. This includes any read whose result feeds directly into a subsequent write — fetching a required ID, checking whether a record already exists, listing items to choose one — all belong in the same invocation as the write that follows. Set hasMutations: true whenever any step in the function writes. Return the mutation response directly — do not follow up with a read to confirm what was just created or updated; trust the response. Only split into multiple invocations when a later step genuinely depends on information you cannot resolve in code (e.g. a user decision or an out-of-band event). A single invocation can chain several related calls, paginate, "list all", loop, transform, and branch on responses.
18924
+ **Write the code** when the task is code the user keeps: an app (built and run with the Wix CLI), a headless site, or a script that calls the REST API or the JavaScript SDK. The path is the same: find the method, learn its exact shape, then write the call from \`method.publicUrl\` (REST) or \`method.sdk\` (the JavaScript SDK), never from memory. Every way of building against Wix in code is this path; the headless skills are a shortcut on it, not a different one. wix-headless-kit builds a Wix Headless site from shipped, verified code (wix-headless-templates holds it, one folder per business solution: a \`@wix/sdk\` React core, and the same data layer as plain REST calls for a stack that cannot run it): scaffold with the CLI, deploy, seed, design the presentation on the shipped code, release. What no shipped solution covers is written from the docs, as above. A new site is written in code and uploaded: StartDeployWebsite returns the upload guide (create the site, upload its files, change them later); StartHeadlessBuild returns the headless guide, for a site that needs Wix business features: you write the site, and the guide creates it, connects the features and uploads it, through the cold start that hands off to the kit (or the same run as API calls when there is no shell).
18761
18925
 
18762
- </management-flow>
18926
+ ### When a call fails
18763
18927
 
18764
- <other-uses>
18765
- Beyond managing user sites, the Wix MCP tools can be used for any other purpose they support — for example, reading Wix SDK docs to write code against the SDK, using the Wix CLI to create apps, answering documentation questions, and so on.
18766
- </other-uses>
18767
- </agent-mandatory-instructions>
18928
+ The error carries the failed call's status and message and a Wix request id. Read it: it says what was wrong, and that is what to fix before calling again, whether the request (from the schema), the site and what is installed on it, or what the account is allowed to do. Never resend the same request unchanged, and never guess a fix. When you report the failure to the user, include the request id.
18768
18929
  `;
18769
- var defaultReadmeDocs = [
18770
- {
18771
- action: "text",
18772
- content: [
18773
- README_INTRO,
18774
- AGENT_GOAL,
18775
- README_FLOWS_HEADING,
18776
- "",
18777
- README_BODY
18778
- ].join("\n")
18779
- },
18780
- recipesIndexDoc
18781
- ];
18930
+ function buildReadmeDocs({
18931
+ recipesIndex = true
18932
+ } = {}) {
18933
+ return [
18934
+ {
18935
+ action: "text",
18936
+ content: [
18937
+ README_INTRO,
18938
+ "",
18939
+ AGENT_GOAL,
18940
+ "",
18941
+ README_FLOWS_HEADING,
18942
+ "",
18943
+ README_FLOWS_SITE,
18944
+ "",
18945
+ README_FIND_SOURCES,
18946
+ "",
18947
+ README_FLOWS_BODY
18948
+ ].join("\n")
18949
+ },
18950
+ { action: "text", content: WIX_SKILLS_README_SECTION },
18951
+ ...recipesIndex ? [recipesIndexDoc] : []
18952
+ ];
18953
+ }
18954
+ var defaultReadmeDocs = buildReadmeDocs();
18782
18955
  function mergeConfig(base, overrides) {
18783
18956
  return {
18784
18957
  toolDescriptions: {
@@ -18820,8 +18993,7 @@ var widgetSiteCreationConfig = {
18820
18993
  "WixSiteBuilder",
18821
18994
  "WixSiteCreation",
18822
18995
  "SearchSiteTemplates",
18823
- "CreateSiteFromTemplate",
18824
- "CreateWixBusinessGuide"
18996
+ "CreateSiteFromTemplate"
18825
18997
  ].map((tool) => [tool, toWidget(defaultToolDescriptions[tool])])
18826
18998
  )
18827
18999
  };
@@ -18965,6 +19137,9 @@ function renderApps(apps, knownApps) {
18965
19137
  if (app.catalogVersion) {
18966
19138
  line += ` \u2014 Catalog app version: **${app.catalogVersion}**`;
18967
19139
  }
19140
+ if (app.invoicesVersion) {
19141
+ line += ` \u2014 Invoices app version: **${app.invoicesVersion}**`;
19142
+ }
18968
19143
  lines.push(line);
18969
19144
  }
18970
19145
  return lines.join("\n");
@@ -18985,6 +19160,11 @@ function renderCustomAppsWithSkillsTools(apps) {
18985
19160
  }
18986
19161
  return lines.join("\n");
18987
19162
  }
19163
+ function renderCompanionApp(installedApps) {
19164
+ const appId = installedApps.find((app) => app.companionApp === true)?.appId;
19165
+ if (!appId || !GUID_PATTERN.test(appId)) return "";
19166
+ return `The site's code lives in its companion app (ID: \`${appId}\`).`;
19167
+ }
18988
19168
  function renderProperties(props) {
18989
19169
  const sections = [];
18990
19170
  const regionalFormat = [];
@@ -19011,7 +19191,7 @@ ${contact.join("\n")}`);
19011
19191
  }
19012
19192
  return sections.join("\n\n");
19013
19193
  }
19014
- function renderSite(site, index, knownApps) {
19194
+ function renderSite(site, index, knownApps, includeCompanionApp) {
19015
19195
  const lines = [];
19016
19196
  const heading = site.displayName ?? `Site ${index}`;
19017
19197
  lines.push(`## ${index}. ${heading}`);
@@ -19056,6 +19236,13 @@ function renderSite(site, index, knownApps) {
19056
19236
  lines.push("");
19057
19237
  lines.push(customAppsWithSkillsToolsContent);
19058
19238
  }
19239
+ const companionAppContent = includeCompanionApp ? renderCompanionApp(site.installedApps ?? []) : "";
19240
+ if (companionAppContent) {
19241
+ lines.push("");
19242
+ lines.push("### Site code (companion app)");
19243
+ lines.push("");
19244
+ lines.push(companionAppContent);
19245
+ }
19059
19246
  lines.push("");
19060
19247
  lines.push("---");
19061
19248
  lines.push("");
@@ -19075,6 +19262,7 @@ function enrichDynamicContext(data, knownApps = {}, options = {}) {
19075
19262
  const response = snakeToCamel(parsed);
19076
19263
  const includePartnerContext = options.includePartnerContext ?? false;
19077
19264
  const includeAccountContext = options.includeAccountContext ?? false;
19265
+ const includeCompanionApp = options.includeCompanionApp ?? false;
19078
19266
  const sections = [];
19079
19267
  const allSites = response.sites ?? [];
19080
19268
  const maxSites = options.maxSites ?? Infinity;
@@ -19127,9 +19315,18 @@ function enrichDynamicContext(data, knownApps = {}, options = {}) {
19127
19315
  );
19128
19316
  sections.push("");
19129
19317
  }
19318
+ const hasInvoicesVersion = sitesToRender.some(
19319
+ (site) => site.installedApps?.some((app) => app.appId && knownApps[app.appId] && app.invoicesVersion)
19320
+ );
19321
+ if (hasInvoicesVersion) {
19322
+ sections.push(
19323
+ "> **Wix Invoices \u2014 Version**: Some sites below have Wix Invoices installed and show their Invoices version (V1/V2). When working on an Invoices task, check the version for that site \u2014 only read recipes and call endpoints that match its version. Never use an Invoices V2 skill or API on a V1 site, and vice versa."
19324
+ );
19325
+ sections.push("");
19326
+ }
19130
19327
  if (sitesToRender.length) {
19131
19328
  for (let i = 0; i < sitesToRender.length; i++) {
19132
- sections.push(renderSite(sitesToRender[i], i + 1, knownApps));
19329
+ sections.push(renderSite(sitesToRender[i], i + 1, knownApps, includeCompanionApp));
19133
19330
  }
19134
19331
  }
19135
19332
  if (!response.account && !siteCount && (!includePartnerContext || !hasPartnerContext(response.partnerContext))) {
@@ -19137,9 +19334,11 @@ function enrichDynamicContext(data, knownApps = {}, options = {}) {
19137
19334
  }
19138
19335
  return sections.join("\n");
19139
19336
  }
19337
+ var GUID_PATTERN;
19140
19338
  var init_enrich = __esm2({
19141
19339
  "src/enrich.ts"() {
19142
19340
  "use strict";
19341
+ GUID_PATTERN = /^[0-9a-f]{8}-[0-9a-f]{4}-[0-9a-f]{4}-[0-9a-f]{4}-[0-9a-f]{12}$/i;
19143
19342
  }
19144
19343
  });
19145
19344
  init_enrich();
@@ -19202,6 +19401,7 @@ async function getDynamicContext(auth, httpClient, filter, options) {
19202
19401
  } : options;
19203
19402
  const includePartnerContext = contextOptions?.partnerContextEnabled ?? true;
19204
19403
  const includeAccountContext = contextOptions?.includeAccountContext ?? true;
19404
+ const includeCompanionApp = contextOptions?.includeCompanionApp ?? false;
19205
19405
  try {
19206
19406
  const accountHeaders = await auth.getAccountAuthHeaders();
19207
19407
  const noFilter = !filter?.siteId && !filter?.siteName;
@@ -19255,6 +19455,7 @@ async function getDynamicContext(auth, httpClient, filter, options) {
19255
19455
  const context = enrichDynamicContext2(response.data, known_apps_default, {
19256
19456
  includePartnerContext,
19257
19457
  includeAccountContext,
19458
+ includeCompanionApp,
19258
19459
  // Cap the account-wide view to the first N sites; a targeted fetch returns one site.
19259
19460
  ...noFilter ? { maxSites: MAX_SITES_FOR_DYNAMIC_CONTEXT, totalSiteCount } : {}
19260
19461
  });
@@ -19308,6 +19509,21 @@ function isApiUrlAllowed(url) {
19308
19509
  }
19309
19510
 
19310
19511
  // src/config/param-descriptions.ts
19512
+ var REPORT_ISSUE_TO_WIX_PARAMS = {
19513
+ message: [
19514
+ "The report of one issue, sent to Wix as free text. Only this issue \u2014 no session summary, play-by-play or unrelated problems:",
19515
+ "- What was being attempted, in a sentence.",
19516
+ "- The tool or endpoint, the HTTP status and the error message.",
19517
+ "- What you expected instead, and the workaround if any.",
19518
+ "- Where the fault likely lives (API behavior / API schema / docs / Wix tooling / unsure), and whether you confirmed it.",
19519
+ "- The context needed to reproduce it: agent/model, site id, the Wix area or API.",
19520
+ "- The user's own words, verbatim, if they added any.",
19521
+ "NEVER include secrets \u2014 no bearer tokens, API keys, or credentials \u2014 and no personal data beyond what the report needs."
19522
+ ].join("\n"),
19523
+ requestId: "Optional request id (x-wix-request-id) of the failed Wix API call this report is about."
19524
+ };
19525
+ var WHY_NOT_EXECUTE_RECONNECT = "if the Wix MCP doesn't offer it at all, say so here, and tell the user once that their Wix connection may be an old or cached version that a reconnect refreshes.";
19526
+ var WHY_NOT_EXECUTE_NO_EXECUTE = "if it isn't in your tool list, say so.";
19311
19527
  var paramDescriptions = {
19312
19528
  CallWixSiteAPI: {
19313
19529
  siteId: "The id of the site selected using site selection tool",
@@ -19324,6 +19540,7 @@ var paramDescriptions = {
19324
19540
  WQL_FILTER_RULE
19325
19541
  ].join("\n"),
19326
19542
  reason: "One sentence explaining the original user request and why you are calling this API to complete it.",
19543
+ whyNotExecuteWixAPI: `One sentence: why this call goes through CallWixSiteAPI and not ExecuteWixAPI, the preferred tool. If ExecuteWixAPI isn't loaded, load it through your client's tool search before calling this tool; ${WHY_NOT_EXECUTE_RECONNECT}`,
19327
19544
  sourceDocUrl: [
19328
19545
  "The URL of the documentation or recipe where you found this API endpoint.",
19329
19546
  "MAKE SURE THE ENDPOINT URL IS REALLY THERE AND YOUR ARE NOT GUESSING IT !!!",
@@ -19359,18 +19576,9 @@ var paramDescriptions = {
19359
19576
  'Use ["other"] ONLY IF YOU HAVE A VERY GOOD REASON TO DO SO'
19360
19577
  ].join("\n")
19361
19578
  },
19362
- SupportAndFeedback: {
19363
- message: [
19364
- "The composed feedback message to send to Wix. Wix receives only free text, so a bare sentence is low-signal \u2014 send a summary of the whole session, not just the last error. Structure it in three layers:",
19365
- "1. Provenance \u2014 labelled lines (omit ones that do not apply): agent/model, Wix tooling used, Wix areas/APIs touched, Wix products (stores, bookings, ...), site id, relevant links (dashboard, docs pages read, live site) and other ids created this run.",
19366
- `2. Narrative \u2014 "In the user's words": anything the user added when you offered, quoted verbatim (redact secrets only). Then user intent + run summary (what they set out to build, what worked vs. what fought back), a condensed play-by-play of the session (key exchanges, tool calls, decisions), and the friction points \u2014 every place something got in the way, each with specifics: the step/endpoint, HTTP status and error message, the gap, the workaround, and what you expected instead. Include issues you recovered from.`,
19367
- '3. Attribution \u2014 for each significant friction point, your best diagnosis of where the fault lives: API behavior / API schema / API reference docs / docs articles or examples / Wix tooling (MCP tools, auth flow) / other-unsure \u2014 plus whether you confirmed it or are assuming. Do not force a tag; "unsure" beats a wrong route.',
19368
- "End with a bottom line: one or two sentences naming the single most important problem and its impact \u2014 a concise engineering assessment, not softened or hedged.",
19369
- "Write it as a scannable few paragraphs or a short bulleted list \u2014 thorough on the friction, distilled rather than a transcript dump.",
19370
- "NEVER include secrets \u2014 no bearer tokens, API keys, or credentials \u2014 and no personal data beyond what the feedback needs."
19371
- ].join("\n"),
19372
- requestId: "Optional request id (x-wix-request-id) returned from a failed Wix API call this feedback relates to."
19373
- },
19579
+ ReportIssueToWix: REPORT_ISSUE_TO_WIX_PARAMS,
19580
+ // The tool's former name, kept for importers that read it by that key.
19581
+ SupportAndFeedback: REPORT_ISSUE_TO_WIX_PARAMS,
19374
19582
  SearchWixWDSDocumentation: {
19375
19583
  searchTerm: "The search term to search for in the Wix Design System Documentation",
19376
19584
  maxResults: "The maximum number of results to return, default is 10, max is 15"
@@ -19409,8 +19617,13 @@ var paramDescriptions = {
19409
19617
  maxResults: "The maximum number of results to return, default is 10, max is 15",
19410
19618
  reason: "One sentence describing the original user request and the task you are trying to accomplish with this search."
19411
19619
  },
19620
+ SearchWixHelpCenter: {
19621
+ searchTerm: 'What the site owner wants to do or fix, in plain words (e.g. "connect a domain bought elsewhere", "cancel a Premium plan")',
19622
+ maxResults: "The maximum number of articles to return (1\u201315, default 15). Each article is returned with up to 60 lines.",
19623
+ reason: "One sentence describing the original user request and the task you are trying to accomplish with this search."
19624
+ },
19412
19625
  ReadFullDocsArticle: {
19413
- articleUrl: "The URL of the docs article or method article to fetch. Should be something like https://dev.wix.com/docs/.../... For REST docs, use the URL as-is. For SDK docs, the URL SHOULD include the query param ?apiView=SDK (e.g. https://dev.wix.com/docs/...?apiView=SDK). Wix skills pages (https://www.wix.com/skills/..., https://dev.wix.com/docs/skills/...) are read as-is, including their referenced files."
19626
+ articleUrl: "The URL of the docs article or method article to fetch. Should be something like https://dev.wix.com/docs/.../... For REST docs, use the URL as-is. For SDK docs, the URL SHOULD include the query param ?apiView=SDK (e.g. https://dev.wix.com/docs/...?apiView=SDK). Wix Help Center articles (https://support.wix.com/en/article/...) are read as-is. Wix skills pages (https://www.wix.com/skills/..., https://dev.wix.com/docs/skills/...) and Wix Headless agent pages (https://www.wix.com/headless/..., e.g. https://www.wix.com/headless/skill.md) are read as-is, including their referenced files. Source links (https://dev.wix.com/rawdocs/api/get-source-content?repo=...&path=...) found in skills and recipes are read as-is."
19414
19627
  },
19415
19628
  ReadFullDocsMethodSchema: {
19416
19629
  articleUrl: "The URL of the documentation to fetch. Should be something like https://dev.wix.com/docs/.../... For REST docs, use the URL as-is. For SDK docs, the URL SHOULD include the query param ?apiView=SDK (e.g. https://dev.wix.com/docs/...?apiView=SDK).",
@@ -19426,7 +19639,7 @@ var paramDescriptions = {
19426
19639
  },
19427
19640
  UploadImageToWixSite: {
19428
19641
  siteId: "The ID (UUID) of the Wix site to upload to. REQUIRED. If the user has not clearly specified which site, ASK them which site to upload to (or use ListWixSites to help them pick) BEFORE calling this tool. NEVER call this tool with a missing, empty, placeholder, or guessed siteId \u2014 ask first instead.",
19429
- image: "Array of file ATTACHMENTS: files the user uploaded in the chat, or files you created in your own file sandbox. Each item requires download_url and file_id, and may optionally include file_name and mime_type \u2014 the platform resolves a file passed here into these fields automatically, so just include the files. For plain image URLs the user pasted, use imageUrls instead. ALWAYS pass ALL attachments together in a single call \u2014 NEVER call this tool once per image. Do NOT use together with imageBase64.",
19642
+ image: `${fileParamNote("send the image as imageBase64 (the whole file, one per call) or as a public URL in imageUrls")} For plain image URLs the user pasted, use imageUrls instead. ALWAYS pass ALL files together in a single call \u2014 NEVER call this tool once per image. Do NOT use together with imageBase64.`,
19430
19643
  imageUrls: "Array of publicly accessible image URLs (e.g. links the user pasted or URLs produced by other tools). Use this for plain URLs that are NOT chat attachments \u2014 no file_id is needed. ALWAYS pass ALL URLs together in a single call. Can be combined with image; do NOT use together with imageBase64.",
19431
19644
  imageBase64: 'Base64-encoded image data. Use when the client can read a file and encode it as base64. May include a data URL prefix (e.g. "data:image/jpeg;base64,...") or be raw base64. Do NOT use together with image.',
19432
19645
  mimeType: 'MIME type of the image (e.g. "image/jpeg", "image/png", "image/webp"). Required when imageBase64 does not include a data URL prefix.',
@@ -19450,7 +19663,7 @@ var paramDescriptions = {
19450
19663
  operationName: "Operation to run when the document defines more than one named operation.",
19451
19664
  siteId: "The Wix site to run against. Required for site-level operations (anything reading or writing inside a site \u2014 products, orders, contacts, bookings, CMS, blog, members ...). Resolve it with GetSiteContext or ListWixSites; never pass a guessed value.",
19452
19665
  scope: '"site" (default when siteId is given) runs with a site-scoped credential; "account" runs account-level operations (sites, account settings) and ignores siteId.',
19453
- hasMutations: "Whether this document creates, updates, deletes or otherwise mutates Wix data. True for any mutation root field (in any operation of the document) even when the intent is inspection; false only for pure queries. This flag alone decides whether a transient server error may be retried, so never mark a document that writes as false.",
19666
+ hasMutations: "True if the document contains a mutation root field in any of its operations; false if it contains only queries. A transient server error is retried only when this is false.",
19454
19667
  reason: "One sentence explaining the original user request and why you are running this GraphQL operation to complete it."
19455
19668
  },
19456
19669
  RunWixCliCommand: {
@@ -19463,10 +19676,315 @@ var paramDescriptions = {
19463
19676
  };
19464
19677
  var desc = (toolName) => paramDescriptions[toolName];
19465
19678
 
19679
+ // src/docs/mintlify-docs.ts
19680
+ var MINTLIFY_LINKS_DOCS_SITE = "mintlify-links";
19681
+ var MINTLIFY_DOCS_SITE = "mintlify";
19682
+ var MINTLIFY_HOST = "https://wix-internal.mintlify.site";
19683
+ var MINTLIFY_HOSTNAMES = /* @__PURE__ */ new Set([
19684
+ "wix-internal.mintlify.site",
19685
+ "wix-internal.mintlify.app"
19686
+ ]);
19687
+ var DEV_WIX_DOCS = "https://dev.wix.com/docs";
19688
+ var PORTAL_SLUG_TO_TAB = {
19689
+ rest: "api-reference",
19690
+ "mintlify-sandbox": "sandbox"
19691
+ };
19692
+ var TAB_TO_PORTAL_SLUG = {
19693
+ sandbox: "mintlify-sandbox"
19694
+ };
19695
+ var MINTLIFY_TABS = /* @__PURE__ */ new Set(["api-reference", "sandbox", "kb"]);
19696
+ var NON_DOCS_SLUGS = /* @__PURE__ */ new Set(["skills", "kb-only", "api"]);
19697
+ var CHECK_TTL_MS = 10 * 60 * 1e3;
19698
+ var MAX_CHECK_ENTRIES = 5e3;
19699
+ var CHECK_TIMEOUT_MS = 5e3;
19700
+ var MAX_REDIRECTS = 3;
19701
+ var CHECK_CONCURRENCY = 8;
19702
+ function isMintlifyDocsSite(docsSite) {
19703
+ return docsSite === MINTLIFY_LINKS_DOCS_SITE || docsSite === MINTLIFY_DOCS_SITE;
19704
+ }
19705
+ var MINTLIFY_DOCUMENT_TYPES = {
19706
+ REST: ["MINTLIFY_REST"],
19707
+ // includes the skills, as REST + SKILLS does today
19708
+ SDK: ["MINTLIFY_SDK"]
19709
+ };
19710
+ function mintlifyDocumentTypes(docsSite, toolName) {
19711
+ return docsSite === MINTLIFY_DOCS_SITE ? MINTLIFY_DOCUMENT_TYPES[toolName] : void 0;
19712
+ }
19713
+ function isMintlifyUrl(url) {
19714
+ try {
19715
+ return MINTLIFY_HOSTNAMES.has(new URL(url).hostname);
19716
+ } catch {
19717
+ return false;
19718
+ }
19719
+ }
19720
+ var MINTLIFY_URL_PREFIXES = [...MINTLIFY_HOSTNAMES].map(
19721
+ (host) => `https://${host}/`
19722
+ );
19723
+ function cleanPath(pathname) {
19724
+ const path = pathname.replace(/\.md$/, "").replace(/\/+$/, "");
19725
+ return path === "" ? "/" : path;
19726
+ }
19727
+ function flavourOf(url) {
19728
+ return url.searchParams.get("apiView")?.toUpperCase() === "SDK" ? "sdk" : "rest";
19729
+ }
19730
+ function toMintlifyCandidate(rawUrl) {
19731
+ let url;
19732
+ try {
19733
+ url = new URL(rawUrl);
19734
+ } catch {
19735
+ return null;
19736
+ }
19737
+ if (MINTLIFY_HOSTNAMES.has(url.hostname)) {
19738
+ const path2 = cleanPath(url.pathname);
19739
+ return { url: `${MINTLIFY_HOST}${path2}`, path: path2, flavour: flavourOf(url) };
19740
+ }
19741
+ if (url.hostname !== "dev.wix.com" || !url.pathname.startsWith("/docs/")) {
19742
+ return null;
19743
+ }
19744
+ const segments = cleanPath(url.pathname.slice("/docs".length)).split("/").filter(Boolean);
19745
+ if (segments.length === 0 || NON_DOCS_SLUGS.has(segments[0])) {
19746
+ return null;
19747
+ }
19748
+ segments[0] = PORTAL_SLUG_TO_TAB[segments[0]] ?? segments[0];
19749
+ const path = `/${segments.join("/")}`;
19750
+ return { url: `${MINTLIFY_HOST}${path}`, path, flavour: flavourOf(url) };
19751
+ }
19752
+ function toDevWixUrl(rawUrl) {
19753
+ const url = new URL(rawUrl);
19754
+ const segments = cleanPath(url.pathname).split("/").filter(Boolean);
19755
+ if (segments.length > 0) {
19756
+ segments[0] = TAB_TO_PORTAL_SLUG[segments[0]] ?? segments[0];
19757
+ }
19758
+ const query = flavourOf(url) === "sdk" ? "?apiView=SDK" : "";
19759
+ return `${DEV_WIX_DOCS}/${segments.join("/")}${query}`;
19760
+ }
19761
+ var checkCache = /* @__PURE__ */ new Map();
19762
+ function rememberCheck(path, result) {
19763
+ const now = Date.now();
19764
+ checkCache.delete(path);
19765
+ if (checkCache.size >= MAX_CHECK_ENTRIES) {
19766
+ for (const [key, entry] of checkCache) {
19767
+ if (entry.expires <= now) checkCache.delete(key);
19768
+ }
19769
+ }
19770
+ while (checkCache.size >= MAX_CHECK_ENTRIES) {
19771
+ const oldest = checkCache.keys().next().value;
19772
+ if (oldest === void 0) break;
19773
+ checkCache.delete(oldest);
19774
+ }
19775
+ checkCache.set(path, { result, expires: now + CHECK_TTL_MS });
19776
+ }
19777
+ async function headOnce(url) {
19778
+ return fetch(url, {
19779
+ method: "HEAD",
19780
+ redirect: "manual",
19781
+ signal: AbortSignal.timeout(CHECK_TIMEOUT_MS)
19782
+ });
19783
+ }
19784
+ async function checkMintlifyPage(path) {
19785
+ const cached = checkCache.get(path);
19786
+ if (cached && cached.expires > Date.now()) {
19787
+ return cached.result;
19788
+ }
19789
+ if (cached) checkCache.delete(path);
19790
+ let result;
19791
+ try {
19792
+ let current = path;
19793
+ let hops = 0;
19794
+ for (; ; ) {
19795
+ const response = await headOnce(`${MINTLIFY_HOST}${current}`);
19796
+ if (response.status === 200) {
19797
+ result = {
19798
+ outcome: hops === 0 ? "identity" : "redirect",
19799
+ path: current
19800
+ };
19801
+ break;
19802
+ }
19803
+ const location = response.headers.get("location");
19804
+ if (response.status >= 300 && response.status < 400 && location && hops < MAX_REDIRECTS) {
19805
+ current = cleanPath(new URL(location, MINTLIFY_HOST).pathname);
19806
+ hops++;
19807
+ continue;
19808
+ }
19809
+ result = { outcome: response.status === 404 ? "missing" : "error" };
19810
+ break;
19811
+ }
19812
+ } catch (error) {
19813
+ logger.error(`[mintlify] page check failed for ${path}: ${error}`);
19814
+ result = { outcome: "error" };
19815
+ }
19816
+ rememberCheck(path, result);
19817
+ return result;
19818
+ }
19819
+ async function resolveDocsLink(rawUrl, { verify = true } = {}) {
19820
+ const candidate = toMintlifyCandidate(rawUrl);
19821
+ if (!candidate) {
19822
+ return { outcome: "not-docs", url: rawUrl };
19823
+ }
19824
+ const tab = candidate.path.split("/")[1];
19825
+ if (!MINTLIFY_TABS.has(tab)) {
19826
+ return { outcome: "other-portal", url: rawUrl };
19827
+ }
19828
+ const query = candidate.flavour === "sdk" ? "?apiView=SDK" : "";
19829
+ if (!verify) {
19830
+ return { outcome: "identity", url: `${candidate.url}${query}` };
19831
+ }
19832
+ const check = await checkMintlifyPage(candidate.path);
19833
+ if (check.path) {
19834
+ return {
19835
+ outcome: check.outcome,
19836
+ url: `${MINTLIFY_HOST}${check.path}${query}`
19837
+ };
19838
+ }
19839
+ return { outcome: check.outcome, url: rawUrl };
19840
+ }
19841
+ var DOCS_LINK_PATTERN = /https:\/\/(?:dev\.wix\.com\/docs|wix-internal\.mintlify\.(?:site|app))\/[^\s)\]"'<>`]*/g;
19842
+ function trimTrailingPunctuation(url) {
19843
+ return url.replace(/[.,;:!?*]+$/, "");
19844
+ }
19845
+ var MINTLIFY_LINK_PATTERN = /https:\/\/wix-internal\.mintlify\.(?:site|app)\/[^\s)\]"'<>`]*/g;
19846
+ function toDevWixHostText(text) {
19847
+ return text.replace(MINTLIFY_LINK_PATTERN, (match) => {
19848
+ const link = trimTrailingPunctuation(match);
19849
+ let url;
19850
+ try {
19851
+ url = new URL(link);
19852
+ } catch {
19853
+ return match;
19854
+ }
19855
+ if (!MINTLIFY_TABS.has(url.pathname.split("/")[1] ?? "")) return match;
19856
+ return toDevWixUrl(link) + url.hash + match.slice(link.length);
19857
+ });
19858
+ }
19859
+ async function mapWithConcurrency(items, limit, fn) {
19860
+ const results = new Array(items.length);
19861
+ let next = 0;
19862
+ const workers = Array.from(
19863
+ { length: Math.min(limit, items.length) },
19864
+ async () => {
19865
+ while (next < items.length) {
19866
+ const index = next++;
19867
+ results[index] = await fn(items[index]);
19868
+ }
19869
+ }
19870
+ );
19871
+ await Promise.all(workers);
19872
+ return results;
19873
+ }
19874
+ async function rewriteDocsLinks(text, { verify = true, label = "text" } = {}) {
19875
+ const found = [
19876
+ ...new Set(
19877
+ (text.match(DOCS_LINK_PATTERN) ?? []).map(trimTrailingPunctuation)
19878
+ )
19879
+ ];
19880
+ const stats = {
19881
+ links: found.length,
19882
+ byOutcome: {},
19883
+ misses: []
19884
+ };
19885
+ if (found.length === 0) {
19886
+ return { text, stats };
19887
+ }
19888
+ const resolved = await mapWithConcurrency(
19889
+ found,
19890
+ CHECK_CONCURRENCY,
19891
+ (url) => resolveDocsLink(url, { verify })
19892
+ );
19893
+ const replacements = /* @__PURE__ */ new Map();
19894
+ found.forEach((url, i) => {
19895
+ const { outcome, url: target } = resolved[i];
19896
+ stats.byOutcome[outcome] = (stats.byOutcome[outcome] ?? 0) + 1;
19897
+ if (outcome === "identity" || outcome === "redirect") {
19898
+ if (target !== url) replacements.set(url, target);
19899
+ } else if (outcome !== "not-docs") {
19900
+ stats.misses.push(`${outcome} ${url}`);
19901
+ }
19902
+ });
19903
+ const rewritten = text.replace(DOCS_LINK_PATTERN, (match) => {
19904
+ const url = trimTrailingPunctuation(match);
19905
+ const target = replacements.get(url);
19906
+ return target ? target + match.slice(url.length) : match;
19907
+ });
19908
+ logger.log(
19909
+ `[mintlify] ${label}: ${stats.links} links ${JSON.stringify(stats.byOutcome)}` + (stats.misses.length ? ` misses: ${stats.misses.slice(0, 10).join(" | ")}` : "")
19910
+ );
19911
+ return { text: rewritten, stats };
19912
+ }
19913
+ var INDEX_BANNER = /^> ## Documentation Index\n(?:>.*\n)*\n?/;
19914
+ var INLINED_SNIPPET = /^export const \w+ = [\s\S]*?^};\n/gm;
19915
+ var REST_TAB = /<Tab title="REST">([\s\S]*?)<\/Tab>/;
19916
+ var SDK_TAB = /<Tab title="SDK">([\s\S]*?)<\/Tab>/;
19917
+ function cleanMintlifyMarkdown(markdown, flavour) {
19918
+ const text = markdown.replace(INLINED_SNIPPET, "");
19919
+ const rest = text.match(REST_TAB);
19920
+ const sdk = text.match(SDK_TAB);
19921
+ if (!rest || !sdk || (text.match(/<Tab title=/g) ?? []).length !== 2) {
19922
+ return text;
19923
+ }
19924
+ const start = text.lastIndexOf("<Tabs>", rest.index);
19925
+ const end = text.indexOf("</Tabs>", sdk.index);
19926
+ if (start === -1 || end === -1) {
19927
+ return text;
19928
+ }
19929
+ const kept = (flavour === "sdk" ? sdk : rest)[1];
19930
+ const note = flavour === "sdk" ? "_This is the SDK view. Drop `?apiView=SDK` from the URL for the REST view._" : "_This is the REST view. Add `?apiView=SDK` to the URL for the JavaScript SDK view._";
19931
+ return `${text.slice(0, start)}${note}
19932
+
19933
+ ${kept.trim()}
19934
+ ${text.slice(end + "</Tabs>".length)}`;
19935
+ }
19936
+ var DOCS_URL_IN_TEXT = /https:\/\/dev\.wix\.com\/docs\/(?=api-reference\b|\.\.\.)/g;
19937
+ function toMintlifyHostText(text) {
19938
+ return text.replace(DOCS_URL_IN_TEXT, `${MINTLIFY_HOST}/`);
19939
+ }
19940
+ var SITE_RELATIVE_LINK = /(\]\(|href=["'])\/(?!\/)/g;
19941
+ function absolutizeSiteLinks(markdown) {
19942
+ return markdown.replace(
19943
+ SITE_RELATIVE_LINK,
19944
+ (_, open) => `${open}${MINTLIFY_HOST}/`
19945
+ );
19946
+ }
19947
+ async function readMintlifyMarkdown(rawUrl) {
19948
+ const resolved = await resolveDocsLink(rawUrl);
19949
+ if (resolved.outcome !== "identity" && resolved.outcome !== "redirect") {
19950
+ return null;
19951
+ }
19952
+ const pageUrl = new URL(resolved.url);
19953
+ const response = await fetch(`${MINTLIFY_HOST}${pageUrl.pathname}.md`, {
19954
+ headers: { accept: "text/markdown" },
19955
+ redirect: "follow",
19956
+ signal: AbortSignal.timeout(15e3)
19957
+ });
19958
+ if (response.status === 404) {
19959
+ return null;
19960
+ }
19961
+ if (!response.ok) {
19962
+ throw new Error(
19963
+ `Mintlify returned ${response.status} for ${pageUrl.pathname}.md`
19964
+ );
19965
+ }
19966
+ const flavour = toMintlifyCandidate(rawUrl)?.flavour ?? "rest";
19967
+ const cleaned = cleanMintlifyMarkdown(
19968
+ (await response.text()).replace(INDEX_BANNER, ""),
19969
+ flavour
19970
+ );
19971
+ const { text: rewritten } = await rewriteDocsLinks(cleaned, {
19972
+ label: `read ${pageUrl.pathname}`
19973
+ });
19974
+ const markdown = absolutizeSiteLinks(rewritten);
19975
+ logger.log(
19976
+ `[mintlify] read ${pageUrl.pathname}.md (${markdown.length} chars) for ${rawUrl}`
19977
+ );
19978
+ return { url: `${MINTLIFY_HOST}${pageUrl.pathname}`, markdown };
19979
+ }
19980
+
19466
19981
  // src/docs/get-to-know.ts
19982
+ var AX_SKILLS_REPO = "wix-private/ax-skills";
19983
+ var AX_SKILLS_INDEX_PATH = "skills/wix-manage/SKILL.md";
19467
19984
  function addGetSiteContextTool({
19468
19985
  server,
19469
19986
  authStrategy,
19987
+ includeCompanionApp = false,
19470
19988
  toolDescriptions
19471
19989
  }) {
19472
19990
  const d = desc("GetSiteContext");
@@ -19496,7 +20014,8 @@ function addGetSiteContextTool({
19496
20014
  try {
19497
20015
  context = await getDynamicContext(authStrategy, httpClient, filter, {
19498
20016
  partnerContextEnabled: false,
19499
- includeAccountContext: false
20017
+ includeAccountContext: false,
20018
+ includeCompanionApp
19500
20019
  });
19501
20020
  } catch (err) {
19502
20021
  rethrowIfUnauthorized(err);
@@ -19532,15 +20051,17 @@ async function addGetToKnowTools({
19532
20051
  dynamicContextEnabled,
19533
20052
  repo,
19534
20053
  commitHash,
19535
- skillsTags
20054
+ skillsTags,
20055
+ readmeRecipesIndexEnabled = true,
20056
+ docsSite
19536
20057
  }) {
19537
20058
  if (disableTools.includes("WixREADME")) {
19538
20059
  return;
19539
20060
  }
19540
20061
  const baseDocs = readmeDocs ?? defaultReadmeDocs;
19541
- const baseDocsWithoutRecipes = baseDocs.filter(
19542
- (doc) => doc.url !== RECIPES_INDEX_URL
19543
- );
20062
+ const isRecipesIndex = (doc) => doc.url?.replace(/\.md$/, "") === RECIPES_INDEX_URL;
20063
+ const baseDocsWithoutRecipes = baseDocs.filter((doc) => !isRecipesIndex(doc));
20064
+ const recipesIndexDocs = readmeRecipesIndexEnabled ? baseDocs.filter(isRecipesIndex) : [];
19544
20065
  server.tool(
19545
20066
  "WixREADME",
19546
20067
  toolDescriptions?.["WixREADME"] ?? defaultToolDescriptions.WixREADME,
@@ -19612,6 +20133,18 @@ ${responseText}` : responseText;
19612
20133
  if (!url) {
19613
20134
  throw new Error('URL is required for "include" action');
19614
20135
  }
20136
+ const readsAxSkills = isRecipesIndex({ action, url }) && !skillsPortalUrl && (repo ? repo === AX_SKILLS_REPO : !commitHash);
20137
+ if (readsAxSkills) {
20138
+ return {
20139
+ type: "text",
20140
+ text: await fetchSourceContent(
20141
+ httpClient,
20142
+ AX_SKILLS_REPO,
20143
+ AX_SKILLS_INDEX_PATH,
20144
+ repo === AX_SKILLS_REPO ? commitHash : void 0
20145
+ )
20146
+ };
20147
+ }
19615
20148
  const fetchedContent = await fetchArticleContent(
19616
20149
  httpClient,
19617
20150
  url,
@@ -19654,9 +20187,9 @@ Failed to fetch content: ${errorMsg}`
19654
20187
  }).catch((err) => {
19655
20188
  console.error("[WixREADME] Failed to fetch skills by portal:", err);
19656
20189
  return null;
19657
- }) : fetchDoc({ action: "include", url: RECIPES_INDEX_URL }).then(
20190
+ }) : readmeRecipesIndexEnabled ? fetchDoc({ action: "include", url: RECIPES_INDEX_URL }).then(
19658
20191
  (doc) => doc?.text ?? null
19659
- );
20192
+ ) : Promise.resolve(null);
19660
20193
  const filter = {};
19661
20194
  if (siteId) filter.siteId = siteId;
19662
20195
  else if (siteName) filter.siteName = siteName;
@@ -19676,7 +20209,7 @@ Failed to fetch content: ${errorMsg}`
19676
20209
  const recipesIntro = dedent_default`
19677
20210
  Reusable how-to guides for common ${isVisitorFlow ? "Wix site visitor" : "Wix management"} tasks, grouped by product area. Each recipe is a Wix docs article that bundles the right endpoints, request shapes, field names, and step ordering for one real-world use case.
19678
20211
 
19679
- Scan the index below and open any relevant article with \`ReadFullDocsArticle\`. If the article contains a code example that fits the user's intent — a **complete** example (not a truncated \`... N more lines ...\` snippet) that matches your exact case, same variant/shape — call the API directly. If the closest example is truncated or omits a field your case needs, do NOT call the API off it — continue discovery first: \`ReadFullDocsArticle\` for the complete example, or \`SearchWixAPISpec\` for the exact schema. On query and search methods an example proves only the fields and operators it uses; the endpoint's own declared list covers the rest. Otherwise (no fitting recipe, no usable code example, or persistent errors after retrying), fall back to docs discovery: \`SearchWixRESTDocumentation\` or \`BrowseWixRESTDocsMenu\` to find the right method, then \`SearchWixAPISpec\` for the exact schema.
20212
+ Open the recipe that matches the task with \`ReadFullDocsArticle\` and follow it. When its example for a call matches your case (the same variant and shape), call from it; when it doesn't, or leaves out a field your case needs, read the method's schema with \`SearchWixAPISpec\` first. On query and search methods an example proves only the fields and operators it uses; the method's own declared list covers the rest. When no recipe fits, find the method with \`SearchWixRESTDocumentation\` or \`BrowseWixRESTDocsMenu\`, then \`SearchWixAPISpec\` for its schema.
19680
20213
  `;
19681
20214
  const recipesContents = skillsContent !== null ? [
19682
20215
  await fetchDoc({
@@ -19686,9 +20219,7 @@ Failed to fetch content: ${errorMsg}`
19686
20219
 
19687
20220
  ${skillsContent}`
19688
20221
  })
19689
- ] : await Promise.all(
19690
- baseDocs.filter((doc) => doc.url === RECIPES_INDEX_URL).map(fetchDoc)
19691
- );
20222
+ ] : await Promise.all(recipesIndexDocs.map(fetchDoc));
19692
20223
  const recipeNotes = !skillsContent?.includes("Dashboard Navigation") ? [] : [
19693
20224
  await fetchDoc({
19694
20225
  action: "text",
@@ -19706,7 +20237,8 @@ ${skillsContent}`
19706
20237
  ).map((item) => item.text),
19707
20238
  ...dynamicContext ? [dynamicContext] : []
19708
20239
  ];
19709
- const text = parts.join("\n\n");
20240
+ const joined = parts.join("\n\n");
20241
+ const text = isMintlifyDocsSite(docsSite) ? (await rewriteDocsLinks(joined, { label: "readme WixREADME" })).text : joined;
19710
20242
  return {
19711
20243
  content: [{ type: "text", text }]
19712
20244
  };
@@ -19714,129 +20246,15 @@ ${skillsContent}`
19714
20246
  );
19715
20247
  }
19716
20248
 
19717
- // src/docs/create-site-guide.ts
19718
- function isHeadlessRequest(prompt) {
19719
- return !!prompt && /headless/i.test(prompt);
19720
- }
19721
- var HEADLESS_NON_CLI_INSTRUCTIONS = `# Creating a Wix Headless Site
19722
-
19723
- Wix Headless sites require the **Wix CLI** and cannot be created from the Wix dashboard or via REST API alone. Let the user know they need to set up a local development environment with the Wix CLI before proceeding.
19724
-
19725
- ## Prerequisites
19726
- - Node.js 18+
19727
- - A terminal / command-line environment
19728
-
19729
- ## Steps to Get Started
19730
-
19731
- 1. **Install and authenticate the Wix CLI:**
19732
- \`\`\`
19733
- npx @wix/cli login
19734
- \`\`\`
19735
- 2. **Follow the quick-start guide:** https://dev.wix.com/docs/go-headless
19736
- 3. **For a complete orchestrated setup** (commerce, CMS, bookings, identity), use the Wix Headless skill: https://www.wix-headless.dev/skill.md`;
19737
- var HEADLESS_CLI_INSTRUCTIONS = `# Creating a Wix Headless Site (CLI Flow)
19738
-
19739
- Follow these steps using the \`RunWixCliCommand\` tool to scaffold and configure a Wix Headless site.
19740
-
19741
- ## Before You Start
19742
- Ask the user:
19743
- 1. What is the brand/site name?
19744
- 2. Which local directory should the project be created in?
19745
-
19746
- ## Steps
19747
-
19748
- ### Step 1 \u2014 Authenticate (if not already done)
19749
- Run: \`npx @wix/cli login\`
19750
- Skip if the user is already authenticated.
19751
-
19752
- ### Step 2 \u2014 Scaffold the project
19753
- Use a Wix headless starter template. Ask the user which starter they prefer, or use the default Next.js starter. Follow the scaffolding instructions at: https://dev.wix.com/docs/go-headless
19754
-
19755
- ### Step 3 \u2014 Install dependencies
19756
- Run: \`npm install\` in the project directory.
19757
-
19758
- ### Step 4 \u2014 Pull environment variables
19759
- Run: \`npx @wix/cli env pull\`
19760
- This writes the \`.env.local\` file with the site's environment variables.
19761
-
19762
- ### Step 5 \u2014 Build and verify
19763
- Run: \`npx @wix/cli build\`
19764
-
19765
- ### Step 6 \u2014 Release (optional)
19766
- Run: \`npx @wix/cli release\` to deploy.
19767
-
19768
- ## Full Orchestration
19769
- For a complete multi-wave headless setup (commerce, CMS, bookings, design system, content seeding), refer to the Wix Headless skill: https://www.wix-headless.dev/skill.md
19770
-
19771
- Use \`RunWixCliCommand\` for each CLI step above.`;
19772
- var CREATE_SITE_DOCS = [
19773
- {
19774
- url: "https://dev.wix.com/docs/kb-only/MCP_REST_RECIPES_KB_ID/TRAIN_create_a_new_site_from_template",
19775
- title: "How to Create a New Wix Site",
19776
- nextSteps: "\n\n**Next Steps:** Use the ManageWixSite tool to make the API call for creating the Wix site."
19777
- },
19778
- {
19779
- url: "https://dev.wix.com/docs/kb-only/MCP_REST_RECIPES_KB_ID/TRAIN_wix.devcenter.apps.installer.v1.AppsInstallerService.InstallApp",
19780
- title: "How to Install App on a Wix Site",
19781
- nextSteps: "\n\n**Next Steps:** Use the CallWixSiteAPI tool to make the API call for installing apps on the Wix site."
19782
- }
19783
- ];
19784
- async function addCreateWixBusinessGuideTools(server, disableTools = [], toolDescriptions, cliEnabled = false) {
19785
- if (disableTools.includes("CreateWixBusinessGuide")) {
19786
- return;
19787
- }
19788
- server.tool(
19789
- "CreateWixBusinessGuide",
19790
- toolDescriptions?.["CreateWixBusinessGuide"] ?? defaultToolDescriptions.CreateWixBusinessGuide,
19791
- {
19792
- userPrompt: external_exports.string().optional().describe("The user prompt that triggered this tool")
19793
- },
19794
- { readOnlyHint: true, destructiveHint: false, openWorldHint: false },
19795
- async (args, { httpClient }) => {
19796
- if (isHeadlessRequest(args.userPrompt)) {
19797
- const isCli = typeof cliEnabled === "function" ? cliEnabled() : cliEnabled;
19798
- const text = isCli ? HEADLESS_CLI_INSTRUCTIONS : HEADLESS_NON_CLI_INSTRUCTIONS;
19799
- return { content: [{ type: "text", text }] };
19800
- }
19801
- try {
19802
- const contents = await Promise.all(
19803
- CREATE_SITE_DOCS.map(async ({ url, title, nextSteps }) => {
19804
- const articleContent = await fetchArticleContent(
19805
- httpClient,
19806
- url,
19807
- "article",
19808
- true
19809
- );
19810
- const fullContent = `# ${title}
19811
-
19812
- ${articleContent}${nextSteps}`;
19813
- return { type: "text", text: fullContent };
19814
- })
19815
- );
19816
- return { content: contents };
19817
- } catch (error) {
19818
- return {
19819
- isError: true,
19820
- content: [
19821
- {
19822
- type: "text",
19823
- text: `Error fetching create site documentation: ${error.message}`
19824
- }
19825
- ]
19826
- };
19827
- }
19828
- }
19829
- );
19830
- }
19831
-
19832
20249
  // src/docs/start-deploy-website.ts
20250
+ var NO_PERSONAL_DATA = "No personal data: no names, emails, phones, passwords, keys or local paths.";
19833
20251
  var START_DEPLOY_WEBSITE_PARAM_DESCRIPTIONS = {
19834
- userRequest: "The user's request that led here, quoted if short, otherwise summarized in a sentence.",
19835
- siteDescription: "What the site is: its purpose and who it is for. One or two sentences.",
19836
- siteForm: "The form the site exists in right now (HTML/CSS/JS files, a static build, a zip, another builder's export, a design created in this conversation, or something else), roughly how many files, and whether it includes images.",
19837
- siteFunctionality: "What the site must be able to do for its visitors beyond showing pages, if anything (for example selling, bookings or reservations, tickets, menus and orders, rentals, forms, memberships or paid plans, donations, a blog, or anything else the user expects to work), in your own words. If it is a plain static site with no such needs, say so.",
19838
- agentIdentity: "Which agent or product you are and the harness you run in.",
19839
- wixAccess: "How you can reach Wix from where you run: through this MCP only, or also from a shell whose network can reach wixapis.com; whether you can run the Wix CLI (npx @wix/cli) there and whether it is logged in; and which Wix identity you act with \u2014 the user's login through this MCP, a CLI login, or none."
20252
+ userRequest: `A short summary of what the user asked for and the context that led here, in a sentence or two, including whether this is a new site or an edit or new version of a site already on Wix. ${NO_PERSONAL_DATA}`,
20253
+ siteDescription: `What the site is: its purpose and who it is for. One or two sentences. ${NO_PERSONAL_DATA}`,
20254
+ siteForm: `The form the site exists in right now (HTML/CSS/JS files, a static build, a zip, a framework project, another builder's export, a design created in this conversation, or something else), roughly how many files, and whether it includes images. For a framework project: which framework, whether you have its built static output (for example dist/) or only the source, and whether it needs a server at runtime (SSR, API routes, a backend), or that you don't know. Also where it came from: built in this conversation, the user's own project or repo, another builder (which one), or a Wix skill or template (which one). ${NO_PERSONAL_DATA}`,
20255
+ siteFunctionality: `What the site must be able to do for its visitors beyond showing pages, if anything (for example selling, bookings or reservations, tickets, menus and orders, rentals, forms, memberships or paid plans, donations, a blog, or anything else the user expects to work), in your own words. If it is a plain static site with no such needs, say so. ${NO_PERSONAL_DATA}`,
20256
+ agentIdentity: `Which agent or product you are, which model if you know it, and the harness you run in. ${NO_PERSONAL_DATA}`,
20257
+ wixAccess: `How you can reach Wix from where you run: through this MCP only, or also from a shell whose network can reach wixapis.com; whether you can run the Wix CLI (npx @wix/cli) there and whether it is logged in; which Wix identity you act with \u2014 the user's login through this MCP, a CLI login, or none; and which Wix skills you have (for example wix-headless-kit or wix-manage), by name and where they come from (installed on disk, a plugin, read online), or none. Name the kind of identity, not the account or its email. ${NO_PERSONAL_DATA}`
19840
20258
  };
19841
20259
  var START_DEPLOY_WEBSITE_PARAMS = Object.keys(
19842
20260
  START_DEPLOY_WEBSITE_PARAM_DESCRIPTIONS
@@ -19844,10 +20262,11 @@ var START_DEPLOY_WEBSITE_PARAMS = Object.keys(
19844
20262
  var START_DEPLOY_WEBSITE_TOOL_NAME = "StartDeployWebsite";
19845
20263
  var START_DEPLOY_WEBSITE_RECIPE_URL = "https://dev.wix.com/docs/api-reference/account-level/sites/skills/upload-a-website-or-html-files.md";
19846
20264
  var DROP_PAGE_URL = "https://www.wix.com/headless/drop?utm_campaign=mcp";
20265
+ var WRITE_THE_CODE_LINE = "When the user brought no files, write the site's code yourself, then upload it as the guide shows.";
19847
20266
  var FALLBACK_LINE = `Only if you cannot run it (you can't reach the file bytes, or a step fails and you can't fix it): send the user to ${DROP_PAGE_URL} \u2014 give that URL exactly as written, keeping the utm_campaign=mcp parameter.`;
19848
20267
  function startDeployWebsiteResponse(recipe) {
19849
20268
  return [
19850
- `The following is the content of ${START_DEPLOY_WEBSITE_RECIPE_URL}. Follow it end to end and do the publishing yourself \u2014 do not hand the user instructions.`,
20269
+ `The following is the content of ${START_DEPLOY_WEBSITE_RECIPE_URL}. Follow it end to end and do the publishing yourself \u2014 do not hand the user instructions. ${WRITE_THE_CODE_LINE}`,
19851
20270
  FALLBACK_LINE,
19852
20271
  "---",
19853
20272
  recipe.trim()
@@ -19855,7 +20274,7 @@ function startDeployWebsiteResponse(recipe) {
19855
20274
  }
19856
20275
  var START_DEPLOY_WEBSITE_POINTER_RESPONSE = [
19857
20276
  `Read and follow this recipe end to end: ${START_DEPLOY_WEBSITE_RECIPE_URL}`,
19858
- "It covers creating the site and uploading the files (with or without a Wix login), updating a site deployed this way, and implementing a backend on it (stores, bookings, CMS, members) as a Wix Headless project. Do the publishing yourself \u2014 do not hand the user instructions.",
20277
+ `It covers creating the site and uploading the files (with or without a Wix login), updating a site deployed this way, and implementing a backend on it (stores, bookings, CMS, members) as a Wix Headless project. Do the publishing yourself \u2014 do not hand the user instructions. ${WRITE_THE_CODE_LINE}`,
19859
20278
  FALLBACK_LINE
19860
20279
  ].join("\n\n");
19861
20280
  function addStartDeployWebsiteTool(server, disableTools = [], toolDescriptions, fetchOptions = {}) {
@@ -19900,13 +20319,79 @@ function addStartDeployWebsiteTool(server, disableTools = [], toolDescriptions,
19900
20319
  );
19901
20320
  }
19902
20321
 
19903
- // src/docs/docs.ts
19904
- var REST_SEARCH_API_GROUNDING_REMINDER = dedent_default`
19905
- # Before calling a Wix API
19906
-
19907
- Search results are partial excerpts. Before calling a Wix API tool, make sure the API call is grounded in concrete context: a user-provided endpoint/example, a docs code example, or the official method article/schema.
19908
-
19909
- Do not rely on memory or previous training for Wix REST endpoints, HTTP methods, request bodies, query parameters, field masks, auth context, or site/account scope.
20322
+ // src/docs/start-headless-build.ts
20323
+ var START_HEADLESS_BUILD_TOOL_NAME = "StartHeadlessBuild";
20324
+ var HEADLESS_GUIDE_URL = "https://www.wix.com/skills/headless-cold-start/headless-kit.md";
20325
+ var START_HEADLESS_BUILD_PARAM_DESCRIPTIONS = {
20326
+ userRequest: START_DEPLOY_WEBSITE_PARAM_DESCRIPTIONS.userRequest,
20327
+ siteDescription: START_DEPLOY_WEBSITE_PARAM_DESCRIPTIONS.siteDescription,
20328
+ startingPoint: `What the site starts from, in your own words: a new site; an existing Wix Headless site (a site deployed from files is one), with its metaSiteId if you have it; a project download link (a download.zip from Wix); a Wix site moving to code; or something else. ${NO_PERSONAL_DATA}`,
20329
+ siteFunctionality: START_DEPLOY_WEBSITE_PARAM_DESCRIPTIONS.siteFunctionality,
20330
+ agentIdentity: START_DEPLOY_WEBSITE_PARAM_DESCRIPTIONS.agentIdentity,
20331
+ wixAccess: START_DEPLOY_WEBSITE_PARAM_DESCRIPTIONS.wixAccess
20332
+ };
20333
+ var BUILT_HERE = "The site is built here, in code: don't offer Wix's editor or a template instead.";
20334
+ var PREFIX2 = `The following is Wix's headless guide. Follow it end to end and do the work yourself: you write the site, and the guide creates it, connects its Wix business features, and uploads it. ${BUILT_HERE}`;
20335
+ function startHeadlessBuildResponse(guide) {
20336
+ if (guide && guide.trim()) {
20337
+ return [PREFIX2, "---", guide.trim()].join("\n\n");
20338
+ }
20339
+ return `Wix's headless guide could not be loaded here. It is at ${HEADLESS_GUIDE_URL}: read it whole with ReadFullDocsArticle if you have that tool, otherwise fetch it with curl or your web tool, then follow it end to end and do the work yourself. ${BUILT_HERE}`;
20340
+ }
20341
+ function addStartHeadlessBuildTool(server, disableTools = [], toolDescriptions, fetchOptions = {}) {
20342
+ if (disableTools.includes(START_HEADLESS_BUILD_TOOL_NAME)) {
20343
+ return;
20344
+ }
20345
+ const d = START_HEADLESS_BUILD_PARAM_DESCRIPTIONS;
20346
+ server.tool(
20347
+ START_HEADLESS_BUILD_TOOL_NAME,
20348
+ toolDescriptions?.[START_HEADLESS_BUILD_TOOL_NAME] ?? defaultToolDescriptions[START_HEADLESS_BUILD_TOOL_NAME],
20349
+ {
20350
+ userRequest: external_exports.string().min(1).describe(d.userRequest),
20351
+ siteDescription: external_exports.string().min(1).describe(d.siteDescription),
20352
+ startingPoint: external_exports.string().optional().describe(d.startingPoint),
20353
+ siteFunctionality: external_exports.string().min(1).describe(d.siteFunctionality),
20354
+ agentIdentity: external_exports.string().min(1).describe(d.agentIdentity),
20355
+ wixAccess: external_exports.string().min(1).describe(d.wixAccess)
20356
+ },
20357
+ { readOnlyHint: true, destructiveHint: false, openWorldHint: false },
20358
+ async (_args, { httpClient }) => {
20359
+ let guide;
20360
+ try {
20361
+ guide = await fetchArticleContent(
20362
+ httpClient,
20363
+ HEADLESS_GUIDE_URL,
20364
+ "article",
20365
+ true,
20366
+ fetchOptions.skillsPortalUrl,
20367
+ fetchOptions.repo,
20368
+ fetchOptions.commitHash
20369
+ );
20370
+ } catch (error) {
20371
+ console.warn(
20372
+ "[StartHeadlessBuild] guide fetch failed, returning the pointer:",
20373
+ error instanceof Error ? error.message : error
20374
+ );
20375
+ }
20376
+ return {
20377
+ content: [
20378
+ {
20379
+ type: "text",
20380
+ text: startHeadlessBuildResponse(guide)
20381
+ }
20382
+ ]
20383
+ };
20384
+ }
20385
+ );
20386
+ }
20387
+
20388
+ // src/docs/docs.ts
20389
+ var REST_SEARCH_API_GROUNDING_REMINDER = dedent_default`
20390
+ # Before calling a Wix API
20391
+
20392
+ Search results are partial excerpts. Before calling a Wix API tool, make sure the API call is grounded in concrete context: a user-provided endpoint/example, a docs code example, or the official method article/schema.
20393
+
20394
+ Do not rely on memory or previous training for Wix REST endpoints, HTTP methods, request bodies, query parameters, field masks, auth context, or site/account scope.
19910
20395
 
19911
20396
  If you found a candidate REST method through this search and the excerpt does not fully confirm the endpoint and request shape, read the matching method article with ReadFullDocsArticle. If required body fields, query parameters, filters, paging, revisions, or response shape are still unclear, prefer SearchWixAPISpec to inspect the method schema by docs URL; use ReadFullDocsMethodSchema only if SearchWixAPISpec is unavailable or insufficient.
19912
20397
 
@@ -19943,12 +20428,13 @@ var addDocsTools = (server, allowedTools = [
19943
20428
  "WIX_HEADLESS",
19944
20429
  "BUSINESS_SOLUTIONS",
19945
20430
  "CLI",
19946
- "OVERVIEW"
20431
+ "OVERVIEW",
20432
+ "HELP_CENTER"
19947
20433
  ], options = {}) => {
19948
20434
  const {
19949
20435
  getToKnowWixEnabled = false,
19950
- createWixBusinessGuideEnabled = true,
19951
20436
  startDeployWebsiteEnabled = true,
20437
+ startHeadlessBuildEnabled = true,
19952
20438
  disableTools,
19953
20439
  toolDescriptions,
19954
20440
  readmeDocs,
@@ -19959,15 +20445,47 @@ var addDocsTools = (server, allowedTools = [
19959
20445
  skillsPr,
19960
20446
  commitHash,
19961
20447
  skillsTags,
20448
+ readmeRecipesIndexEnabled,
19962
20449
  dynamicContextEnabled,
19963
- cliEnabled = false,
20450
+ includeCompanionApp,
19964
20451
  usePlatformizedSearch = true,
19965
- usePlatformizedBrowse = true
20452
+ usePlatformizedBrowse = true,
20453
+ docsSite
19966
20454
  } = options;
19967
20455
  const effectiveRepo = repo ?? skillsRepo;
19968
20456
  const effectiveCommitHash = commitHash ?? skillsPr;
19969
- const getDescription = (toolName, defaultDesc) => toolDescriptions?.[toolName] ?? defaultDesc;
20457
+ const mintlifyDocs = isMintlifyDocsSite(docsSite);
20458
+ const runSearch = mintlifyDocs ? async (params) => {
20459
+ const documentTypes = mintlifyDocumentTypes(docsSite, params.toolName);
20460
+ const result = await runSemanticSearchAndFormat(
20461
+ documentTypes ? { ...params, documentTypes } : params
20462
+ );
20463
+ return (await rewriteDocsLinks(result, { label: `search ${params.toolName}` })).text;
20464
+ } : runSemanticSearchAndFormat;
20465
+ const docsUrlPrefixes = mintlifyDocs ? ["https://dev.wix.com/docs/", ...MINTLIFY_URL_PREFIXES] : ["https://dev.wix.com/docs/"];
20466
+ const toBackendUrl = (url) => mintlifyDocs && isMintlifyUrl(url) ? toDevWixUrl(url) : url;
20467
+ const sourceNote = (source) => mintlifyDocs ? [{ type: "text", text: `[docs source] ${source}` }] : [];
20468
+ const docsText = (text) => mintlifyDocs ? toMintlifyHostText(text) : text;
20469
+ const desc2 = (toolName) => {
20470
+ const descriptions = desc(toolName);
20471
+ if (!mintlifyDocs) return descriptions;
20472
+ return Object.fromEntries(
20473
+ Object.entries(descriptions).map(([param, text]) => [
20474
+ param,
20475
+ docsText(text)
20476
+ ])
20477
+ );
20478
+ };
20479
+ const getDescription = (toolName, defaultDesc) => docsText(toolDescriptions?.[toolName] ?? defaultDesc);
19970
20480
  const fetchMenuTextForUrl = async (httpClient, url) => {
20481
+ const text = await fetchMenuTextForBackendUrl(
20482
+ httpClient,
20483
+ toBackendUrl(url)
20484
+ );
20485
+ if (!text || !mintlifyDocs) return text;
20486
+ return (await rewriteDocsLinks(text, { verify: false, label: "menu" })).text;
20487
+ };
20488
+ const fetchMenuTextForBackendUrl = async (httpClient, url) => {
19971
20489
  if (usePlatformizedBrowse) {
19972
20490
  try {
19973
20491
  return await fetchPlatformizedMenu(url);
@@ -19984,10 +20502,25 @@ var addDocsTools = (server, allowedTools = [
19984
20502
  }
19985
20503
  return menuContent.length > MENU_CONTENT_THRESHOLD ? summarizeLargeMenu(menuContent, url) : normalizeMenuContent(menuContent);
19986
20504
  };
20505
+ if (startDeployWebsiteEnabled) {
20506
+ addStartDeployWebsiteTool(server, disableTools || [], toolDescriptions, {
20507
+ skillsPortalUrl,
20508
+ repo: effectiveRepo,
20509
+ commitHash: effectiveCommitHash
20510
+ });
20511
+ }
20512
+ if (startHeadlessBuildEnabled) {
20513
+ addStartHeadlessBuildTool(server, disableTools || [], toolDescriptions, {
20514
+ skillsPortalUrl,
20515
+ repo: effectiveRepo,
20516
+ commitHash: effectiveCommitHash
20517
+ });
20518
+ }
19987
20519
  if (dynamicContextEnabled && authStrategy && !disableTools?.includes("GetSiteContext")) {
19988
20520
  addGetSiteContextTool({
19989
20521
  server,
19990
20522
  authStrategy,
20523
+ includeCompanionApp,
19991
20524
  toolDescriptions,
19992
20525
  disableTools: disableTools || []
19993
20526
  });
@@ -20003,22 +20536,9 @@ var addDocsTools = (server, allowedTools = [
20003
20536
  dynamicContextEnabled,
20004
20537
  repo: effectiveRepo,
20005
20538
  commitHash: effectiveCommitHash,
20006
- skillsTags
20007
- });
20008
- }
20009
- if (createWixBusinessGuideEnabled && !disableTools?.includes("CreateWixBusinessGuide")) {
20010
- addCreateWixBusinessGuideTools(
20011
- server,
20012
- disableTools || [],
20013
- toolDescriptions,
20014
- cliEnabled
20015
- );
20016
- }
20017
- if (startDeployWebsiteEnabled) {
20018
- addStartDeployWebsiteTool(server, disableTools || [], toolDescriptions, {
20019
- skillsPortalUrl,
20020
- repo: effectiveRepo,
20021
- commitHash: effectiveCommitHash
20539
+ skillsTags,
20540
+ readmeRecipesIndexEnabled,
20541
+ docsSite
20022
20542
  });
20023
20543
  }
20024
20544
  if (allowedTools.includes("WDS") && !disableTools?.includes("SearchWixWDSDocumentation")) {
@@ -20029,7 +20549,7 @@ var addDocsTools = (server, allowedTools = [
20029
20549
  defaultToolDescriptions.SearchWixWDSDocumentation ?? ""
20030
20550
  ),
20031
20551
  (() => {
20032
- const d = desc("SearchWixWDSDocumentation");
20552
+ const d = desc2("SearchWixWDSDocumentation");
20033
20553
  return {
20034
20554
  searchTerm: external_exports.string().describe(d.searchTerm),
20035
20555
  maxResults: external_exports.number().describe(d.maxResults).min(1).max(15).optional().default(15)
@@ -20039,7 +20559,7 @@ var addDocsTools = (server, allowedTools = [
20039
20559
  async ({ searchTerm, maxResults }, { panorama }) => {
20040
20560
  try {
20041
20561
  logger.log(`Searching for ${searchTerm} in Wix WDS`);
20042
- const result = await runSemanticSearchAndFormat({
20562
+ const result = await runSearch({
20043
20563
  toolName: "WDS",
20044
20564
  toolParams: {
20045
20565
  searchTerm
@@ -20082,7 +20602,7 @@ var addDocsTools = (server, allowedTools = [
20082
20602
  defaultToolDescriptions.SearchWixRESTDocumentation
20083
20603
  ),
20084
20604
  (() => {
20085
- const d = desc("SearchWixRESTDocumentation");
20605
+ const d = desc2("SearchWixRESTDocumentation");
20086
20606
  return {
20087
20607
  searchTerm: external_exports.string().describe(d.searchTerm),
20088
20608
  maxResults: external_exports.number().describe(d.maxResults).min(1).max(17).optional().default(17),
@@ -20095,7 +20615,7 @@ var addDocsTools = (server, allowedTools = [
20095
20615
  logger.log(
20096
20616
  `[SearchWixRESTDocumentation] searchTerm="${searchTerm}", reason="${reason}"`
20097
20617
  );
20098
- const result = await runSemanticSearchAndFormat({
20618
+ const result = await runSearch({
20099
20619
  toolName: "REST",
20100
20620
  toolParams: {
20101
20621
  searchTerm
@@ -20146,7 +20666,7 @@ var addDocsTools = (server, allowedTools = [
20146
20666
  defaultToolDescriptions.WixBusinessFlowsDocumentation ?? ""
20147
20667
  ),
20148
20668
  (() => {
20149
- const d = desc("WixBusinessFlowsDocumentation");
20669
+ const d = desc2("WixBusinessFlowsDocumentation");
20150
20670
  return {
20151
20671
  searchTerm: external_exports.string().describe(d.searchTerm),
20152
20672
  maxResults: external_exports.number().describe(d.maxResults).min(1).max(15).optional().default(15)
@@ -20156,7 +20676,7 @@ var addDocsTools = (server, allowedTools = [
20156
20676
  async ({ searchTerm, maxResults }, { panorama }) => {
20157
20677
  try {
20158
20678
  logger.log(`Searching for ${searchTerm} in Wix Sample Flows`);
20159
- const result = await runSemanticSearchAndFormat({
20679
+ const result = await runSearch({
20160
20680
  toolName: "BUSINESS_SOLUTIONS",
20161
20681
  toolParams: {
20162
20682
  searchTerm: "**RECIPE**: Business Recipes - full setup flow for::: " + searchTerm
@@ -20202,7 +20722,7 @@ var addDocsTools = (server, allowedTools = [
20202
20722
  defaultToolDescriptions.SearchWixSDKDocumentation ?? ""
20203
20723
  ),
20204
20724
  (() => {
20205
- const d = desc("SearchWixSDKDocumentation");
20725
+ const d = desc2("SearchWixSDKDocumentation");
20206
20726
  return {
20207
20727
  searchTerm: external_exports.string().describe(d.searchTerm),
20208
20728
  maxResults: external_exports.number().describe(d.maxResults).min(1).max(15).optional().default(15)
@@ -20213,7 +20733,7 @@ var addDocsTools = (server, allowedTools = [
20213
20733
  try {
20214
20734
  logger.log(`Searching for ${searchTerm} in Wix SDK`);
20215
20735
  panorama.transaction("SearchWixSDKDocumentation").start({ maxResults });
20216
- const result = await runSemanticSearchAndFormat({
20736
+ const result = await runSearch({
20217
20737
  toolName: "SDK",
20218
20738
  toolParams: {
20219
20739
  searchTerm
@@ -20261,7 +20781,7 @@ var addDocsTools = (server, allowedTools = [
20261
20781
  defaultToolDescriptions.SearchBuildAppsDocumentation ?? ""
20262
20782
  ),
20263
20783
  (() => {
20264
- const d = desc("SearchBuildAppsDocumentation");
20784
+ const d = desc2("SearchBuildAppsDocumentation");
20265
20785
  return {
20266
20786
  searchTerm: external_exports.string().describe(d.searchTerm),
20267
20787
  maxResults: external_exports.number().describe(d.maxResults).min(1).max(15).optional().default(15)
@@ -20271,7 +20791,7 @@ var addDocsTools = (server, allowedTools = [
20271
20791
  async ({ searchTerm, maxResults }, { panorama }) => {
20272
20792
  try {
20273
20793
  logger.log(`Searching for ${searchTerm} in Build Apps`);
20274
- const result = await runSemanticSearchAndFormat({
20794
+ const result = await runSearch({
20275
20795
  toolName: "BUILD_APPS",
20276
20796
  toolParams: {
20277
20797
  searchTerm: `wix cli docs for ${searchTerm}`
@@ -20313,7 +20833,7 @@ var addDocsTools = (server, allowedTools = [
20313
20833
  defaultToolDescriptions.SearchDevelopmentDocumentation ?? ""
20314
20834
  ),
20315
20835
  (() => {
20316
- const d = desc("SearchDevelopmentDocumentation");
20836
+ const d = desc2("SearchDevelopmentDocumentation");
20317
20837
  return {
20318
20838
  searchTerm: external_exports.string().describe(d.searchTerm),
20319
20839
  maxResults: external_exports.number().describe(d.maxResults).min(1).max(15).optional().default(15)
@@ -20323,7 +20843,7 @@ var addDocsTools = (server, allowedTools = [
20323
20843
  async ({ searchTerm, maxResults }, { panorama }) => {
20324
20844
  try {
20325
20845
  logger.log(`Searching for ${searchTerm} in Wix Overview`);
20326
- const result = await runSemanticSearchAndFormat({
20846
+ const result = await runSearch({
20327
20847
  toolName: "OVERVIEW",
20328
20848
  toolParams: {
20329
20849
  searchTerm
@@ -20365,7 +20885,7 @@ var addDocsTools = (server, allowedTools = [
20365
20885
  defaultToolDescriptions.SearchWixHeadlessDocumentation ?? ""
20366
20886
  ),
20367
20887
  (() => {
20368
- const d = desc("SearchWixHeadlessDocumentation");
20888
+ const d = desc2("SearchWixHeadlessDocumentation");
20369
20889
  return {
20370
20890
  searchTerm: external_exports.string().describe(d.searchTerm),
20371
20891
  maxResults: external_exports.number().describe(d.maxResults).min(1).max(17).optional().default(17)
@@ -20375,7 +20895,7 @@ var addDocsTools = (server, allowedTools = [
20375
20895
  async ({ searchTerm, maxResults }, { panorama }) => {
20376
20896
  try {
20377
20897
  logger.log(`Searching for ${searchTerm} in Headless`);
20378
- const result = await runSemanticSearchAndFormat({
20898
+ const result = await runSearch({
20379
20899
  toolName: "WIX_HEADLESS",
20380
20900
  toolParams: {
20381
20901
  searchTerm
@@ -20420,7 +20940,7 @@ var addDocsTools = (server, allowedTools = [
20420
20940
  defaultToolDescriptions.SearchWixVeloDocumentation ?? ""
20421
20941
  ),
20422
20942
  (() => {
20423
- const d = desc("SearchWixVeloDocumentation");
20943
+ const d = desc2("SearchWixVeloDocumentation");
20424
20944
  return {
20425
20945
  searchTerm: external_exports.string().describe(d.searchTerm),
20426
20946
  maxResults: external_exports.number().describe(d.maxResults).min(1).max(15).optional().default(15)
@@ -20431,7 +20951,7 @@ var addDocsTools = (server, allowedTools = [
20431
20951
  try {
20432
20952
  logger.log(`Searching for ${searchTerm} in Velo`);
20433
20953
  panorama.transaction("SearchWixVeloDocumentation").start({ maxResults });
20434
- const result = await runSemanticSearchAndFormat({
20954
+ const result = await runSearch({
20435
20955
  toolName: "VELO",
20436
20956
  toolParams: {
20437
20957
  searchTerm
@@ -20469,6 +20989,72 @@ var addDocsTools = (server, allowedTools = [
20469
20989
  }
20470
20990
  );
20471
20991
  }
20992
+ if (allowedTools.includes("HELP_CENTER") && !disableTools?.includes("SearchWixHelpCenter")) {
20993
+ server.tool(
20994
+ "SearchWixHelpCenter",
20995
+ getDescription(
20996
+ "SearchWixHelpCenter",
20997
+ defaultToolDescriptions.SearchWixHelpCenter ?? ""
20998
+ ),
20999
+ (() => {
21000
+ const d = desc2("SearchWixHelpCenter");
21001
+ return {
21002
+ searchTerm: external_exports.string().describe(d.searchTerm),
21003
+ maxResults: external_exports.number().describe(d.maxResults).min(1).max(15).optional().default(15),
21004
+ reason: external_exports.string().describe(d.reason)
21005
+ };
21006
+ })(),
21007
+ { readOnlyHint: true, destructiveHint: false, openWorldHint: false },
21008
+ async ({ searchTerm, maxResults, reason }, { panorama }) => {
21009
+ try {
21010
+ logger.log(
21011
+ `[SearchWixHelpCenter] searchTerm="${searchTerm}", reason="${reason}"`
21012
+ );
21013
+ const result = await runSemanticSearchAndFormat({
21014
+ toolName: "HELP_CENTER",
21015
+ toolParams: {
21016
+ searchTerm
21017
+ },
21018
+ maxResults: Math.max(1, Math.min(maxResults ?? 15, 15)),
21019
+ linesInEachResult: 60,
21020
+ usePlatformizedSearch
21021
+ });
21022
+ return {
21023
+ content: [
21024
+ {
21025
+ type: "text",
21026
+ text: `${HELP_CENTER_IS_FOR_PEOPLE}
21027
+
21028
+ ${result}`
21029
+ }
21030
+ ]
21031
+ };
21032
+ } catch (error) {
21033
+ panorama.errorMonitor().reportError(error);
21034
+ captureException(error, {
21035
+ tags: {
21036
+ componentId: "SearchWixHelpCenter",
21037
+ toolName: "SearchWixHelpCenter"
21038
+ }
21039
+ });
21040
+ logger.error(
21041
+ `Error searching for ${searchTerm} in the Wix Help Center: ${error}`
21042
+ );
21043
+ return {
21044
+ isError: true,
21045
+ content: [
21046
+ {
21047
+ type: "text",
21048
+ text: `Error: ${error.message}
21049
+
21050
+ ${HELP_CENTER_IS_FOR_PEOPLE}`
21051
+ }
21052
+ ]
21053
+ };
21054
+ }
21055
+ }
21056
+ );
21057
+ }
20472
21058
  if (allowedTools.includes("CLI") && !disableTools?.includes("SearchWixCLIDocumentation")) {
20473
21059
  server.tool(
20474
21060
  "SearchWixCLIDocumentation",
@@ -20477,7 +21063,7 @@ var addDocsTools = (server, allowedTools = [
20477
21063
  defaultToolDescriptions.SearchWixCLIDocumentation ?? ""
20478
21064
  ),
20479
21065
  (() => {
20480
- const d = desc("SearchWixCLIDocumentation");
21066
+ const d = desc2("SearchWixCLIDocumentation");
20481
21067
  return {
20482
21068
  searchTerm: external_exports.string().describe(d.searchTerm),
20483
21069
  maxResults: external_exports.number().describe(d.maxResults).min(1).max(15).optional().default(15),
@@ -20490,7 +21076,7 @@ var addDocsTools = (server, allowedTools = [
20490
21076
  logger.log(
20491
21077
  `[SearchWixCLIDocumentation] searchTerm="${searchTerm}", reason="${reason}"`
20492
21078
  );
20493
- const result = await runSemanticSearchAndFormat({
21079
+ const result = await runSearch({
20494
21080
  toolName: "CLI",
20495
21081
  toolParams: {
20496
21082
  searchTerm
@@ -20534,14 +21120,39 @@ var addDocsTools = (server, allowedTools = [
20534
21120
  defaultToolDescriptions.ReadFullDocsArticle
20535
21121
  ),
20536
21122
  (() => {
20537
- const d = desc("ReadFullDocsArticle");
21123
+ const d = desc2("ReadFullDocsArticle");
20538
21124
  return {
20539
21125
  articleUrl: external_exports.string().url().describe(d.articleUrl)
20540
21126
  };
20541
21127
  })(),
20542
21128
  { readOnlyHint: true, destructiveHint: false, openWorldHint: false },
20543
21129
  async ({ articleUrl }, { httpClient }) => {
20544
- const validPrefixes = ["https://dev.wix.com/docs/"];
21130
+ const source = parseSourceContentUrl(articleUrl);
21131
+ if (source) {
21132
+ try {
21133
+ const text = await fetchSourceContent(
21134
+ httpClient,
21135
+ source.repo,
21136
+ source.path,
21137
+ source.commitHash
21138
+ );
21139
+ return { content: [{ type: "text", text }] };
21140
+ } catch (error) {
21141
+ logger.error(
21142
+ `Error fetching source content for ${articleUrl}: ${error}`
21143
+ );
21144
+ return {
21145
+ isError: true,
21146
+ content: [
21147
+ {
21148
+ type: "text",
21149
+ text: formatDocsReadError("source content", error)
21150
+ }
21151
+ ]
21152
+ };
21153
+ }
21154
+ }
21155
+ const validPrefixes = [...docsUrlPrefixes, "https://support.wix.com/"];
20545
21156
  if (skillsPortalUrl) validPrefixes.push(skillsPortalUrl);
20546
21157
  const isSkillsPage = isSkillsRegistryUrl(articleUrl);
20547
21158
  if (!isSkillsPage && !validPrefixes.some((p) => articleUrl.startsWith(p))) {
@@ -20550,7 +21161,7 @@ var addDocsTools = (server, allowedTools = [
20550
21161
  content: [
20551
21162
  {
20552
21163
  type: "text",
20553
- text: `Invalid article URL: must start with https://dev.wix.com/docs/, or be a Wix skills page (https://www.wix.com/skills/...). Got: "${articleUrl}"`
21164
+ 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}"`
20554
21165
  }
20555
21166
  ]
20556
21167
  };
@@ -20558,6 +21169,27 @@ var addDocsTools = (server, allowedTools = [
20558
21169
  if (!isSkillsPage && articleUrl.startsWith("https://dev.wix.com/docs/")) {
20559
21170
  articleUrl = articleUrl.replace(/\.md$/, "");
20560
21171
  }
21172
+ if (mintlifyDocs && !isSkillsPage) {
21173
+ try {
21174
+ const page = await readMintlifyMarkdown(articleUrl);
21175
+ if (page) {
21176
+ return {
21177
+ content: [
21178
+ {
21179
+ type: "text",
21180
+ text: isQueryOrSearchEndpoint(page.url) ? [page.markdown, ARTICLE_CAPABILITY_NOTE].join("\n\n") : page.markdown
21181
+ },
21182
+ ...sourceNote(`Mintlify site: ${page.url}.md`)
21183
+ ]
21184
+ };
21185
+ }
21186
+ } catch (error) {
21187
+ logger.error(
21188
+ `[mintlify] reading ${articleUrl} from Mintlify failed, falling back: ${error}`
21189
+ );
21190
+ }
21191
+ articleUrl = toBackendUrl(articleUrl);
21192
+ }
20561
21193
  try {
20562
21194
  const articleContent = await fetchArticleContent(
20563
21195
  httpClient,
@@ -20578,7 +21210,10 @@ var addDocsTools = (server, allowedTools = [
20578
21210
  // The article's own URL, never its body — a filter/sort reference page links query
20579
21211
  // methods in its prose but isn't one.
20580
21212
  text: isQueryOrSearchEndpoint(articleUrl) ? [articleContent, ARTICLE_CAPABILITY_NOTE].join("\n\n") : articleContent
20581
- }
21213
+ },
21214
+ ...sourceNote(
21215
+ isSkillsPage ? `skills registry: ${articleUrl}` : `today's backend (dev.wix.com/rawdocs, ingvar), not on the Mintlify site: ${articleUrl}`
21216
+ )
20582
21217
  ]
20583
21218
  };
20584
21219
  } catch (error) {
@@ -20624,7 +21259,7 @@ ${text}`
20624
21259
  defaultToolDescriptions.ReadFullDocsMethodSchema
20625
21260
  ),
20626
21261
  (() => {
20627
- const d = desc("ReadFullDocsMethodSchema");
21262
+ const d = desc2("ReadFullDocsMethodSchema");
20628
21263
  return {
20629
21264
  articleUrl: external_exports.string().url().describe(d.articleUrl),
20630
21265
  reason: external_exports.string().describe(d.reason)
@@ -20632,7 +21267,7 @@ ${text}`
20632
21267
  })(),
20633
21268
  { readOnlyHint: true, destructiveHint: false, openWorldHint: false },
20634
21269
  async ({ articleUrl, reason }, { httpClient }) => {
20635
- const validPrefixes = ["https://dev.wix.com/docs/"];
21270
+ const validPrefixes = [...docsUrlPrefixes];
20636
21271
  if (skillsPortalUrl) validPrefixes.push(skillsPortalUrl);
20637
21272
  if (!validPrefixes.some((p) => articleUrl.startsWith(p))) {
20638
21273
  return {
@@ -20648,6 +21283,7 @@ ${text}`
20648
21283
  if (articleUrl.startsWith("https://dev.wix.com/docs/")) {
20649
21284
  articleUrl = articleUrl.replace(/\.md$/, "");
20650
21285
  }
21286
+ articleUrl = toBackendUrl(articleUrl);
20651
21287
  try {
20652
21288
  logger.log(
20653
21289
  `[ReadFullDocsMethodSchema] url="${articleUrl}", reason="${reason}"`
@@ -20665,12 +21301,18 @@ ${text}`
20665
21301
  if (!articleContent) {
20666
21302
  throw new Error("Method schema is empty");
20667
21303
  }
21304
+ const schemaText = mintlifyDocs ? (await rewriteDocsLinks(articleContent, {
21305
+ label: "schema ReadFullDocsMethodSchema"
21306
+ })).text : articleContent;
20668
21307
  return {
20669
21308
  content: [
20670
21309
  {
20671
21310
  type: "text",
20672
- text: articleContent
20673
- }
21311
+ text: schemaText
21312
+ },
21313
+ ...sourceNote(
21314
+ `PAPI, through today's backend (dev.wix.com/rawdocs, ingvar): ${articleUrl}`
21315
+ )
20674
21316
  ]
20675
21317
  };
20676
21318
  } catch (error) {
@@ -20716,7 +21358,7 @@ ${text}`
20716
21358
  defaultToolDescriptions.BrowseWixRESTDocsMenu
20717
21359
  ),
20718
21360
  (() => {
20719
- const d = desc("BrowseWixRESTDocsMenu");
21361
+ const d = desc2("BrowseWixRESTDocsMenu");
20720
21362
  return {
20721
21363
  menuUrl: external_exports.string().optional().describe(d.menuUrl),
20722
21364
  reason: external_exports.string().describe(d.reason)
@@ -20725,7 +21367,7 @@ ${text}`
20725
21367
  { readOnlyHint: true, destructiveHint: false, openWorldHint: false },
20726
21368
  async ({ menuUrl, reason }, { httpClient }) => {
20727
21369
  try {
20728
- if (menuUrl && !menuUrl.startsWith("https://dev.wix.com/docs/")) {
21370
+ if (menuUrl && !docsUrlPrefixes.some((p) => menuUrl.startsWith(p))) {
20729
21371
  return {
20730
21372
  content: [
20731
21373
  {
@@ -21008,7 +21650,7 @@ function resolveBase64Image(imageBase64, mimeType) {
21008
21650
  function errorResponse(text) {
21009
21651
  return { isError: true, content: [{ type: "text", text }] };
21010
21652
  }
21011
- async function uploadFromUrl(item, authHeaders, displayName) {
21653
+ async function uploadFromUrl(item, authHeaders, displayName, imagePickerToolName) {
21012
21654
  if (!item.download_url) {
21013
21655
  return {
21014
21656
  success: false,
@@ -21018,7 +21660,7 @@ async function uploadFromUrl(item, authHeaders, displayName) {
21018
21660
  if (!/^https?:\/\//i.test(item.download_url)) {
21019
21661
  return {
21020
21662
  success: false,
21021
- error: `download_url must be a publicly accessible http(s) URL, not a local or sandbox file path (got: "${item.download_url}"). For a user-attached file, pass the file so the platform resolves it to a real download_url; if you only have the raw bytes, use imageBase64 instead.`
21663
+ error: `This server can't read files on your machine or sandbox (got: "${item.download_url}"). Send this image as imageBase64 (the whole file, one per call) or as a public URL in imageUrls${imagePickerToolName ? `, or call ${imagePickerToolName} so the user picks it` : ""}.`
21022
21664
  };
21023
21665
  }
21024
21666
  try {
@@ -21116,7 +21758,10 @@ function formatBatchResults(results) {
21116
21758
  };
21117
21759
  }
21118
21760
  function addUploadImageTool(server, strategy, options) {
21119
- const description = options?.description ?? defaultToolDescriptions.UploadImageToWixSite;
21761
+ const imagePickerToolName = options?.imagePickerToolName;
21762
+ const baseDescription = options?.description || defaultToolDescriptions.UploadImageToWixSite;
21763
+ const description = imagePickerToolName ? `${baseDescription}
21764
+ If you can't deliver the image any of these ways, call ${imagePickerToolName} so the user picks it.` : baseDescription;
21120
21765
  const hints = {
21121
21766
  readOnlyHint: options?.hints?.readOnlyHint ?? false,
21122
21767
  destructiveHint: options?.hints?.destructiveHint ?? false,
@@ -21183,7 +21828,9 @@ function addUploadImageTool(server, strategy, options) {
21183
21828
  try {
21184
21829
  const authHeaders = await strategy.getSiteAuthHeaders(siteId);
21185
21830
  const urlResults = await Promise.all(
21186
- urlItems.map((item) => uploadFromUrl(item, authHeaders, displayName))
21831
+ urlItems.map(
21832
+ (item) => uploadFromUrl(item, authHeaders, displayName, imagePickerToolName)
21833
+ )
21187
21834
  );
21188
21835
  let base64Result = null;
21189
21836
  if (imageBase64) {
@@ -21250,7 +21897,8 @@ function formatApiResponse(responseData, maxResponseSize = DEFAULT_MAX_RESPONSE_
21250
21897
  }
21251
21898
  return { text: responseText, isError: false, originalLength, returnedRows };
21252
21899
  }
21253
- function addApiCallTool(server, strategy, allowedTools = ["CallWixSiteAPI", "ListWixSites", "ManageWixSite"], disableTools = [], enableTools = [], toolDescriptions, toolHints, maxResponseSize) {
21900
+ function addApiCallTool(server, strategy, allowedTools = ["CallWixSiteAPI", "ListWixSites", "ManageWixSite"], disableTools = [], enableTools = [], toolDescriptions, toolHints, maxResponseSize, options) {
21901
+ const executeAdvice = (text, reconnect, plain) => options?.executeWixAPIServed ? text : text.replace(reconnect, plain);
21254
21902
  const effectiveAllowedTools = [
21255
21903
  .../* @__PURE__ */ new Set([...allowedTools, ...enableTools])
21256
21904
  ].filter((tool) => !disableTools.includes(tool));
@@ -21263,7 +21911,14 @@ function addApiCallTool(server, strategy, allowedTools = ["CallWixSiteAPI", "Lis
21263
21911
  if (effectiveAllowedTools.includes("CallWixSiteAPI") && !disableTools.includes("CallWixSiteAPI")) {
21264
21912
  server.tool(
21265
21913
  "CallWixSiteAPI",
21266
- getDescription("CallWixSiteAPI", defaultToolDescriptions.CallWixSiteAPI),
21914
+ executeAdvice(
21915
+ getDescription(
21916
+ "CallWixSiteAPI",
21917
+ defaultToolDescriptions.CallWixSiteAPI
21918
+ ),
21919
+ CALL_WIX_SITE_API_RECONNECT_LINE,
21920
+ CALL_WIX_SITE_API_NO_EXECUTE_LINE
21921
+ ),
21267
21922
  (() => {
21268
21923
  const d = desc("CallWixSiteAPI");
21269
21924
  return {
@@ -21272,17 +21927,34 @@ function addApiCallTool(server, strategy, allowedTools = ["CallWixSiteAPI", "Lis
21272
21927
  method: external_exports.string().describe(d.method),
21273
21928
  body: external_exports.union([external_exports.object({}).passthrough(), external_exports.array(external_exports.unknown())]).optional().describe(d.body),
21274
21929
  reason: external_exports.string().describe(d.reason),
21930
+ whyNotExecuteWixAPI: external_exports.string().optional().describe(
21931
+ executeAdvice(
21932
+ d.whyNotExecuteWixAPI,
21933
+ WHY_NOT_EXECUTE_RECONNECT,
21934
+ WHY_NOT_EXECUTE_NO_EXECUTE
21935
+ )
21936
+ ),
21275
21937
  sourceDocUrl: external_exports.string().describe(d.sourceDocUrl)
21276
21938
  };
21277
21939
  })(),
21940
+ // openWorldHint true: a free-form URL into the whole Wix REST surface is an
21941
+ // open-ended target, even though auth is bounded to the user's account.
21278
21942
  getHints("CallWixSiteAPI", {
21279
21943
  readOnlyHint: false,
21280
21944
  destructiveHint: true,
21281
- openWorldHint: false
21945
+ openWorldHint: true
21282
21946
  }),
21283
- async ({ url, body, method, siteId, reason, sourceDocUrl }, { httpClient, setToolBiParams }) => {
21947
+ async ({
21948
+ url,
21949
+ body,
21950
+ method,
21951
+ siteId,
21952
+ reason,
21953
+ whyNotExecuteWixAPI,
21954
+ sourceDocUrl
21955
+ }, { httpClient, setToolBiParams }) => {
21284
21956
  logger.log(
21285
- `[CallWixSiteAPI] siteId=${siteId}, method=${method}, url=${url}, sourceDocUrl=${sourceDocUrl}, reason="${reason}", body=${JSON.stringify(body)}`
21957
+ `[CallWixSiteAPI] siteId=${siteId}, method=${method}, url=${url}, sourceDocUrl=${sourceDocUrl}, reason="${reason}", whyNotExecuteWixAPI="${whyNotExecuteWixAPI ?? ""}", body=${JSON.stringify(body)}`
21286
21958
  );
21287
21959
  const requestHeaders = {
21288
21960
  // Ask the Wix API edge for JSON error bodies (it serves a branded HTML
@@ -21455,7 +22127,7 @@ function addApiCallTool(server, strategy, allowedTools = ["CallWixSiteAPI", "Lis
21455
22127
  getHints("ManageWixSite", {
21456
22128
  readOnlyHint: false,
21457
22129
  destructiveHint: true,
21458
- openWorldHint: false
22130
+ openWorldHint: true
21459
22131
  }),
21460
22132
  async ({ url, body, method, reason }, { httpClient, setToolBiParams }) => {
21461
22133
  logger.log(
@@ -21525,7 +22197,8 @@ function addApiCallTool(server, strategy, allowedTools = ["CallWixSiteAPI", "Lis
21525
22197
  if (effectiveAllowedTools.includes("UploadImageToWixSite") && !disableTools.includes("UploadImageToWixSite")) {
21526
22198
  addUploadImageTool(server, strategy, {
21527
22199
  description: getDescription("UploadImageToWixSite", ""),
21528
- hints: toolHints?.["UploadImageToWixSite"]
22200
+ hints: toolHints?.["UploadImageToWixSite"],
22201
+ imagePickerToolName: options?.imagePickerToolName
21529
22202
  });
21530
22203
  }
21531
22204
  }
@@ -21543,10 +22216,14 @@ function truncateResponse(content, maxChars = DEFAULT_MAX_CHARS) {
21543
22216
  const truncated = text.slice(0, effectiveMax);
21544
22217
  const estimatedTokens = Math.ceil(text.length / CHARS_PER_TOKEN);
21545
22218
  const limitTokens = Math.ceil(effectiveMax / CHARS_PER_TOKEN);
21546
- return `${truncated}
22219
+ const cutChars = text.length - effectiveMax;
22220
+ const note = `Response was ~${estimatedTokens.toLocaleString()} tokens (limit: ${limitTokens.toLocaleString()}). Showing the first ${effectiveMax.toLocaleString()} of ${text.length.toLocaleString()} characters; the last ${cutChars.toLocaleString()} were cut. To get the rest, run again and return less per call \u2014 only the fields you need, the next page (cursor or offset), or the next slice of a large array \u2014 and repeat until you have it all.`;
22221
+ return `[TRUNCATED: ${note}]
22222
+
22223
+ ${truncated}
21547
22224
 
21548
22225
  --- TRUNCATED ---
21549
- Response was ~${estimatedTokens.toLocaleString()} tokens (limit: ${limitTokens.toLocaleString()}). Refine your code to return less data.`;
22226
+ ${note}`;
21550
22227
  }
21551
22228
 
21552
22229
  // src/graphql/constants.ts
@@ -22211,7 +22888,8 @@ function addExecuteGraphqlTool(server, description, authStrategy, options) {
22211
22888
  hasMutations: external_exports.boolean().describe(d.hasMutations),
22212
22889
  reason: external_exports.string().describe(d.reason)
22213
22890
  },
22214
- { readOnlyHint: false, destructiveHint: true, openWorldHint: false },
22891
+ // openWorldHint true: any operation in the Wix GraphQL schema, chosen at call time.
22892
+ { readOnlyHint: false, destructiveHint: true, openWorldHint: true },
22215
22893
  async ({ query, variables, operationName, siteId, scope, hasMutations, reason }, extra) => {
22216
22894
  const effectiveScope = scope ?? (siteId ? "site" : "account");
22217
22895
  logger.log(
@@ -22306,7 +22984,7 @@ ${text.slice(0, 2e3)}`
22306
22984
 
22307
22985
  // src/code-mode/attachments.ts
22308
22986
  var MAX_ATTACHMENTS_BYTES = 10 * 1024 * 1024;
22309
- var MAX_REDIRECTS = 4;
22987
+ var MAX_REDIRECTS2 = 4;
22310
22988
  var OAI_USERCONTENT_HOST = /^[a-z0-9-]+\.oaiusercontent\.com$/;
22311
22989
  var OAI_BLOB_ACCOUNTS = new Set(
22312
22990
  [
@@ -22380,7 +23058,7 @@ async function fetchAllowed(start, fetchImpl, label) {
22380
23058
  const isRedirect = res.status >= 300 && res.status < 400 && location;
22381
23059
  if (!isRedirect) return res;
22382
23060
  await res.body?.cancel().catch(() => void 0);
22383
- if (hop >= MAX_REDIRECTS) {
23061
+ if (hop >= MAX_REDIRECTS2) {
22384
23062
  throw new AttachmentError(`${label}: too many redirects.`);
22385
23063
  }
22386
23064
  let next;
@@ -22443,7 +23121,7 @@ async function resolveAttachments(attachments, fetchImpl = fetch) {
22443
23121
  throw new AttachmentError(
22444
23122
  `attachments[${i}] was not resolved to a download URL (got ${JSON.stringify(
22445
23123
  typeof raw === "string" ? raw : (a && a.download_url) ?? raw
22446
- )}). The platform did not hydrate this attachment; retry once, and if it still arrives like this put the file in the \`files\` bundle instead (\`=== FILE: <path> base64 ===\` for binary).`
23124
+ )}). \`attachments\` works only in ChatGPT, which swaps each file for a download URL before the call reaches Wix. Here it arrived as written, and Wix cannot read a path on your machine, so retrying the same value fails the same way. Upload another way. With a shell that reaches the internet, send the file from there (for a site, the StartDeployWebsite recipe's curl drop). Otherwise leave \`attachments\` out and put the files in \`files\`: text as is, and a binary as a \`=== FILE: <path> base64 ===\` entry only when it is a few KB (an icon, a logo), since a larger base64 payload does not survive your own output. A larger image goes in by public URL or through the user (the Media Manager).`
22447
23125
  );
22448
23126
  }
22449
23127
  const problem = checkAttachmentUrl(url);
@@ -22501,6 +23179,998 @@ function validateExecuteCode(code) {
22501
23179
  return { isValid: true };
22502
23180
  }
22503
23181
 
23182
+ // src/api-call/site-files.ts
23183
+ var MAX_FILES_BUNDLE_CHARS = 4e6;
23184
+ var MAX_UNZIP_BYTES = 64 * 1024 * 1024;
23185
+ var MAX_SITE_FILES = 2e3;
23186
+ var textEncoder = new TextEncoder();
23187
+ function base64ToBytes(b64) {
23188
+ const clean = b64.replace(/^data:[^,]*,/, "").replace(/\s+/g, "");
23189
+ return Uint8Array.from(atob(clean), (c) => c.charCodeAt(0));
23190
+ }
23191
+ function parseFileBundle(bundle) {
23192
+ if (!bundle || !bundle.trim()) return [];
23193
+ if (bundle.length > MAX_FILES_BUNDLE_CHARS) {
23194
+ throw new Error(
23195
+ `files bundle is too large (${bundle.length} chars; max ${MAX_FILES_BUNDLE_CHARS}). Keep it to text and small base64 assets; pass larger files through attachments or reference media by URL.`
23196
+ );
23197
+ }
23198
+ const delimiter = /^=== FILE: (.+?)(?: (base64))? ===[ \t]*$/gm;
23199
+ const matches = [...bundle.matchAll(delimiter)];
23200
+ if (matches.length === 0) {
23201
+ throw new Error(
23202
+ "files bundle has no `=== FILE: <path> ===` sections. Start each file with that line (add ` base64` before the closing === for binary content)."
23203
+ );
23204
+ }
23205
+ return matches.map((match, i) => {
23206
+ const path = match[1].trim();
23207
+ const start = (match.index ?? 0) + match[0].length;
23208
+ const end = i + 1 < matches.length ? matches[i + 1].index ?? bundle.length : bundle.length;
23209
+ const content = bundle.slice(start, end).replace(/^\r?\n/, "").replace(/\r?\n$/, "");
23210
+ return {
23211
+ path,
23212
+ bytes: match[2] === "base64" ? base64ToBytes(content) : textEncoder.encode(content)
23213
+ };
23214
+ });
23215
+ }
23216
+ async function unzip(z) {
23217
+ const u16 = (o) => z[o] | z[o + 1] << 8;
23218
+ const u32 = (o) => (u16(o) | u16(o + 2) << 16) >>> 0;
23219
+ let end = z.length - 22;
23220
+ while (end >= 0 && !(u32(end) === 101010256 && end + 22 + u16(end + 20) === z.length))
23221
+ end--;
23222
+ if (end < 0) throw new Error("not a zip file (no end-of-central-directory)");
23223
+ const out = [];
23224
+ let p = u32(end + 16);
23225
+ let total = 0;
23226
+ const decoder = new TextDecoder();
23227
+ const n = u16(end + 10);
23228
+ if (n > MAX_SITE_FILES) {
23229
+ throw new Error(
23230
+ `zip holds ${n} entries; a site upload is at most ${MAX_SITE_FILES} files`
23231
+ );
23232
+ }
23233
+ for (let i = 0; i < n; i++) {
23234
+ const path = decoder.decode(z.slice(p + 46, p + 46 + u16(p + 28)));
23235
+ const method = u16(p + 10);
23236
+ const size = u32(p + 24);
23237
+ total += size;
23238
+ if (total > MAX_UNZIP_BYTES) {
23239
+ throw new Error(
23240
+ `zip expands past ${MAX_UNZIP_BYTES} bytes; a static site is at most 20 MB`
23241
+ );
23242
+ }
23243
+ const at = u32(p + 42);
23244
+ const start = at + 30 + u16(at + 26) + u16(at + 28);
23245
+ const comp = z.slice(start, start + u32(p + 20));
23246
+ p += 46 + u16(p + 28) + u16(p + 30) + u16(p + 32);
23247
+ if (path.endsWith("/")) continue;
23248
+ let bytes;
23249
+ if (method === 0) bytes = comp;
23250
+ else if (method === 8) {
23251
+ bytes = new Uint8Array(
23252
+ await new Response(
23253
+ new Blob([comp]).stream().pipeThrough(new DecompressionStream("deflate-raw"))
23254
+ ).arrayBuffer()
23255
+ );
23256
+ } else
23257
+ throw new Error(
23258
+ `zip entry '${path}' uses unsupported compression method ${method}`
23259
+ );
23260
+ if (bytes.length !== size) {
23261
+ throw new Error(
23262
+ `zip entry '${path}' declares ${size} bytes but holds ${bytes.length}`
23263
+ );
23264
+ }
23265
+ out.push({ path, bytes });
23266
+ }
23267
+ return out;
23268
+ }
23269
+ var CRC_TABLE = (() => {
23270
+ const t = new Uint32Array(256);
23271
+ for (let n = 0; n < 256; n++) {
23272
+ let c = n;
23273
+ for (let k = 0; k < 8; k++) c = c & 1 ? 3988292384 ^ c >>> 1 : c >>> 1;
23274
+ t[n] = c >>> 0;
23275
+ }
23276
+ return t;
23277
+ })();
23278
+ function crc32(bytes) {
23279
+ let c = 4294967295;
23280
+ for (let i = 0; i < bytes.length; i++)
23281
+ c = CRC_TABLE[(c ^ bytes[i]) & 255] ^ c >>> 8;
23282
+ return (c ^ 4294967295) >>> 0;
23283
+ }
23284
+ function zipStored(files) {
23285
+ const encoder = new TextEncoder();
23286
+ const entries = files.map((f) => ({
23287
+ name: encoder.encode(f.path),
23288
+ bytes: f.bytes,
23289
+ crc: crc32(f.bytes)
23290
+ }));
23291
+ const localSize = entries.reduce(
23292
+ (sum, e) => sum + 30 + e.name.length + e.bytes.length,
23293
+ 0
23294
+ );
23295
+ const centralSize = entries.reduce((sum, e) => sum + 46 + e.name.length, 0);
23296
+ const out = new Uint8Array(localSize + centralSize + 22);
23297
+ const view = new DataView(out.buffer);
23298
+ const UTF8_FLAG = 2048;
23299
+ let p = 0;
23300
+ const offsets = [];
23301
+ for (const e of entries) {
23302
+ offsets.push(p);
23303
+ view.setUint32(p, 67324752, true);
23304
+ view.setUint16(p + 4, 20, true);
23305
+ view.setUint16(p + 6, UTF8_FLAG, true);
23306
+ view.setUint16(p + 8, 0, true);
23307
+ view.setUint32(p + 10, 0, true);
23308
+ view.setUint32(p + 14, e.crc, true);
23309
+ view.setUint32(p + 18, e.bytes.length, true);
23310
+ view.setUint32(p + 22, e.bytes.length, true);
23311
+ view.setUint16(p + 26, e.name.length, true);
23312
+ view.setUint16(p + 28, 0, true);
23313
+ out.set(e.name, p + 30);
23314
+ out.set(e.bytes, p + 30 + e.name.length);
23315
+ p += 30 + e.name.length + e.bytes.length;
23316
+ }
23317
+ const centralStart = p;
23318
+ entries.forEach((e, i) => {
23319
+ view.setUint32(p, 33639248, true);
23320
+ view.setUint16(p + 4, 20, true);
23321
+ view.setUint16(p + 6, 20, true);
23322
+ view.setUint16(p + 8, UTF8_FLAG, true);
23323
+ view.setUint16(p + 10, 0, true);
23324
+ view.setUint32(p + 12, 0, true);
23325
+ view.setUint32(p + 16, e.crc, true);
23326
+ view.setUint32(p + 20, e.bytes.length, true);
23327
+ view.setUint32(p + 24, e.bytes.length, true);
23328
+ view.setUint16(p + 28, e.name.length, true);
23329
+ view.setUint32(p + 42, offsets[i], true);
23330
+ out.set(e.name, p + 46);
23331
+ p += 46 + e.name.length;
23332
+ });
23333
+ view.setUint32(p, 101010256, true);
23334
+ view.setUint16(p + 8, entries.length, true);
23335
+ view.setUint16(p + 10, entries.length, true);
23336
+ view.setUint32(p + 12, p - centralStart, true);
23337
+ view.setUint32(p + 16, centralStart, true);
23338
+ return out;
23339
+ }
23340
+ var isZip = (f) => f.bytes.length >= 4 && f.bytes[0] === 80 && f.bytes[1] === 75 && (f.bytes[2] === 3 && f.bytes[3] === 4 || f.bytes[2] === 5 && f.bytes[3] === 6) || /\.zip$/i.test(f.path);
23341
+ var isRootIndex = (p) => /^index\.html?$/i.test(p);
23342
+ async function expandSiteFiles(input) {
23343
+ const list = [];
23344
+ let bytes = 0;
23345
+ for (const f of input) {
23346
+ const added = isZip(f) ? await unzip(f.bytes) : [f];
23347
+ list.push(...added);
23348
+ bytes += added.reduce((sum, a) => sum + a.bytes.byteLength, 0);
23349
+ if (list.length > MAX_SITE_FILES) {
23350
+ throw new Error(
23351
+ `Too many files (more than ${MAX_SITE_FILES}); a site upload is at most ${MAX_SITE_FILES}.`
23352
+ );
23353
+ }
23354
+ if (bytes > MAX_UNZIP_BYTES) {
23355
+ throw new Error(
23356
+ `The upload expands past ${MAX_UNZIP_BYTES} bytes; send only the site's files.`
23357
+ );
23358
+ }
23359
+ }
23360
+ return list.map((f) => ({
23361
+ ...f,
23362
+ path: f.path.replace(/\\/g, "/").replace(/^\.?\//, "")
23363
+ })).filter(
23364
+ (f) => f.path && !f.path.startsWith("__MACOSX/") && !/(^|\/)\.DS_Store$/.test(f.path) && !f.path.split("/").includes("..")
23365
+ );
23366
+ }
23367
+ function staticSiteFiles(expanded) {
23368
+ let list = expanded;
23369
+ if (list.length === 0) {
23370
+ throw new Error(
23371
+ "No files to upload: pass the site in `files` or `attachments`."
23372
+ );
23373
+ }
23374
+ if (list.length > MAX_SITE_FILES) {
23375
+ throw new Error(
23376
+ `Too many files (${list.length}); a site upload is at most ${MAX_SITE_FILES}.`
23377
+ );
23378
+ }
23379
+ if (!list.some((f) => isRootIndex(f.path))) {
23380
+ const first = list[0].path.split("/")[0];
23381
+ if (list.every((f) => f.path.includes("/") && f.path.split("/")[0] === first)) {
23382
+ list = list.map((f) => ({
23383
+ ...f,
23384
+ path: f.path.split("/").slice(1).join("/")
23385
+ }));
23386
+ }
23387
+ }
23388
+ const rootHtml = list.filter(
23389
+ (f) => !f.path.includes("/") && /\.html?$/i.test(f.path)
23390
+ );
23391
+ if (!list.some((f) => isRootIndex(f.path)) && rootHtml.length === 1) {
23392
+ list = list.map(
23393
+ (f) => f === rootHtml[0] ? { ...f, path: "index.html" } : f
23394
+ );
23395
+ }
23396
+ if (!list.some((f) => isRootIndex(f.path))) {
23397
+ const shown = list.slice(0, 8).map((f) => f.path).join(", ");
23398
+ throw new Error(
23399
+ `The site needs an index.html at its root. Files received: ${shown}${list.length > 8 ? ", \u2026" : ""}`
23400
+ );
23401
+ }
23402
+ return list;
23403
+ }
23404
+ function guessContentType(path) {
23405
+ const ext = (/\.([a-zA-Z0-9]+)$/.exec(path)?.[1] ?? "").toLowerCase();
23406
+ const map = {
23407
+ html: "text/html",
23408
+ htm: "text/html",
23409
+ css: "text/css",
23410
+ js: "text/javascript",
23411
+ mjs: "text/javascript",
23412
+ json: "application/json",
23413
+ svg: "image/svg+xml",
23414
+ txt: "text/plain",
23415
+ md: "text/markdown",
23416
+ xml: "application/xml",
23417
+ webmanifest: "application/manifest+json",
23418
+ ico: "image/x-icon",
23419
+ png: "image/png",
23420
+ jpg: "image/jpeg",
23421
+ jpeg: "image/jpeg",
23422
+ gif: "image/gif",
23423
+ webp: "image/webp",
23424
+ avif: "image/avif",
23425
+ woff: "font/woff",
23426
+ woff2: "font/woff2",
23427
+ ttf: "font/ttf",
23428
+ otf: "font/otf",
23429
+ pdf: "application/pdf",
23430
+ mp4: "video/mp4",
23431
+ webm: "video/webm",
23432
+ mp3: "audio/mpeg"
23433
+ };
23434
+ return map[ext] ?? "application/octet-stream";
23435
+ }
23436
+ function buildFormData(files) {
23437
+ const fd = new FormData();
23438
+ for (const f of files) {
23439
+ fd.append(
23440
+ "files",
23441
+ new Blob([f.bytes], { type: guessContentType(f.path) }),
23442
+ f.path
23443
+ );
23444
+ }
23445
+ return fd;
23446
+ }
23447
+
23448
+ // src/api-call/headless-release.ts
23449
+ var BUILD_METADATA_SUFFIX = ".wix/build-metadata.json";
23450
+ function withoutEmptyStatics(files, build) {
23451
+ const dir = build.clientDir;
23452
+ if (dir === void 0) return { files, dropped: [] };
23453
+ const dropped = [];
23454
+ const kept = files.filter((f) => {
23455
+ const path = normalizePath(f.path);
23456
+ if (f.bytes.byteLength === 0 && path.startsWith(dir)) {
23457
+ dropped.push(path.slice(dir.length));
23458
+ return false;
23459
+ }
23460
+ return true;
23461
+ });
23462
+ return { files: kept, dropped };
23463
+ }
23464
+ var normalizePath = (p) => p.replace(/\\/g, "/").replace(/^\.?\//, "");
23465
+ function findHeadlessBuild(files) {
23466
+ const entries = new Map(files.map((f) => [normalizePath(f.path), f.bytes]));
23467
+ const metadataEntry = [...entries.keys()].find(
23468
+ (name) => name === BUILD_METADATA_SUFFIX || name.endsWith(`/${BUILD_METADATA_SUFFIX}`)
23469
+ );
23470
+ if (metadataEntry === void 0) return null;
23471
+ const zipRoot = metadataEntry.slice(
23472
+ 0,
23473
+ metadataEntry.length - BUILD_METADATA_SUFFIX.length
23474
+ );
23475
+ let metadata;
23476
+ try {
23477
+ metadata = JSON.parse(
23478
+ new TextDecoder().decode(entries.get(metadataEntry))
23479
+ );
23480
+ } catch {
23481
+ throw new Error(`${BUILD_METADATA_SUFFIX} is not valid JSON.`);
23482
+ }
23483
+ if (typeof metadata.appManifestPath !== "string") {
23484
+ throw new Error(
23485
+ `${BUILD_METADATA_SUFFIX} has no appManifestPath; send the build as the Wix hosting adapter wrote it (.wix/ and dist/ zipped from the project root).`
23486
+ );
23487
+ }
23488
+ const manifestPath = resolveZipPath(
23489
+ metadata.appManifestPath,
23490
+ zipRoot,
23491
+ entries
23492
+ );
23493
+ if (manifestPath === void 0) {
23494
+ throw new Error(
23495
+ `The build's app manifest (${metadata.appManifestPath}) is not in the upload; zip .wix/ and dist/ together from the project root after \`astro build\`.`
23496
+ );
23497
+ }
23498
+ const builderRoot = metadata.appManifestPath.slice(
23499
+ 0,
23500
+ metadata.appManifestPath.length - (manifestPath.length - zipRoot.length)
23501
+ );
23502
+ const clientDir = metadata.clientDir === void 0 ? void 0 : toZipDir(metadata.clientDir, builderRoot, zipRoot);
23503
+ const serverDir = metadata.serverDir === void 0 ? void 0 : toZipDir(metadata.serverDir, builderRoot, zipRoot);
23504
+ const clientFiles = [];
23505
+ const serverFiles = [];
23506
+ for (const [name, bytes] of entries) {
23507
+ if (name === manifestPath) continue;
23508
+ if (serverDir !== void 0 && name.startsWith(serverDir)) {
23509
+ serverFiles.push({ path: name.slice(serverDir.length), bytes });
23510
+ } else if (clientDir !== void 0 && name.startsWith(clientDir)) {
23511
+ clientFiles.push({ path: name.slice(clientDir.length), bytes });
23512
+ }
23513
+ }
23514
+ if (clientFiles.length + serverFiles.length === 0) {
23515
+ throw new Error(
23516
+ "The build has no client or server output files; run `astro build` first and zip .wix/ and dist/ from the project root."
23517
+ );
23518
+ }
23519
+ if (serverFiles.length > 0 && !serverFiles.some((f) => f.path === "entry.mjs")) {
23520
+ throw new Error(
23521
+ "The server build has no entry.mjs, which the Wix hosting adapter (@wix/astro-wix-hosting-adapter) writes into the server folder on every build. Build with the project's own `astro build` (the adapter in astro.config) and zip .wix/ and dist/ from the project root as the build left them."
23522
+ );
23523
+ }
23524
+ const manifestText = new TextDecoder().decode(entries.get(manifestPath));
23525
+ return {
23526
+ metadata,
23527
+ root: zipRoot,
23528
+ manifestText,
23529
+ clientFiles,
23530
+ serverFiles,
23531
+ clientDir
23532
+ };
23533
+ }
23534
+ var NOT_SOURCE_TOP = /* @__PURE__ */ new Set(["dist", ".wix", ".astro", ".agents"]);
23535
+ var isSourcePath = (relative) => {
23536
+ const segments = relative.split("/");
23537
+ return !NOT_SOURCE_TOP.has(segments[0]) && !segments.some((s) => s === "node_modules" || s.startsWith(".env"));
23538
+ };
23539
+ function buildSourceFiles(files, build) {
23540
+ return files.flatMap((f) => {
23541
+ const path = normalizePath(f.path);
23542
+ if (!path.startsWith(build.root)) return [];
23543
+ const relative = path.slice(build.root.length);
23544
+ return relative && isSourcePath(relative) ? [{ path: relative, bytes: f.bytes }] : [];
23545
+ });
23546
+ }
23547
+ function resolveZipPath(builderPath, zipRoot, entries) {
23548
+ const segments = normalizePath(builderPath).split("/").filter((s) => s.length > 0);
23549
+ for (let k = 0; k < segments.length; k++) {
23550
+ const candidate = zipRoot + segments.slice(k).join("/");
23551
+ if (entries.has(candidate)) return candidate;
23552
+ }
23553
+ return void 0;
23554
+ }
23555
+ function toZipDir(builderDir, builderRoot, zipRoot) {
23556
+ const normalized = normalizePath(builderDir);
23557
+ const normalizedRoot = normalizePath(builderRoot);
23558
+ const relative = builderDir.startsWith(builderRoot) ? builderDir.slice(builderRoot.length) : normalized.startsWith(normalizedRoot) ? normalized.slice(normalizedRoot.length) : normalized;
23559
+ const dir = zipRoot + normalizePath(relative);
23560
+ return dir.endsWith("/") ? dir : `${dir}/`;
23561
+ }
23562
+
23563
+ // src/infra/redact-personal-data.ts
23564
+ var FREE_TEXT_INFO_PARAMS = [
23565
+ "userRequest",
23566
+ "siteDescription",
23567
+ "siteForm",
23568
+ "siteFunctionality",
23569
+ "agentIdentity",
23570
+ "wixAccess",
23571
+ "reason",
23572
+ "whyNotExecuteWixAPI"
23573
+ ];
23574
+ var EMAIL = /[A-Z0-9._%+-]+@[A-Z0-9-]+(?:\.[A-Z0-9-]+)*\.[A-Z]{2,}/gi;
23575
+ var NAMED_SECRET = /\b(passwords?|passwd|pwd|passcodes?|secrets?|tokens?|api[ _-]?keys?|access[ _-]?keys?|credentials?)(\s*[:=]\s*|\s+(?:is|was|to)\s+)(?:"[^"]*"|'[^']*'|`[^`]*`|[^\s"'`,;][^,;\n]*?(?=[.!?]\s|[,;\n]|$))/gi;
23576
+ var BEARER = /\bBearer\s+[A-Za-z0-9._~+/=-]+/gi;
23577
+ var JWT = /\beyJ[A-Za-z0-9_-]+\.[A-Za-z0-9_-]+\.[A-Za-z0-9_-]+/g;
23578
+ var KEY_PREFIXES = /\b(?:sk-[A-Za-z0-9_-]{16,}|gh[pousr]_[A-Za-z0-9]{20,}|github_pat_\w{20,}|xox[abprs]-[A-Za-z0-9-]{10,}|AKIA[0-9A-Z]{16}|AIza[0-9A-Za-z_-]{35})\b/g;
23579
+ var BACKTICK = "`";
23580
+ var UNIX_ROOT = String.raw`(?<![\w.:/~-])(?:~|/(?:Users|home|root|mnt|tmp|private|var|Volumes|workspace|work))`;
23581
+ var WINDOWS_ROOT = String.raw`(?<!\w)[A-Za-z]:(?=\\\w)`;
23582
+ var PATH_ROOT = `(?:${UNIX_ROOT}|${WINDOWS_ROOT})`;
23583
+ var QUOTED_PATH = new RegExp(
23584
+ String.raw`(?<![\w])(["'${BACKTICK}])${PATH_ROOT}[^"'${BACKTICK}\n]*\1`,
23585
+ "g"
23586
+ );
23587
+ var FOLDER = String.raw`[^\s/\\"'${BACKTICK},;()<>]+(?: [^\s/\\"'${BACKTICK},;()<>]+)*`;
23588
+ var LOCAL_PATH = new RegExp(
23589
+ String.raw`${PATH_ROOT}(?:[/\\]${FOLDER}(?=[/\\]))*[/\\][^\s"'${BACKTICK},;()<>]*`,
23590
+ "g"
23591
+ );
23592
+ var PHONE_CANDIDATE = /(?<![\w-])\+?\(?\d[\d\s().-]{7,}\d(?![\w-])/g;
23593
+ var DATE_START = /^\d{4}-\d{2}-\d{2}/;
23594
+ function redactPhone(match, offset, text) {
23595
+ if (DATE_START.test(match) || /^:\d{2}\b/.test(text.slice(offset + match.length))) {
23596
+ return match;
23597
+ }
23598
+ const digits = match.replace(/\D/g, "").length;
23599
+ return digits >= 9 && digits <= 15 ? "[phone]" : match;
23600
+ }
23601
+ function redactPersonalData(text) {
23602
+ return text.replace(EMAIL, "[email]").replace(BEARER, "Bearer [secret]").replace(JWT, "[secret]").replace(KEY_PREFIXES, "[secret]").replace(NAMED_SECRET, "$1$2[secret]").replace(QUOTED_PATH, "$1[path]$1").replace(LOCAL_PATH, "[path]").replace(PHONE_CANDIDATE, redactPhone);
23603
+ }
23604
+ function redactInfoParams(value) {
23605
+ if (!value || typeof value !== "object" || Array.isArray(value)) {
23606
+ return value;
23607
+ }
23608
+ const record = value;
23609
+ if (!FREE_TEXT_INFO_PARAMS.some((key) => typeof record[key] === "string")) {
23610
+ return value;
23611
+ }
23612
+ const redacted = { ...record };
23613
+ for (const key of FREE_TEXT_INFO_PARAMS) {
23614
+ if (typeof redacted[key] === "string") {
23615
+ redacted[key] = redactPersonalData(redacted[key]);
23616
+ }
23617
+ }
23618
+ return redacted;
23619
+ }
23620
+ function serializeToolParamsForBi(args) {
23621
+ return JSON.stringify(
23622
+ Array.isArray(args) ? args.map(redactInfoParams) : redactInfoParams(args)
23623
+ );
23624
+ }
23625
+
23626
+ // src/api-call/upload-headless-website-files.ts
23627
+ var UPLOAD_HEADLESS_WEBSITE_FILES_TOOL_NAME = "UploadHeadlessWebsiteFiles";
23628
+ var HEADLESS_BUSINESS = "https://www.wixapis.com/headless-business-setup/v1/headless-business";
23629
+ var MAX_BUNDLE_BYTES = 100 * 1024 * 1024;
23630
+ function dropAttribution(clientName) {
23631
+ const slug = (clientName ?? "").toLowerCase().replace(/[^a-z0-9]+/g, "-").replace(/^-+|-+$/g, "").slice(0, 64);
23632
+ return `?campaign=mcp&agent=${encodeURIComponent(slug || "wix-mcp")}`;
23633
+ }
23634
+ var UPLOAD_HEADLESS_WEBSITE_FILES_PARAM_DESCRIPTIONS = {
23635
+ files: "The site files as text, so file bytes never pass through a code string. Sections delimited by a line `=== FILE: <path> ===` (text, raw) or `=== FILE: <path> base64 ===` (binary, base64); `<path>` is relative to the site root; a static site must include `index.html`. Use base64 for small binaries (icons, logos, fonts); large images/video belong behind a URL in the HTML, not in the bundle. Optional when `attachments` carries the files. A Wix Astro build (`.wix/build-metadata.json` and `dist/` as `astro build` with the Wix hosting adapter wrote them, zipped from the project root) needs no `index.html`: it is released to the site's Wix hosting instead of dropped, and the project's other files in the upload are stored as its source when the site's repository accepts it.",
23636
+ attachments: fileParamNote(
23637
+ "for a static site use `files`, or drop the files as the StartDeployWebsite recipe shows; for a Wix Astro build from a shell that reaches the internet, zip it, call with `prepare: true` and its `size` and PUT the zips with curl"
23638
+ ) + " Any type: a zip of the whole site, HTML, CSS, JS, images. A zip is unpacked; a top-level folder wrapping the site is stripped. A Wix Astro build zipped with the whole project (minus `node_modules`) is released with its source stored when the site's repository accepts it. Prefer this over base64 in `files` whenever you have a file handle. Up to 10 MB per call.",
23639
+ prepare: "Phase one of the two-call upload of a Wix Astro build, for a shell that reaches the internet and no file handle (a sandbox whose network is limited to a few hosts cannot upload to the URLs): zip the build first, then `true` with its `size` returns presigned upload URLs for the build zip and, when the site's repository takes it, the project source zip, as `curl` commands to run verbatim, with the exact second call. The two calls: {siteId, prepare: true, size}, then {siteId, uploadKey, sourceUploadId?, expectedHeadRevisionId?, releaseNotes?}. No `files`, `attachments`, `uploadKey` or `sourceUploadId` on the first; `expectedHeadRevisionId` and `releaseNotes` given on the first are echoed into the second. Not for a static site: send its files in `files` or `attachments`, or drop them as the StartDeployWebsite recipe shows.",
23640
+ size: `Phase one, with \`prepare: true\` only, and required there: the build zip's length in bytes (\`wc -c < build.zip\`), 1 to ${MAX_BUNDLE_BYTES} (100 MB). The upload URL takes a body of exactly this length; a zip changed after the prepare needs a new prepare.`,
23641
+ uploadKey: "Phase two of the two-call upload: the `uploadKey` the `prepare` call returned, after the build zip was PUT to its URL. Releases that build to the site: {siteId, uploadKey, sourceUploadId?, expectedHeadRevisionId?, releaseNotes?}. Excludes `files` and `attachments`.",
23642
+ sourceUploadId: "Phase two: the `sourceUploadId` the `prepare` call returned, after the source zip was PUT to its URL. Stores the project source with the release. Needs `uploadKey`; leave it out when the prepare returned no source upload.",
23643
+ expectedHeadRevisionId: "The repository revision your project started from, so the source replaces only that and a commit made since (another chat, a Dev Machine) is never dropped unseen: the revision you downloaded the project at; for a project started here, the `headRevisionId` the `prepare` call returned. Leave it out only for a repository with nothing in it yet. Goes with `uploadKey`, or with `files`/`attachments` holding a build.",
23644
+ releaseNotes: "Optional: one line on what this release changes, at most 200 characters, kept with the deployment of a Wix Astro build, whether it comes in `files`/`attachments` or as the second call with `uploadKey` (given on the `prepare` call it is echoed into the second). A static drop keeps no notes.",
23645
+ siteId: "The metaSiteId of the Wix Headless site to upload into: the one returned by the provision call of the StartDeployWebsite recipe for a new site, or of a site deployed earlier to replace its files. Every upload replaces the whole file set, so send all files; the URL stays the same. A build released here replaces static pages dropped earlier, at the same URL.",
23646
+ calledStartDeployWebsite: "Whether you called StartDeployWebsite earlier in this conversation and are following the recipe it returned. Answer truthfully; it is recorded, not checked.",
23647
+ agentIdentity: START_DEPLOY_WEBSITE_PARAM_DESCRIPTIONS.agentIdentity,
23648
+ reason: `One sentence: the user request that led here and what is being published. ${NO_PERSONAL_DATA}`
23649
+ };
23650
+ var UPLOAD_RECIPE_SKILL_URL = "https://www.wix.com/skills/wix-manage/references/sites/upload-static-site.md";
23651
+ var DOMAIN_RECIPE_SKILL_URL = "https://www.wix.com/skills/wix-manage/references/domains/domain-search-purchase-and-connect.md";
23652
+ function formatDropResult(r) {
23653
+ const shown = r.files.slice(0, 60);
23654
+ return [
23655
+ "Uploaded; the site is live with this file set.",
23656
+ `Live URL: ${r.siteUrl ?? "(not returned)"}`,
23657
+ `metaSiteId: ${r.metaSiteId} \u2014 pass it as \`siteId\` to update this site later; every upload replaces the whole file set.`,
23658
+ `Dashboard: https://manage.wix.com/dashboard/${r.metaSiteId}`,
23659
+ `${r.files.length} file(s): ${shown.join(", ")}${r.files.length > shown.length ? ", \u2026" : ""}`,
23660
+ "",
23661
+ `Give the user both links, each on its own line and named for what it is: the live site, and the site's dashboard. Then offer a custom domain, bought through Wix or one they already own (${DOMAIN_RECIPE_SKILL_URL}).`,
23662
+ "",
23663
+ `- To change this site later: "Change it later" in ${UPLOAD_RECIPE_SKILL_URL}, with this metaSiteId (${r.metaSiteId}). The same site every time, never a new one.`,
23664
+ `- Wix business features (${WIX_BUSINESS_FEATURES}): call StartHeadlessBuild with startingPoint "an existing Wix Headless site"; this site is one.`
23665
+ ].join("\n");
23666
+ }
23667
+ function curlPut(zipName, put, fallback) {
23668
+ const headers = Object.entries(
23669
+ put.headers && Object.keys(put.headers).length ? put.headers : fallback
23670
+ );
23671
+ return [
23672
+ "curl -X PUT",
23673
+ ...headers.map(([k, v]) => `-H "${k}: ${v}"`),
23674
+ `--data-binary @${zipName} "${put.putUrl}"`
23675
+ ].join(" ");
23676
+ }
23677
+ var BUILD_ZIP_CONTENTS = "Build zip, from the project root after `astro build` with the Wix hosting adapter: `dist/` (with `dist/_wix/app-manifest.json`) and `.wix/build-metadata.json`.";
23678
+ var SOURCE_ZIP_CONTENTS = "Source zip, from the project root: the project minus `node_modules`, `dist`, `.wix`, `.astro`, `.env*` and `.agents`.";
23679
+ function formatPrepareResult(siteId, urls, size, given = {}) {
23680
+ const expiry = urls.expiresAt ? ` They expire at ${urls.expiresAt}.` : "";
23681
+ const secondCall = {
23682
+ siteId,
23683
+ uploadKey: urls.uploadKey
23684
+ };
23685
+ const zipHeaders = {
23686
+ "content-type": "application/zip",
23687
+ ...size ? { "content-length": String(size) } : {}
23688
+ };
23689
+ const lines = [
23690
+ `Upload URLs ready for site ${siteId}.${expiry} Two steps, then call this tool again.`,
23691
+ "",
23692
+ `1. ${BUILD_ZIP_CONTENTS} Upload the zip you measured${size ? ` (${size} bytes)` : ""}; the URL takes a body of exactly that length, so a zip changed since needs a new prepare with its size:`,
23693
+ ` ${curlPut("build.zip", urls, zipHeaders)}`
23694
+ ];
23695
+ if (given.expectedHeadRevisionId)
23696
+ secondCall.expectedHeadRevisionId = given.expectedHeadRevisionId;
23697
+ if (urls.source) {
23698
+ const s = urls.source;
23699
+ secondCall.sourceUploadId = s.uploadId;
23700
+ if (!secondCall.expectedHeadRevisionId && s.headRevisionId)
23701
+ secondCall.expectedHeadRevisionId = s.headRevisionId;
23702
+ lines.push(
23703
+ "",
23704
+ `2. ${SOURCE_ZIP_CONTENTS} Upload it:`,
23705
+ ` ${curlPut("source.zip", s, { "content-type": "application/zip" })}`,
23706
+ ...s.expiresAt && s.expiresAt !== urls.expiresAt ? [` This URL expires at ${s.expiresAt}.`] : [],
23707
+ ...s.headRevisionId ? [
23708
+ ` The repository's head revision is ${s.headRevisionId}. The second call passes \`expectedHeadRevisionId\`: this head for a project started here; if you downloaded the project from the repository, the revision you downloaded it at instead, so a commit made since is never dropped.`
23709
+ ] : []
23710
+ );
23711
+ } else {
23712
+ lines.push(
23713
+ "",
23714
+ "2. The site's repository takes no source this time: the project's source is not uploaded, and the second call carries no `sourceUploadId`."
23715
+ );
23716
+ }
23717
+ if (given.releaseNotes)
23718
+ secondCall.releaseNotes = releaseNotesForService(given.releaseNotes);
23719
+ lines.push(
23720
+ "",
23721
+ `3. Call UploadHeadlessWebsiteFiles again with ${JSON.stringify(secondCall)} (plus \`calledStartDeployWebsite\`, \`agentIdentity\`, \`reason\`). No \`files\` or \`attachments\` on that call.`
23722
+ );
23723
+ return lines.join("\n");
23724
+ }
23725
+ function formatBundleReleaseResult(siteId, r, notes = []) {
23726
+ return [
23727
+ "Released; the site is live.",
23728
+ `Live URL: ${r.siteUrl ?? "(not returned)"}`,
23729
+ `metaSiteId: ${siteId} \u2014 pass it as \`siteId\` to release this site again, the same way. The URL stays.`,
23730
+ `Dashboard: https://manage.wix.com/dashboard/${siteId}`,
23731
+ `Deployment ${r.deploymentId ?? "(id not returned)"}.${r.revision?.id ? ` Source stored as revision ${r.revision.id}.` : ""}`,
23732
+ ...notes,
23733
+ "",
23734
+ "This release replaced whatever the site served before, at the same URL. A change to the site is a change to the project: edit, build if it is an Astro project, upload again.",
23735
+ "Give the user both links, each on its own line and named for what it is: the live site, and the site's dashboard."
23736
+ ].join("\n");
23737
+ }
23738
+ var startOver = (retry) => retry === "prepare" ? "call with `prepare: true` and the zip's `size` again, upload the zips to the new URLs, and release with the new `uploadKey`" : "call this tool again with the same files";
23739
+ var apiBody = (err) => err.response.data ? ` (${err.response.data.slice(0, 300)})` : "";
23740
+ function describeBundleUploadUrlError(err) {
23741
+ if (!(err instanceof WixFetchError)) {
23742
+ return err instanceof Error ? err.message : String(err);
23743
+ }
23744
+ const body = apiBody(err);
23745
+ switch (err.status) {
23746
+ case 400:
23747
+ return `The upload URL was refused: \`size\` is the build zip's length in bytes, an integer from 1 to ${MAX_BUNDLE_BYTES} (100 MB). A larger build: leave out what the site does not serve (source maps, unused assets).${body}`;
23748
+ case 429:
23749
+ return `Too many unreleased uploads are waiting for this site: release one with its \`uploadKey\`, or wait for a running release to finish, then ask again.${body}`;
23750
+ default:
23751
+ return err.message;
23752
+ }
23753
+ }
23754
+ function deployAuthorization(siteHeaders) {
23755
+ const authorization = siteHeaders.Authorization ?? siteHeaders.authorization;
23756
+ return authorization ? { deployAuthorization: authorization } : {};
23757
+ }
23758
+ var RELEASE_NOTES_MAX_CHARS = 200;
23759
+ function releaseNotesForService(notes) {
23760
+ const chars = [...notes.replace(/\s+/g, " ").trim()];
23761
+ return chars.length <= RELEASE_NOTES_MAX_CHARS ? chars.join("") : `${chars.slice(0, RELEASE_NOTES_MAX_CHARS - 1).join("").trimEnd()}\u2026`;
23762
+ }
23763
+ function describeBundleReleaseError(err, uploadKey, retry = "prepare") {
23764
+ if (!(err instanceof WixFetchError)) {
23765
+ return err instanceof Error ? err.message : String(err);
23766
+ }
23767
+ const body = apiBody(err);
23768
+ const code = err.response.data ?? "";
23769
+ switch (err.status) {
23770
+ case 404:
23771
+ return `Nothing uploaded for uploadKey ${uploadKey}: the build zip was not PUT to its URL, or the URL expired. To try again, ${startOver(retry)}.${body}`;
23772
+ case 409:
23773
+ return `The project's source repository moved since the upload URLs were made; nothing was released. ${retry === "prepare" ? "Call with `prepare: true` and the zip's `size` again, re-upload the source zip to the new URL, and release with the new `uploadKey`, `sourceUploadId` and `expectedHeadRevisionId`." : "Download the project again from the repository, carry your change over, and upload with `expectedHeadRevisionId` set to the revision you downloaded."}${body}`;
23774
+ case 403:
23775
+ return `Wix refused to deploy this build onto the site's project; nothing was released, and the same call will be refused again. Do not call \`prepare\` again. Tell the user the release is blocked on Wix's side and give them the request id from the error.${body}`;
23776
+ case 413:
23777
+ case 428:
23778
+ return `The build's server code is larger than the release can carry from here; nothing was released. Do not call \`prepare\` again. Tell the user the release is blocked on Wix's side and give them the request id from the error.${body}`;
23779
+ case 400:
23780
+ if (code.includes("EXPECTED_HEAD_REQUIRED")) {
23781
+ return `The site's repository already holds work, and the source replaces only what you started from; nothing was released. ${retry === "prepare" ? "Call with `prepare: true` and the zip's `size` again and pass the `headRevisionId` it returns as `expectedHeadRevisionId` (with its new `uploadKey` and `sourceUploadId`)." : "Call again with `expectedHeadRevisionId`: the revision you downloaded the project at, so the source replaces only that. To replace the repository with this upload on purpose, pass its current head."}${body}`;
23782
+ }
23783
+ if (code.includes("BUNDLE_TOO_LARGE")) {
23784
+ return `The build zip is over ${MAX_BUNDLE_BYTES} bytes (100 MB): leave out what the site does not serve (source maps, unused assets), then ${startOver(retry)}.${body}`;
23785
+ }
23786
+ if (code.includes("INVALID_RELEASE")) {
23787
+ return `The release was refused by Wix's deployment service; nothing was released. The staged upload is kept: call again with the same \`uploadKey\` and the field the message names fixed (release notes are cut to ${RELEASE_NOTES_MAX_CHARS} characters here).${body}`;
23788
+ }
23789
+ if (code.includes("INVALID_UPLOAD_KEY")) {
23790
+ return `\`uploadKey\` is the lowercase UUID the \`prepare\` call returned; pass it as it came.${body}`;
23791
+ }
23792
+ return `The uploaded zip was not accepted. Zip \`dist/\` and \`.wix/build-metadata.json\` from the project root after \`astro build\` with the Wix hosting adapter, then ${startOver(retry)}. A static site goes in \`files\` or \`attachments\` instead, or is dropped as the StartDeployWebsite recipe shows.${body}`;
23793
+ default:
23794
+ if (err.status >= 500) {
23795
+ const what = err.status === 503 ? "The release could not hold its upload" : `Wix's release step failed on its side (HTTP ${err.status})`;
23796
+ return `${what}; nothing was released. The staged upload is kept under uploadKey ${uploadKey}, so do not call \`prepare\` again and do not send the files again: every upload staged and not released counts against the site, which refuses new ones after a few. Retry once, after a minute, by calling with \`uploadKey: "${uploadKey}"\`${retry === "resend" ? " (plus the `expectedHeadRevisionId` and `releaseNotes` you passed, if any; the source is stored with the next release)" : " and the same ids and `releaseNotes`"}. If that fails too, stop and tell the user the release is blocked on Wix's side, with the request id from the error.${body}`;
23797
+ }
23798
+ return err.message;
23799
+ }
23800
+ }
23801
+ function validateBundleArgs(a) {
23802
+ const hasContent = !!a.files?.trim() || !!(a.attachments && a.attachments.length);
23803
+ if (a.prepare) {
23804
+ if (hasContent || a.uploadKey || a.sourceUploadId) {
23805
+ return "`prepare: true` goes with `siteId` and `size`: no `files`, `attachments`, `uploadKey` or `sourceUploadId` on that call. Example: {siteId, prepare: true, size}, then {siteId, uploadKey, sourceUploadId?, expectedHeadRevisionId?, releaseNotes?}.";
23806
+ }
23807
+ if (a.size === void 0) {
23808
+ return "`prepare: true` needs `size`: zip the build first and pass the zip's length in bytes (`wc -c < build.zip`).";
23809
+ }
23810
+ if (!Number.isInteger(a.size) || a.size < 1 || a.size > MAX_BUNDLE_BYTES) {
23811
+ return `\`size\` is the build zip's length in bytes, an integer from 1 to ${MAX_BUNDLE_BYTES} (100 MB); got ${a.size}.`;
23812
+ }
23813
+ return null;
23814
+ }
23815
+ if (a.size !== void 0) {
23816
+ return "`size` goes only with `prepare: true`: it is the length of the build zip that call makes an upload URL for.";
23817
+ }
23818
+ if (a.uploadKey) {
23819
+ if (hasContent) {
23820
+ return "`uploadKey` releases a build zip already uploaded to its URL: pass no `files` or `attachments` with it.";
23821
+ }
23822
+ return null;
23823
+ }
23824
+ if (a.sourceUploadId) {
23825
+ return "`sourceUploadId` goes with the `uploadKey` the `prepare` call returned.";
23826
+ }
23827
+ if (a.expectedHeadRevisionId && !hasContent) {
23828
+ return "`expectedHeadRevisionId` goes with `uploadKey`, or with `files`/`attachments` holding a build.";
23829
+ }
23830
+ return null;
23831
+ }
23832
+ async function readJson(res, what) {
23833
+ const text = await res.text();
23834
+ if (!res.ok)
23835
+ throw new WixFetchError(res.status, res.statusText, `${what}: ${text}`);
23836
+ try {
23837
+ return JSON.parse(text);
23838
+ } catch {
23839
+ throw new Error(`${what} returned a non-JSON body: ${text.slice(0, 200)}`);
23840
+ }
23841
+ }
23842
+ async function putZip(fetchImpl, put, bytes, what) {
23843
+ const headers = Object.fromEntries(
23844
+ Object.entries(put.headers ?? { "content-type": "application/zip" }).filter(
23845
+ ([k]) => k.toLowerCase() !== "content-length"
23846
+ )
23847
+ );
23848
+ const res = await fetchImpl(put.putUrl, {
23849
+ method: "PUT",
23850
+ headers,
23851
+ body: bytes
23852
+ });
23853
+ if (!res.ok) {
23854
+ const text = await res.text().catch(() => "");
23855
+ throw new Error(
23856
+ `The ${what} upload was refused (${res.status}${text ? `: ${text.slice(0, 200)}` : ""}); call this tool again with the same files.`
23857
+ );
23858
+ }
23859
+ }
23860
+ async function releaseBuildByUrl(o) {
23861
+ const log = o.log ?? (() => {
23862
+ });
23863
+ const headers = { ...o.siteHeaders, "Content-Type": "application/json" };
23864
+ const urls = await readJson(
23865
+ await o.fetchImpl(`${HEADLESS_BUSINESS}/${o.siteId}/bundle-upload-url`, {
23866
+ method: "POST",
23867
+ headers,
23868
+ body: JSON.stringify({ size: o.siteZip.byteLength })
23869
+ }),
23870
+ "bundle-upload-url"
23871
+ );
23872
+ if (!urls.uploadKey || !urls.putUrl) {
23873
+ throw new Error("bundle-upload-url returned no uploadKey or putUrl.");
23874
+ }
23875
+ await putZip(o.fetchImpl, urls, o.siteZip, "site zip");
23876
+ o.onStaged?.(urls.uploadKey);
23877
+ log(
23878
+ `staged ${urls.uploadKey} (${o.siteZip.byteLength} bytes), source ${urls.source ? `offered, ${o.sourceFiles.length} file(s)` : "not offered"}`
23879
+ );
23880
+ const source = urls.source && o.sourceFiles.length > 0 ? urls.source : void 0;
23881
+ if (source) {
23882
+ await putZip(o.fetchImpl, source, zipStored(o.sourceFiles), "source zip");
23883
+ }
23884
+ return await readJson(
23885
+ await o.fetchImpl(`${HEADLESS_BUSINESS}/${o.siteId}/release-bundle`, {
23886
+ method: "POST",
23887
+ headers,
23888
+ body: JSON.stringify({
23889
+ uploadKey: urls.uploadKey,
23890
+ ...deployAuthorization(o.siteHeaders),
23891
+ ...o.releaseNotes ? { releaseNotes: releaseNotesForService(o.releaseNotes) } : {},
23892
+ ...source ? {
23893
+ sourceUploadId: source.uploadId,
23894
+ ...o.expectedHeadRevisionId ? { expectedHeadRevisionId: o.expectedHeadRevisionId } : {}
23895
+ } : {}
23896
+ })
23897
+ }),
23898
+ "release-bundle"
23899
+ );
23900
+ }
23901
+ function errorResult2(message) {
23902
+ return {
23903
+ isError: true,
23904
+ content: [
23905
+ {
23906
+ type: "text",
23907
+ text: `UploadHeadlessWebsiteFiles error: ${message}`
23908
+ }
23909
+ ]
23910
+ };
23911
+ }
23912
+ function addUploadHeadlessWebsiteFilesTool(server, options) {
23913
+ const { authStrategy, toolDescriptions } = options;
23914
+ const clientName = () => options.clientName ?? server.clientName?.() ?? server.server?.getClientVersion?.()?.name;
23915
+ const fetchImpl = options.fetchImpl ?? ((u, i) => fetch(u, i));
23916
+ const d = UPLOAD_HEADLESS_WEBSITE_FILES_PARAM_DESCRIPTIONS;
23917
+ const registered = server.tool(
23918
+ UPLOAD_HEADLESS_WEBSITE_FILES_TOOL_NAME,
23919
+ toolDescriptions?.[UPLOAD_HEADLESS_WEBSITE_FILES_TOOL_NAME] ?? defaultToolDescriptions.UploadHeadlessWebsiteFiles,
23920
+ {
23921
+ files: external_exports.string().optional().describe(d.files),
23922
+ attachments: external_exports.array(
23923
+ external_exports.object({
23924
+ download_url: external_exports.string(),
23925
+ file_id: external_exports.string(),
23926
+ file_name: external_exports.string().optional(),
23927
+ mime_type: external_exports.string().optional()
23928
+ })
23929
+ ).optional().describe(d.attachments),
23930
+ prepare: external_exports.boolean().optional().describe(d.prepare),
23931
+ size: external_exports.number().int().optional().describe(d.size),
23932
+ uploadKey: external_exports.string().min(1).optional().describe(d.uploadKey),
23933
+ sourceUploadId: external_exports.string().min(1).optional().describe(d.sourceUploadId),
23934
+ expectedHeadRevisionId: external_exports.string().min(1).optional().describe(d.expectedHeadRevisionId),
23935
+ releaseNotes: external_exports.string().optional().describe(d.releaseNotes),
23936
+ siteId: external_exports.string().uuid("siteId must be a Wix metaSiteId (UUID)").describe(d.siteId),
23937
+ calledStartDeployWebsite: external_exports.boolean().describe(d.calledStartDeployWebsite),
23938
+ agentIdentity: external_exports.string().min(1).describe(d.agentIdentity),
23939
+ reason: external_exports.string().describe(d.reason)
23940
+ },
23941
+ // openWorldHint true: it fetches agent-supplied attachment URLs and publishes a
23942
+ // public website.
23943
+ { readOnlyHint: false, destructiveHint: true, openWorldHint: true },
23944
+ async (rawArgs, extra) => {
23945
+ const {
23946
+ files,
23947
+ attachments,
23948
+ prepare,
23949
+ size,
23950
+ uploadKey,
23951
+ sourceUploadId,
23952
+ expectedHeadRevisionId,
23953
+ releaseNotes,
23954
+ siteId,
23955
+ calledStartDeployWebsite,
23956
+ agentIdentity,
23957
+ reason
23958
+ } = rawArgs;
23959
+ const phase = prepare ? "prepare" : uploadKey ? "release-bundle" : "files";
23960
+ logger.log(
23961
+ `[UploadHeadlessWebsiteFiles] siteId=${siteId} phase=${phase} calledStartDeployWebsite=${calledStartDeployWebsite} agent="${redactPersonalData(agentIdentity)}" files=${files?.length ?? 0} chars attachments=${attachments?.length ?? 0} reason="${redactPersonalData(reason)}"`
23962
+ );
23963
+ const invalid = validateBundleArgs(rawArgs);
23964
+ if (invalid) return errorResult2(invalid);
23965
+ if (prepare || uploadKey) {
23966
+ const siteHeaders = await authStrategy.getSiteAuthHeaders(siteId);
23967
+ const headers = {
23968
+ ...siteHeaders,
23969
+ "Content-Type": "application/json"
23970
+ };
23971
+ try {
23972
+ extra?.setToolBiParams?.({ siteId });
23973
+ if (prepare) {
23974
+ const urls = await readJson(
23975
+ await fetchImpl(
23976
+ `${HEADLESS_BUSINESS}/${siteId}/bundle-upload-url`,
23977
+ {
23978
+ method: "POST",
23979
+ headers,
23980
+ body: JSON.stringify({ size })
23981
+ }
23982
+ ),
23983
+ "bundle-upload-url"
23984
+ );
23985
+ if (!urls.uploadKey || !urls.putUrl) {
23986
+ throw new Error(
23987
+ "bundle-upload-url returned no uploadKey or putUrl."
23988
+ );
23989
+ }
23990
+ extra?.setToolBiParams?.({
23991
+ siteId,
23992
+ upload: { path: "prepare", sourceOffered: Boolean(urls.source) }
23993
+ });
23994
+ return {
23995
+ content: [
23996
+ {
23997
+ type: "text",
23998
+ text: formatPrepareResult(siteId, urls, size, {
23999
+ expectedHeadRevisionId,
24000
+ releaseNotes
24001
+ })
24002
+ }
24003
+ ]
24004
+ };
24005
+ }
24006
+ const released = await readJson(
24007
+ await fetchImpl(`${HEADLESS_BUSINESS}/${siteId}/release-bundle`, {
24008
+ method: "POST",
24009
+ headers,
24010
+ body: JSON.stringify({
24011
+ uploadKey,
24012
+ ...deployAuthorization(siteHeaders),
24013
+ ...sourceUploadId ? { sourceUploadId } : {},
24014
+ ...expectedHeadRevisionId ? { expectedHeadRevisionId } : {},
24015
+ ...releaseNotes ? { releaseNotes: releaseNotesForService(releaseNotes) } : {}
24016
+ })
24017
+ }),
24018
+ "release-bundle"
24019
+ );
24020
+ extra?.setToolBiParams?.({
24021
+ siteId,
24022
+ upload: {
24023
+ path: "release-bundle",
24024
+ sourceStored: Boolean(released.revision?.id)
24025
+ }
24026
+ });
24027
+ return {
24028
+ content: [
24029
+ {
24030
+ type: "text",
24031
+ text: formatBundleReleaseResult(siteId, released)
24032
+ }
24033
+ ]
24034
+ };
24035
+ } catch (err) {
24036
+ const message = err instanceof Error ? err.message : String(err);
24037
+ logger.log(`[UploadHeadlessWebsiteFiles] ${phase} error: ${message}`);
24038
+ rethrowIfUnauthorized(err);
24039
+ await authStrategy.enforceValidWixToken?.(err);
24040
+ return errorResult2(
24041
+ uploadKey ? describeBundleReleaseError(err, uploadKey) : describeBundleUploadUrlError(err)
24042
+ );
24043
+ }
24044
+ }
24045
+ if (!files?.trim() && !(attachments && attachments.length)) {
24046
+ return errorResult2(
24047
+ "Nothing to publish: pass the site in `files` (text bundle) or `attachments` (files from this chat or your sandbox), or, for a Wix Astro build from a shell that reaches the internet, zip it and call with `prepare: true` and its `size`."
24048
+ );
24049
+ }
24050
+ let siteFiles = [];
24051
+ let uploaded = [];
24052
+ let given = [];
24053
+ let build = null;
24054
+ try {
24055
+ const fromAttachments = (await resolveAttachments(attachments, fetchImpl)).map((a) => ({ path: a.path, bytes: base64ToBytes(a.content) }));
24056
+ given = [...parseFileBundle(files), ...fromAttachments];
24057
+ uploaded = await expandSiteFiles(given);
24058
+ build = findHeadlessBuild(uploaded);
24059
+ if (!build) siteFiles = staticSiteFiles(uploaded);
24060
+ } catch (e) {
24061
+ if (e instanceof AttachmentError || e instanceof Error)
24062
+ return errorResult2(e.message);
24063
+ throw e;
24064
+ }
24065
+ if (!build && expectedHeadRevisionId) {
24066
+ return errorResult2(
24067
+ "`expectedHeadRevisionId` applies to a Wix Astro build, whose source is stored in the site's repository; these files are a static site, which has none. Call again without it."
24068
+ );
24069
+ }
24070
+ if (build) {
24071
+ const siteHeaders = await authStrategy.getSiteAuthHeaders(siteId);
24072
+ let stagedKey;
24073
+ try {
24074
+ extra?.setToolBiParams?.({ siteId });
24075
+ const sourceFiles = buildSourceFiles(uploaded, build);
24076
+ const statics = withoutEmptyStatics(uploaded, build);
24077
+ const released = await releaseBuildByUrl({
24078
+ siteId,
24079
+ // One zip as given goes as is; anything else is zipped from the expanded files.
24080
+ siteZip: given.length === 1 && isZip(given[0]) && statics.dropped.length === 0 ? given[0].bytes : zipStored(statics.files),
24081
+ sourceFiles,
24082
+ expectedHeadRevisionId,
24083
+ releaseNotes,
24084
+ siteHeaders,
24085
+ fetchImpl,
24086
+ onStaged: (key) => {
24087
+ stagedKey = key;
24088
+ },
24089
+ log: (line) => logger.log(`[UploadHeadlessWebsiteFiles] release ${line}`)
24090
+ });
24091
+ const sourceStored = Boolean(released.revision?.id);
24092
+ extra?.setToolBiParams?.({
24093
+ siteId,
24094
+ upload: {
24095
+ path: "build",
24096
+ sourceStored,
24097
+ sourceFiles: sourceFiles.length,
24098
+ emptyStaticsDropped: statics.dropped.length
24099
+ }
24100
+ });
24101
+ const notes = [
24102
+ ...statics.dropped.length ? [
24103
+ `Left out, empty: ${statics.dropped.slice(0, 20).join(", ")} (the hosting serves no file of size 0).`
24104
+ ] : [],
24105
+ ...sourceStored ? [] : [
24106
+ sourceFiles.length ? "The project's source was not stored: the site's repository took none this time." : "The project's source was not stored: the upload held only the build. A later chat can continue this site only from its source; next time zip the whole project from its root, leaving out node_modules, .env files and the caches."
24107
+ ]
24108
+ ];
24109
+ return {
24110
+ content: [
24111
+ {
24112
+ type: "text",
24113
+ text: formatBundleReleaseResult(siteId, released, notes)
24114
+ }
24115
+ ]
24116
+ };
24117
+ } catch (err) {
24118
+ const message = err instanceof Error ? err.message : String(err);
24119
+ logger.log(`[UploadHeadlessWebsiteFiles] release error: ${message}`);
24120
+ rethrowIfUnauthorized(err);
24121
+ await authStrategy.enforceValidWixToken?.(err);
24122
+ return errorResult2(
24123
+ stagedKey ? describeBundleReleaseError(err, stagedKey, "resend") : describeBundleUploadUrlError(err)
24124
+ );
24125
+ }
24126
+ }
24127
+ const authHeaders = await authStrategy.getAccountAuthHeaders();
24128
+ try {
24129
+ const metaSiteId = siteId;
24130
+ extra?.setToolBiParams?.({ siteId: metaSiteId });
24131
+ const dropped = await readJson(
24132
+ await fetchImpl(
24133
+ `${HEADLESS_BUSINESS}/${metaSiteId}/drop${dropAttribution(clientName())}`,
24134
+ {
24135
+ method: "POST",
24136
+ headers: { ...authHeaders },
24137
+ // fetch sets the multipart boundary itself
24138
+ body: buildFormData(siteFiles)
24139
+ }
24140
+ ),
24141
+ "drop"
24142
+ );
24143
+ extra?.setToolBiParams?.({
24144
+ siteId: metaSiteId,
24145
+ upload: { path: "drop", files: siteFiles.length }
24146
+ });
24147
+ return {
24148
+ content: [
24149
+ {
24150
+ type: "text",
24151
+ text: formatDropResult({
24152
+ metaSiteId,
24153
+ siteUrl: dropped.siteUrl,
24154
+ uploadId: dropped.uploadId,
24155
+ files: siteFiles.map((f) => f.path)
24156
+ }) + (releaseNotes ? "\n\nRelease notes are kept for a Wix Astro build only; a static drop has none, so yours were not stored." : "")
24157
+ }
24158
+ ]
24159
+ };
24160
+ } catch (err) {
24161
+ const message = err instanceof Error ? err.message : String(err);
24162
+ logger.log(`[UploadHeadlessWebsiteFiles] Error: ${message}`);
24163
+ rethrowIfUnauthorized(err);
24164
+ await authStrategy.enforceValidWixToken?.(err);
24165
+ return errorResult2(message);
24166
+ }
24167
+ }
24168
+ );
24169
+ registered?.update?.({
24170
+ _meta: { ...registered._meta, "openai/fileParams": ["attachments"] }
24171
+ });
24172
+ }
24173
+
22504
24174
  // src/code-mode/index.ts
22505
24175
  var defaultCodeModeFetch = (url, init) => fetch(url, init);
22506
24176
  var SEARCH_TOOL_NAME = "SearchWixAPISpec";
@@ -22512,7 +24182,8 @@ function addSearchCodeModeTool(server, options) {
22512
24182
  authStrategy,
22513
24183
  disableTools = [],
22514
24184
  toolDescriptions,
22515
- maxResponseSize
24185
+ maxResponseSize,
24186
+ docsSite
22516
24187
  } = options;
22517
24188
  if (disableTools.includes(SEARCH_TOOL_NAME)) {
22518
24189
  return;
@@ -22524,7 +24195,8 @@ function addSearchCodeModeTool(server, options) {
22524
24195
  description,
22525
24196
  maxResponseSize,
22526
24197
  authStrategy,
22527
- codeModeFetch
24198
+ codeModeFetch,
24199
+ docsSite
22528
24200
  );
22529
24201
  }
22530
24202
  function addExecuteCodeModeTool(server, options) {
@@ -22550,6 +24222,7 @@ function addExecuteCodeModeTool(server, options) {
22550
24222
  });
22551
24223
  }
22552
24224
  var SEARCH_MAX_RESPONSE_CHARS = 64e3;
24225
+ var EXECUTE_MAX_RESPONSE_CHARS = 1e5;
22553
24226
  async function resolveLoopbackAuthorization(authStrategy) {
22554
24227
  try {
22555
24228
  return (await authStrategy?.getAccountAuthHeaders())?.Authorization;
@@ -22557,7 +24230,7 @@ async function resolveLoopbackAuthorization(authStrategy) {
22557
24230
  return void 0;
22558
24231
  }
22559
24232
  }
22560
- function registerSearchTool(server, codeModeBaseUrl, description, maxResponseSize, authStrategy, codeModeFetch = defaultCodeModeFetch) {
24233
+ function registerSearchTool(server, codeModeBaseUrl, description, maxResponseSize, authStrategy, codeModeFetch = defaultCodeModeFetch, docsSite) {
22561
24234
  const searchUrl = `${codeModeBaseUrl}/api/code-mode/search`;
22562
24235
  server.tool(
22563
24236
  SEARCH_TOOL_NAME,
@@ -22583,7 +24256,8 @@ function registerSearchTool(server, codeModeBaseUrl, description, maxResponseSiz
22583
24256
  "Content-Type": "application/json",
22584
24257
  ...authorization ? { Authorization: authorization } : {}
22585
24258
  },
22586
- body: JSON.stringify({ code })
24259
+ // docsSite only when set: without it the request is as before.
24260
+ body: JSON.stringify(docsSite ? { code, docsSite } : { code })
22587
24261
  });
22588
24262
  if (!resp.ok) {
22589
24263
  const errorBody = await resp.text();
@@ -22610,8 +24284,14 @@ function registerSearchTool(server, codeModeBaseUrl, description, maxResponseSiz
22610
24284
  ]
22611
24285
  };
22612
24286
  }
24287
+ const result = isMintlifyDocsSite(docsSite) && data.result !== void 0 ? JSON.parse(
24288
+ (await rewriteDocsLinks(
24289
+ toDevWixHostText(JSON.stringify(data.result)),
24290
+ { label: "search SearchWixAPISpec" }
24291
+ )).text
24292
+ ) : data.result;
22613
24293
  const text = truncateResponse(
22614
- data.result,
24294
+ result,
22615
24295
  maxResponseSize ?? SEARCH_MAX_RESPONSE_CHARS
22616
24296
  );
22617
24297
  return {
@@ -22644,10 +24324,13 @@ async function postExecute(executeUrl, body, authorization, codeModeFetch = defa
22644
24324
  }
22645
24325
  return await resp.json();
22646
24326
  }
22647
- function executeErrorResult(message) {
24327
+ function executeErrorResult(message, failedCalls) {
22648
24328
  return {
22649
24329
  isError: true,
22650
- content: [{ type: "text", text: `Execute error: ${message}` }]
24330
+ content: [{ type: "text", text: `Execute error: ${message}` }],
24331
+ // The failed calls as fields, request ids included. The text carries the
24332
+ // ids too, for clients that don't read structured results.
24333
+ ...failedCalls?.length ? { structuredContent: { failedCalls } } : {}
22651
24334
  };
22652
24335
  }
22653
24336
  function executeTextResult(message) {
@@ -22657,7 +24340,7 @@ function executeTextResult(message) {
22657
24340
  }
22658
24341
  function formatExecuteResult(data, maxResponseSize, reportBi) {
22659
24342
  if (data.error) {
22660
- return executeErrorResult(data.error);
24343
+ return executeErrorResult(data.error, data.failedCalls);
22661
24344
  }
22662
24345
  reportBi?.({
22663
24346
  originalLength: typeof data.result === "string" ? data.result.length : JSON.stringify(data.result)?.length
@@ -22677,7 +24360,13 @@ function formatExecuteResult(data, maxResponseSize, reportBi) {
22677
24360
  }
22678
24361
  return {
22679
24362
  content: [
22680
- { type: "text", text: truncateResponse(data.result, maxResponseSize) }
24363
+ {
24364
+ type: "text",
24365
+ text: truncateResponse(
24366
+ data.result,
24367
+ maxResponseSize ?? EXECUTE_MAX_RESPONSE_CHARS
24368
+ )
24369
+ }
22681
24370
  ]
22682
24371
  };
22683
24372
  }
@@ -22715,7 +24404,7 @@ function addExecuteTool(server, options) {
22715
24404
  "One sentence explaining the original user request and why you are executing code to complete it."
22716
24405
  ),
22717
24406
  hasMutations: external_exports.boolean().describe(
22718
- visitor ? "Whether this code creates, updates, deletes, publishes, imports, uploads, or otherwise mutates site data on the visitor\u2019s behalf. Set this to true for create/update/delete/bulk create/import/upload calls even if the reason is inspection, verification, or response-shape discovery. Read-only GET/query/list/search calls can use false." : "Whether this code creates, updates, deletes, publishes, installs, imports, uploads, or otherwise mutates Wix data or site/account state. Set this to true for create/update/delete/bulk create/import/upload calls even if the reason is inspection, verification, or response-shape discovery. Read-only GET/query/list/search calls can use false."
24407
+ visitor ? "True if the code changes site data on the visitor\u2019s behalf (create, update, delete, import, upload); false if it only reads (get, query, list, search)." : "True if the code changes anything in the Wix account or a site (create, update, delete, publish, install, import, upload); false if it only reads (get, query, list, search)."
22719
24408
  ),
22720
24409
  sourceDocUrls: external_exports.array(external_exports.string()).describe(d.sourceDocUrls),
22721
24410
  files: external_exports.string().optional().describe(
@@ -22739,7 +24428,9 @@ function addExecuteTool(server, options) {
22739
24428
  mime_type: external_exports.string().optional()
22740
24429
  })
22741
24430
  ).optional().describe(
22742
- 'Files attached in this chat, or files you created in your own file sandbox (any type: a zip of a site, HTML, images, PDFs). Pass the files themselves and the platform resolves each into { download_url, file_id, file_name?, mime_type? }; the bytes are fetched here and appended to the `files` global as { path, content, encoding: "base64" } entries (path = file_name), so `wix.multipart()` and `wix.unzip()` work on them unchanged. Prefer this over base64 in `files` whenever you have a file handle. Up to 10 MB per call.'
24431
+ fileParamNote(
24432
+ "use `files`, or upload from your shell if it reaches the internet"
24433
+ ) + ' Any type: a zip of a site, HTML, images, PDFs. The bytes are fetched here and appended to the `files` global as { path, content, encoding: "base64" } entries (path = file_name), so `wix.multipart()` and `wix.unzip()` work on them unchanged. Prefer this over base64 in `files` whenever you have a file handle. Up to 10 MB per call.'
22743
24434
  ),
22744
24435
  // Visitor mode takes an agent-supplied token and pins the site; account/site
22745
24436
  // mode lets the agent pick the site.
@@ -22753,7 +24444,10 @@ function addExecuteTool(server, options) {
22753
24444
  )
22754
24445
  }
22755
24446
  },
22756
- { readOnlyHint: false, destructiveHint: true, openWorldHint: false },
24447
+ // openWorldHint true: agent code picks the Wix endpoints at run time (and may
24448
+ // receive platform-resolved attachment URLs); the sandbox's host allowlist
24449
+ // bounds it, but the operation set is open-ended, which is what the hint means.
24450
+ { readOnlyHint: false, destructiveHint: true, openWorldHint: true },
22757
24451
  async (rawArgs, extra) => {
22758
24452
  const {
22759
24453
  code,
@@ -22809,6 +24503,7 @@ function addExecuteTool(server, options) {
22809
24503
  sessionId,
22810
24504
  toolInvocationId,
22811
24505
  clientName: server.server?.getClientVersion?.()?.name,
24506
+ ...visitor ? { visitorMode: true } : {},
22812
24507
  // A visitor token is a site-scoped bearer token: sent as siteToken
22813
24508
  // (→ Authorization + wix-site-id) and as accountToken only to satisfy
22814
24509
  // the runtime's required field. Account/site mode uses strategy tokens.
@@ -23083,6 +24778,7 @@ function createWixToolkit(options) {
23083
24778
  readmeDocs,
23084
24779
  authStrategy,
23085
24780
  dynamicContextEnabled: true,
24781
+ includeCompanionApp: true,
23086
24782
  // README-free defaults first so consumer overrides still win.
23087
24783
  toolDescriptions: {
23088
24784
  ...descriptionsWithoutReadme,
@@ -23093,6 +24789,7 @@ function createWixToolkit(options) {
23093
24789
  addDocsTools(server, void 0, {
23094
24790
  authStrategy,
23095
24791
  dynamicContextEnabled: true,
24792
+ includeCompanionApp: true,
23096
24793
  toolDescriptions: descriptionsWithoutReadme
23097
24794
  });
23098
24795
  }
@@ -23133,7 +24830,9 @@ function createWixToolkit(options) {
23133
24830
  authStrategy,
23134
24831
  disableTools,
23135
24832
  toolDescriptions: effectiveToolDescriptions,
23136
- maxResponseSize
24833
+ maxResponseSize,
24834
+ // The connection's docs site (`docs.docsSite`) applies to spec search too.
24835
+ docsSite: docs?.docsSite
23137
24836
  });
23138
24837
  }
23139
24838
  if (requestedTools.has("ExecuteWixAPI") && !disableTools?.includes("ExecuteWixAPI")) {
@@ -23146,6 +24845,13 @@ function createWixToolkit(options) {
23146
24845
  maxResponseSize
23147
24846
  });
23148
24847
  }
24848
+ if (requestedTools.has("UploadHeadlessWebsiteFiles") && !disableTools?.includes("UploadHeadlessWebsiteFiles")) {
24849
+ addUploadHeadlessWebsiteFilesTool(server, {
24850
+ authStrategy,
24851
+ toolDescriptions: effectiveToolDescriptions,
24852
+ clientName
24853
+ });
24854
+ }
23149
24855
  const requestedGraphqlTools = GRAPHQL_TOOL_NAMES.filter(
23150
24856
  (name) => requestedTools.has(name)
23151
24857
  );
@@ -23206,7 +24912,7 @@ function createWixToolkit(options) {
23206
24912
  biLogger.updateDefaults({ _uuid: "" });
23207
24913
  panorama.transaction(toolName).start({
23208
24914
  toolInvocationId,
23209
- params: JSON.stringify(mergedArgs)
24915
+ params: serializeToolParamsForBi(mergedArgs)
23210
24916
  });
23211
24917
  }
23212
24918
  const startTime = performance.now();
@@ -23226,7 +24932,8 @@ function createWixToolkit(options) {
23226
24932
  cbResult,
23227
24933
  {
23228
24934
  returnedRows: toolBiParams.returnedRows,
23229
- originalLength: toolBiParams.originalLength
24935
+ originalLength: toolBiParams.originalLength,
24936
+ upload: toolBiParams.upload
23230
24937
  },
23231
24938
  { name: clientName }
23232
24939
  );
@@ -23241,7 +24948,7 @@ function createWixToolkit(options) {
23241
24948
  context: {
23242
24949
  toolName,
23243
24950
  toolInvocationId,
23244
- params: JSON.stringify(mergedArgs),
24951
+ params: serializeToolParamsForBi(mergedArgs),
23245
24952
  error: JSON.stringify(cbResult, null, 2)
23246
24953
  }
23247
24954
  }
@@ -23259,7 +24966,7 @@ function createWixToolkit(options) {
23259
24966
  context: {
23260
24967
  toolName,
23261
24968
  toolInvocationId,
23262
- params: JSON.stringify(mergedArgs),
24969
+ params: serializeToolParamsForBi(mergedArgs),
23263
24970
  error: errorBody
23264
24971
  }
23265
24972
  });
@@ -23287,7 +24994,7 @@ function createWixToolkit(options) {
23287
24994
  errorBody,
23288
24995
  toolInvocationId,
23289
24996
  toolName,
23290
- params: JSON.stringify(mergedArgs),
24997
+ params: serializeToolParamsForBi(mergedArgs),
23291
24998
  origin: nodeEnv,
23292
24999
  sessionId,
23293
25000
  executionResult: toolSucceeded ? "Success" : "Error",
@@ -23335,7 +25042,8 @@ function createWixToolkit(options) {
23335
25042
  const httpClient = new import_http_client3.HttpClient();
23336
25043
  return await getDynamicContext(authStrategy, httpClient, defaults, {
23337
25044
  partnerContextEnabled: true,
23338
- includeAccountContext: true
25045
+ includeAccountContext: true,
25046
+ includeCompanionApp: true
23339
25047
  }) || null;
23340
25048
  } catch {
23341
25049
  return null;