@wix/mcp 1.0.92 → 1.0.94

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 (38) hide show
  1. package/build/bin-standalone.js +180 -212
  2. package/build/cjs/index.cjs +757 -216
  3. package/build/cjs/toolkit.cjs +725 -209
  4. package/build/dts/api-call/index.js +6 -3
  5. package/build/dts/api-call/site-files.d.ts +28 -0
  6. package/build/dts/api-call/site-files.js +194 -0
  7. package/build/dts/api-call/upload-headless-website-files.d.ts +35 -0
  8. package/build/dts/api-call/upload-headless-website-files.js +171 -0
  9. package/build/dts/bin.js +3 -6
  10. package/build/dts/code-mode/attachments.d.ts +37 -0
  11. package/build/dts/code-mode/attachments.js +218 -0
  12. package/build/dts/code-mode/index.js +53 -6
  13. package/build/dts/config/default-config.d.ts +0 -4
  14. package/build/dts/config/default-config.js +48 -56
  15. package/build/dts/config/param-descriptions.js +5 -5
  16. package/build/dts/docs/docs.d.ts +4 -2
  17. package/build/dts/docs/docs.js +25 -15
  18. package/build/dts/docs/fetch-article.js +4 -1
  19. package/build/dts/docs/get-to-know.js +1 -1
  20. package/build/dts/docs/semanticSearch.d.ts +2 -1
  21. package/build/dts/docs/semanticSearch.js +12 -5
  22. package/build/dts/docs/start-headless-build.d.ts +19 -0
  23. package/build/dts/docs/start-headless-build.js +74 -0
  24. package/build/dts/graphql/index.js +3 -1
  25. package/build/dts/import-claude-design-tool/index.js +2 -2
  26. package/build/dts/index.d.ts +1 -0
  27. package/build/dts/index.js +1 -0
  28. package/build/dts/site-widget-tools/search-site-templates-tool/index.js +17 -7
  29. package/build/dts/toolkit-entry.d.cts +4 -2
  30. package/build/dts/toolkit-entry.d.ts +4 -2
  31. package/build/dts/toolkit.js +9 -0
  32. package/build/dts/wix-mcp-server.d.ts +2 -0
  33. package/build/dts/wix-mcp-server.js +4 -0
  34. package/build/esm/index.js +755 -216
  35. package/build/esm/toolkit.js +725 -209
  36. package/package.json +2 -2
  37. package/build/dts/docs/create-site-guide.d.ts +0 -3
  38. package/build/dts/docs/create-site-guide.js +0 -109
@@ -16289,9 +16289,12 @@ var runSemanticSearch = async (toolName, toolParams, maxResults = 20, rerank = f
16289
16289
  );
16290
16290
  return data?.results;
16291
16291
  };
16292
- var runPlatformizedSemanticSearch = async (toolName, searchTerm, maxResults = 20, linesInEachResult) => {
16292
+ var runPlatformizedSemanticSearch = async (toolName, searchTerm, maxResults = 20, linesInEachResult, extraDocumentTypes) => {
16293
16293
  const startTime = Date.now();
16294
- logger.log(`[SemanticSearch/v2] Tool: ${toolName}, Query: "${searchTerm}"`);
16294
+ const documentTypes = extraDocumentTypes?.length ? [toolName, ...extraDocumentTypes] : void 0;
16295
+ logger.log(
16296
+ `[SemanticSearch/v2] Tool: ${documentTypes ? documentTypes.join("+") : toolName}, Query: "${searchTerm}"`
16297
+ );
16295
16298
  const response = await fetch(
16296
16299
  "https://www.wixapis.com/mcp-docs-search/v1/docs/search/markdown",
16297
16300
  {
@@ -16302,7 +16305,7 @@ var runPlatformizedSemanticSearch = async (toolName, searchTerm, maxResults = 20
16302
16305
  },
16303
16306
  body: JSON.stringify({
16304
16307
  search_term: searchTerm,
16305
- document_type: toolName,
16308
+ ...documentTypes ? { document_types: documentTypes } : { document_type: toolName },
16306
16309
  maximum_results: maxResults,
16307
16310
  lines_in_each_result: linesInEachResult
16308
16311
  })
@@ -16331,14 +16334,16 @@ var runSemanticSearchAndFormat = async ({
16331
16334
  maxResults = DEFAULT_MAX_RESULTS,
16332
16335
  rerank,
16333
16336
  linesInEachResult,
16334
- usePlatformizedSearch = true
16337
+ usePlatformizedSearch = true,
16338
+ extraDocumentTypes
16335
16339
  }) => {
16336
16340
  if (usePlatformizedSearch) {
16337
16341
  return runPlatformizedSemanticSearch(
16338
16342
  toolName,
16339
16343
  toolParams.searchTerm,
16340
16344
  maxResults,
16341
- linesInEachResult
16345
+ linesInEachResult,
16346
+ extraDocumentTypes
16342
16347
  );
16343
16348
  } else {
16344
16349
  const results = await runSemanticSearch(
@@ -17275,7 +17280,7 @@ async function fetchArticle(articleUrl) {
17275
17280
  }
17276
17281
  var DOCS_URL_PREFIX = "https://dev.wix.com/docs/";
17277
17282
  var SKILLS_REGISTRY_URL = new RegExp(
17278
- "^https://(?:dev\\.wix\\.com(?:/docs)?|www\\.wix\\.com(?:/velo/reference)?)/skills(?:[/.?#]|$)"
17283
+ "^https://(?:dev\\.wix\\.com(?:/docs)?|www\\.wix\\.com(?:/velo/reference)?)/skills(?:[/.?#]|$)|^https://www\\.wix\\.com/headless/"
17279
17284
  );
17280
17285
  function isSkillsRegistryUrl(url) {
17281
17286
  return SKILLS_REGISTRY_URL.test(url.trim());
@@ -17700,10 +17705,8 @@ function buildSystemReminderGuidelines(includeReadme, includeImageUploadGuidance
17700
17705
  if (includeReadme) {
17701
17706
  lines.push(
17702
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.",
17703
- "**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.",
17704
- "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.",
17705
- "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.",
17706
- "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."
17708
+ "**Creating a new Wix site \u2014 and only then \u2014 skip WixREADME and the docs.** First settle one thing: will the user keep working on this site with you, in code, or design it themselves in Wix's editor? In code \u2014 you or the user have code, the two of you designed it here, they asked you to build it, they asked for a headless site, or it is an app: StartDeployWebsite if the code exists in any form, StartHeadlessBuild if not, called right away (it only returns the guide; the site's purpose is not needed first). In Wix's editor: the site-creation tools; their descriptions carry the rules. Everything else starts with WixREADME as usual.",
17709
+ "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 site creation through ManageWixSite, CallWixSiteAPI, or ExecuteWixAPI."
17707
17710
  );
17708
17711
  }
17709
17712
  lines.push(
@@ -17751,9 +17754,8 @@ function buildSystemReminder(includeReadme, includeImageUploadGuidance = true) {
17751
17754
  );
17752
17755
  const flows = buildSystemReminderFlows(includeReadme);
17753
17756
  return dedent_default`
17754
- <agent-mandatory-instructions>
17755
- YOU MUST READ AND FOLLOW THE AGENT-MANDATORY-INSTRUCTIONS BELOW
17756
- A FAILURE TO DO SO WILL RESULT IN ERRORS AND CRITICAL ISSUES.
17757
+ <wix-usage-guide>
17758
+ How to work with Wix through these tools. Following these steps avoids failed or incorrect API calls.
17757
17759
  <goal>
17758
17760
  ${AGENT_GOAL}
17759
17761
  </goal>
@@ -17763,7 +17765,7 @@ function buildSystemReminder(includeReadme, includeImageUploadGuidance = true) {
17763
17765
  <flow-description>
17764
17766
  ${flows}
17765
17767
  </flow-description>
17766
- </agent-mandatory-instructions>
17768
+ </wix-usage-guide>
17767
17769
  `;
17768
17770
  }
17769
17771
  var SYSTEM_REMINDER = buildSystemReminder(true);
@@ -17775,18 +17777,14 @@ var SITE_CREATION_COPY = {
17775
17777
  unstatedMethod: {
17776
17778
  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",
17777
17779
  widget: "you MUST call `WixSiteCreation` and let them choose"
17778
- },
17779
- normalCreationRoute: {
17780
- nonWidget: "route those through `WixSiteBuilder` or `SearchSiteTemplates`",
17781
- widget: "route those through `WixSiteCreation`"
17782
17780
  }
17783
17781
  };
17784
17782
  var SITE_GUIDANCE = dedent_default`
17785
- First decide which of two different things is being asked for:
17786
- - 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.
17787
- - 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.
17783
+ First decide who keeps building the site:
17784
+ - **You, in code**: a Wix Headless site, with full control of the design, changed and redeployed from this conversation, Wix business features added as a backend. This is the case when you or the user have code (hand-written files, a static build, a zip, another builder's export, a page you made here): call StartDeployWebsite. It is also the case when nothing is coded yet but the user asked you to build it or asked for a headless site, the two of you worked out its design in this conversation, or it is an app (a game, a dashboard, a tool): call StartHeadlessBuild right away, before asking what the site is for. Do not offer AI or templates for either.
17785
+ - **The user, in Wix's editor**: Wix generates it with AI or starts it from a template, and the user designs it in Wix. That is what the site-creation tools do; they never take files you already have.
17788
17786
 
17789
- 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.
17787
+ For a new site in Wix's editor 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.
17790
17788
 
17791
17789
  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.
17792
17790
  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.
@@ -17806,6 +17804,7 @@ var toWidget = (text) => Object.values(SITE_CREATION_COPY).reduce(
17806
17804
  );
17807
17805
  var EXECUTE_WIX_API_INTRO = dedent_default`
17808
17806
  Execute JavaScript code against the Wix REST API when code is useful for chaining related calls, pagination, loops, branching, or in-memory transformation.
17807
+ Putting a site live or changing a headless site's files starts with StartDeployWebsite; building a new site in code with StartHeadlessBuild.
17809
17808
 
17810
17809
  CODE CONTRACT:
17811
17810
  - Pass an async function expression: \`async function() { ... }\` or \`async () => { ... }\`. Put every declaration, \`await\`, and \`return\` inside it, and do not invoke it yourself.
@@ -17883,13 +17882,14 @@ var ACCOUNT_SITE_EXECUTE_SCOPE = dedent_default`
17883
17882
  unzip(input: string | Uint8Array): Promise<Array<{ path: string; bytes: Uint8Array; text(): string }>>;
17884
17883
  };
17885
17884
  declare const siteId: string | undefined;
17886
- // Files from the ExecuteWixAPI \`files\` param. Text entries have \`content\`;
17887
- // an entry tagged \`=== FILE: <path> base64 ===\` has encoding:'base64' and
17888
- // base64 \`content\` (a binary file — image, font).
17885
+ // Files from the ExecuteWixAPI \`files\` param, followed by the resolved
17886
+ // \`attachments\`. Text entries have \`content\`; an entry tagged
17887
+ // \`=== FILE: <path> base64 ===\` — and every attachment, path = its file name —
17888
+ // has encoding:'base64' and base64 \`content\`.
17889
17889
  declare const files: Array<{ path: string; content: string; encoding?: "base64" }>;
17890
17890
  \`\`\`
17891
17891
 
17892
- FILE UPLOADS: put every file in the \`files\` param (never inline in \`code\`). 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):
17892
+ FILE UPLOADS: files never go inline in \`code\`; two params feed the \`files\` global. \`attachments\` works in ChatGPT only: pass files attached in the chat or created in your sandbox (any type, up to 10 MB per call: a zip of a whole site, HTML, images, PDFs) as you have them, by file id or /mnt/data path, all in one call. ChatGPT swaps each for \`{ download_url, file_id, file_name?, mime_type? }\` before the call reaches Wix, and the bytes arrive as base64 entries named by file name. Other clients send the value unchanged and the call fails before running; there, leave \`attachments\` out, or upload from your shell if it reaches the internet. 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):
17893
17893
  \`\`\`javascript
17894
17894
  // files param:
17895
17895
  // === FILE: index.html ===
@@ -17904,6 +17904,12 @@ var ACCOUNT_SITE_EXECUTE_SCOPE = dedent_default`
17904
17904
  return res.data;
17905
17905
  }
17906
17906
  \`\`\`
17907
+ A site zip passed through \`attachments\` is one base64 entry; unzip it and upload the entries:
17908
+ \`\`\`javascript
17909
+ // attachments: [site.zip] → files = [{ path: "site.zip", content: "<base64>", encoding: "base64" }]
17910
+ const entries = await wix.unzip(files[0].content); // [{ path, bytes, text() }]
17911
+ const mp = wix.multipart(entries);
17912
+ \`\`\`
17907
17913
  DOWNLOAD + EDIT + RE-UPLOAD: fetch the zip as base64, \`wix.unzip()\` it, edit text via \`entry.text()\`, keep binary as bytes, and hand the entries back to \`wix.multipart()\`:
17908
17914
  \`\`\`javascript
17909
17915
  const r = await wix.request({ scope: "account", method: "GET", responseType: "base64", url: zipUrl });
@@ -18044,7 +18050,7 @@ function buildToolDescriptions(includeReadme, includeImageUploadGuidance = true)
18044
18050
  ReadFullDocsArticle: dedent_default`
18045
18051
  Fetches the full Wix docs article or method article with code examples for using the method.
18046
18052
  Docs articles looks like this: https://dev.wix.com/docs/... and they can either be general docs articles or method articles.
18047
- 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.
18053
+ 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.
18048
18054
  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.
18049
18055
  For REST docs, use the URL as-is. For SDK docs, the URL SHOULD include ?apiView=SDK.
18050
18056
  ${reminder}
@@ -18092,7 +18098,7 @@ function buildToolDescriptions(includeReadme, includeImageUploadGuidance = true)
18092
18098
  ${reminder}
18093
18099
  `,
18094
18100
  ManageWixSite: dedent_default`
18095
- Use account level API in order to create a site and update a site.
18101
+ Use account level API in order to update a site.
18096
18102
  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\`.
18097
18103
  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"}]).
18098
18104
  The API endpoint url param MUST ALWAYS be taken from the conversation context.
@@ -18108,12 +18114,12 @@ function buildToolDescriptions(includeReadme, includeImageUploadGuidance = true)
18108
18114
  NEVER call this tool with a missing, empty, or guessed siteId — ask first instead.
18109
18115
 
18110
18116
  Parameters — provide image input via image and/or imageUrls, OR imageBase64:
18111
- • image (array): chat file ATTACHMENTS. 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.
18117
+ • 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.
18112
18118
  • 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.
18113
18119
  • imageBase64 (string): base64-encoded image + mimeType. One image at a time. Do NOT combine with image/imageUrls.
18114
18120
 
18115
18121
  Delivering the bytes — this is where uploads most often fail:
18116
- • NEVER pass a local or sandbox file path (e.g. /mnt/..., /home/user/..., /Users/...) in any field — the server cannot reach your filesystem. Use a public http(s) URL (imageUrls) or the complete base64 (imageBase64).
18122
+ • 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).
18117
18123
  • 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.
18118
18124
  `,
18119
18125
  SupportAndFeedback: dedent_default`
@@ -18171,14 +18177,15 @@ function buildToolDescriptions(includeReadme, includeImageUploadGuidance = true)
18171
18177
 
18172
18178
  Do not call this if the user explicitly asks to build with AI; call \`WixSiteBuilder\` instead.
18173
18179
  Do not call this if the user asks for templates or Wix Studio; call \`SearchSiteTemplates\` instead.
18180
+ Not for a site the user wants you to build in code, a design you worked out together, or an app: call \`StartHeadlessBuild\`.
18174
18181
 
18175
18182
  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).
18176
18183
 
18177
18184
  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.
18178
18185
  `,
18179
18186
  "import-claude-design-from-url": dedent_default`
18180
- 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.
18181
- 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.
18187
+ 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.
18188
+ 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.
18182
18189
  `,
18183
18190
  RunWixCliCommand: dedent_default`
18184
18191
  Executes Wix CLI commands for Wix app development and management.
@@ -18615,23 +18622,23 @@ function buildToolDescriptions(includeReadme, includeImageUploadGuidance = true)
18615
18622
  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.
18616
18623
  Never default to this tool: if the user hasn't explicitly named AI, don't call this tool — ${SITE_CREATION_COPY.unstatedMethod.nonWidget}.
18617
18624
 
18618
- 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\`.
18625
+ For templates or Wix Studio, call \`SearchSiteTemplates\` (\`builder: classic\` for the Classic Editor); for a template id, \`CreateSiteFromTemplate\`. A site the user wants you to build in code, or an app: \`StartHeadlessBuild\`.
18619
18626
 
18620
18627
  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.)
18621
18628
  `,
18622
18629
  SearchSiteTemplates: dedent_default`
18623
18630
  ${SITE_GUIDANCE}
18624
18631
 
18625
- Searches Wix templates and shows the template gallery, from the Harmony or the Studio template source.
18632
+ Searches Wix templates and shows the template gallery, from the Harmony, the Studio or the Classic Editor template source.
18626
18633
 
18627
- 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.
18634
+ Call this ONLY when the user's own words ask for a template, for Wix Studio or for the Classic Editor (for example "start from a template", "show me some templates", "build it in Wix Studio", "the old Wix editor") and you can already tell what the site is for. If they mention Wix Studio, search Studio templates; if they ask for the Classic Editor (the Wix Editor), search \`classic\`; otherwise search Harmony templates.
18628
18635
  ${SITE_CREATION_COPY.templatePick.nonWidget}
18629
18636
 
18630
18637
  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}.`,
18631
18638
  CreateSiteFromTemplate: dedent_default`
18632
18639
  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.
18633
18640
 
18634
- 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\`.
18641
+ 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).
18635
18642
 
18636
18643
  `,
18637
18644
  SearchWixGraphQLOperations: dedent_default`
@@ -18659,34 +18666,24 @@ function buildToolDescriptions(includeReadme, includeImageUploadGuidance = true)
18659
18666
  Compose: put independent reads in one document as several root fields, and use related-entity fields (e.g. \`inventoryItems\`, \`collections\`, \`fulfillments\`) instead of extra round-trips. Select only the fields you need; every object field needs a selection set. Variables: use them for \`JSON\` scalars (filter, sort) and plain scalars (String, Int, ID), declared in the document (e.g. \`query Q($f: JSON) { ... filter: $f ... }\`). Write mutation inputs and any object that contains an enum INLINE as GraphQL literals with enum values unquoted (e.g. \`input: { product: { name: "Mug", productType: PHYSICAL } }\`) — this endpoint fails with 503 when an enum value arrives inside an object-typed variable. For lists page with \`cursorPaging\` or \`paging\` exactly as the input type declares (never the other one), and request \`pageInfo { hasNext total }\`; \`total\` is only populated with offset \`paging\`, so for a cursor-paged list count by walking pages or use a count operation.
18660
18667
  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.
18661
18668
  Set \`hasMutations: true\` for any document containing a mutation root field.
18669
+ `,
18670
+ UploadHeadlessWebsiteFiles: dedent_default`
18671
+ The upload step of the StartDeployWebsite and StartHeadlessBuild guides, and nothing else: puts a finished static website's files — index.html plus its CSS/JS/images, a static build, or a zip of the site — 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.
18672
+ Pass the files themselves: in ChatGPT as \`attachments\` (any type, a zip is unpacked), elsewhere as the \`files\` text bundle (\`=== FILE: <path> ===\` sections, \`base64\` tag for small binaries). The site must contain index.html at its root.
18673
+ NOT a site-creation tool: a request to create, build, design or generate a site — with or without a description — never comes here (those are the site-creation tools, after their own questions). Also NOT for media uploads to an existing site (UploadImageToWixSite) or any other API call (ExecuteWixAPI).
18662
18674
  `,
18663
18675
  StartDeployWebsite: dedent_default`
18664
- 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.
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, put online, make it live, get a URL, upload my site / index.html, or wants to update or redeploy the files of a site you or the user deployed as code.
18665
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.
18666
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).
18667
- Returns the full recipe; follow it and run the flow yourself. The drop page is only the fallback when you can't.
18668
- 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).
18679
+ Returns the full recipe; follow it and run the flow yourself. When the UploadHeadlessWebsiteFiles tool is available, use it for the recipe's upload step — after the site exists (the recipe's provision call, or a metaSiteId from an earlier deploy) — instead of building the multipart body in code; never before this tool. The drop page is only the fallback when you can't.
18680
+ NOT for: a screenshot or reference of a site the user wants Wix to generate (the site-creation tools); a site described in words with no code yet (StartHeadlessBuild); a Wix editor site's content or settings (WixSiteBuilder's edit mode, or WixREADME); 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 site; uploading images or documents to a site's media (UploadImageToWixSite).
18669
18681
  `,
18670
- CreateWixBusinessGuide: dedent_default`
18671
- Provides comprehensive documentation for creating a new Wix business (site, app, etc.).
18672
- 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\`.
18673
- 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.
18674
-
18675
- ## What This Tool Contains
18676
-
18677
- This tool provides complete documentation including:
18678
- - Template selection (empty sites or designed templates)
18679
- - Wix Editor vs Wix Studio options
18680
- - Regular vs Headless site creation (CLI-based; returns setup instructions)
18681
- - API endpoint details and parameters
18682
- - Post-creation steps (OAuth for headless, publishing for regular sites)
18683
- - App installation instructions
18684
-
18685
- ## After Reading This Documentation
18686
-
18687
- **After reading this documentation:**
18688
- 1. Use ManageWixSite for account-level site creation API calls
18689
- 2. Use CallWixSiteAPI / ExecuteWixAPI for site-level follow-up API calls (like install apps if needed)`
18682
+ StartHeadlessBuild: dedent_default`
18683
+ The user wants a site or web app that you build and keep changing in code, here with them, and no code exists yet. Wix runs its business side (store, bookings, CMS, forms, members, payments) as a Wix Headless site. Call this when the user asks you to build it yourself rather than Wix's AI or a template; when the two of you worked out a design in this conversation and nothing is coded yet; when it is an app (a game, a dashboard, a tool); when the user asks for a headless site; when a prompt links \`wix.com/headless/skill.md\` or a project's \`download.zip\`; or to move a Wix site to code.
18684
+ Call it right away: it only returns the guide, and the site's purpose is not needed first (pass "not stated yet" for what you don't know). Returns the full guide; follow it and do the work yourself, choosing its route by what you can reach (a shell that reaches Wix, or this MCP alone).
18685
+ NOT for: files, a build, a zip or a page that already exist (StartDeployWebsite); a site the user will design in Wix's editor (the site-creation tools); a Claude Design URL (import-claude-design-from-url).
18686
+ `
18690
18687
  };
18691
18688
  }
18692
18689
  var defaultToolDescriptions = buildToolDescriptions(true);
@@ -18698,9 +18695,9 @@ var recipesIndexDoc = {
18698
18695
  action: "include"
18699
18696
  };
18700
18697
  var README_INTRO = dedent_default`
18701
- <agent-mandatory-instructions>
18698
+ <wix-usage-guide>
18702
18699
 
18703
- YOU MUST READ AND FOLLOW THE AGENT-MANDATORY-INSTRUCTIONS BELOW:
18700
+ How to work with Wix through these tools:
18704
18701
 
18705
18702
  <source-of-truth>
18706
18703
  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.
@@ -18752,7 +18749,7 @@ var README_BODY = dedent_default`
18752
18749
  <other-uses>
18753
18750
  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.
18754
18751
  </other-uses>
18755
- </agent-mandatory-instructions>
18752
+ </wix-usage-guide>
18756
18753
  `;
18757
18754
  var defaultReadmeDocs = [
18758
18755
  {
@@ -18808,8 +18805,7 @@ var widgetSiteCreationConfig = {
18808
18805
  "WixSiteBuilder",
18809
18806
  "WixSiteCreation",
18810
18807
  "SearchSiteTemplates",
18811
- "CreateSiteFromTemplate",
18812
- "CreateWixBusinessGuide"
18808
+ "CreateSiteFromTemplate"
18813
18809
  ].map((tool) => [tool, toWidget(defaultToolDescriptions[tool])])
18814
18810
  )
18815
18811
  };
@@ -19365,7 +19361,7 @@ var paramDescriptions = {
19365
19361
  },
19366
19362
  SearchWixRESTDocumentation: {
19367
19363
  searchTerm: `The search term to look up in the Wix REST API Documentation \u2014 a natural-language description of the endpoint, resource, or action you need across any Wix domain (Stores, eCommerce, Bookings, CRM, Members, CMS, Events, Blog, Forms, Media, site settings, etc.), e.g. "create a catalog item with inventory", "book a service", "update data collection items". Match the wording to how many entities you will act on: a plural term ("update products") surfaces the resource's bulk methods, which a singular term ("update a product") ranks lower or leaves out. Results are ranked by relevance, so describe the goal rather than guessing an exact API name.`,
19368
- maxResults: "The maximum number of results to return, default is 10, max is 15",
19364
+ maxResults: "The maximum number of results to return (1\u201317, default 17). Results mix REST API documentation with matching recipes and skills.",
19369
19365
  reason: "One sentence describing the original user request and the task you are trying to accomplish with this search."
19370
19366
  },
19371
19367
  WixBusinessFlowsDocumentation: {
@@ -19386,7 +19382,7 @@ var paramDescriptions = {
19386
19382
  },
19387
19383
  SearchWixHeadlessDocumentation: {
19388
19384
  searchTerm: "The search term to search for in the Headless Documentation",
19389
- maxResults: "The maximum number of results to return, default is 10, max is 15"
19385
+ maxResults: "The maximum number of results to return (1\u201317, default 17). Results mix Headless documentation with matching recipes and skills."
19390
19386
  },
19391
19387
  SearchWixVeloDocumentation: {
19392
19388
  searchTerm: "The search term to search for in the Velo Documentation",
@@ -19398,7 +19394,7 @@ var paramDescriptions = {
19398
19394
  reason: "One sentence describing the original user request and the task you are trying to accomplish with this search."
19399
19395
  },
19400
19396
  ReadFullDocsArticle: {
19401
- 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."
19397
+ 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/...) 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."
19402
19398
  },
19403
19399
  ReadFullDocsMethodSchema: {
19404
19400
  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).",
@@ -19414,7 +19410,7 @@ var paramDescriptions = {
19414
19410
  },
19415
19411
  UploadImageToWixSite: {
19416
19412
  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.",
19417
- image: "Array of file ATTACHMENTS the user uploaded in the chat. Each item requires download_url and file_id, and may optionally include file_name and mime_type \u2014 attached files are automatically resolved to these fields by the platform, so just include them here. 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.",
19413
+ 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.",
19418
19414
  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.",
19419
19415
  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.',
19420
19416
  mimeType: 'MIME type of the image (e.g. "image/jpeg", "image/png", "image/webp"). Required when imageBase64 does not include a data URL prefix.',
@@ -19438,7 +19434,7 @@ var paramDescriptions = {
19438
19434
  operationName: "Operation to run when the document defines more than one named operation.",
19439
19435
  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.",
19440
19436
  scope: '"site" (default when siteId is given) runs with a site-scoped credential; "account" runs account-level operations (sites, account settings) and ignores siteId.',
19441
- 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.",
19437
+ 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.",
19442
19438
  reason: "One sentence explaining the original user request and why you are running this GraphQL operation to complete it."
19443
19439
  },
19444
19440
  RunWixCliCommand: {
@@ -19702,121 +19698,6 @@ ${skillsContent}`
19702
19698
  );
19703
19699
  }
19704
19700
 
19705
- // src/docs/create-site-guide.ts
19706
- function isHeadlessRequest(prompt) {
19707
- return !!prompt && /headless/i.test(prompt);
19708
- }
19709
- var HEADLESS_NON_CLI_INSTRUCTIONS = `# Creating a Wix Headless Site
19710
-
19711
- 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.
19712
-
19713
- ## Prerequisites
19714
- - Node.js 18+
19715
- - A terminal / command-line environment
19716
-
19717
- ## Steps to Get Started
19718
-
19719
- 1. **Install and authenticate the Wix CLI:**
19720
- \`\`\`
19721
- npx @wix/cli login
19722
- \`\`\`
19723
- 2. **Follow the quick-start guide:** https://dev.wix.com/docs/go-headless
19724
- 3. **For a complete orchestrated setup** (commerce, CMS, bookings, identity), use the Wix Headless skill: https://www.wix-headless.dev/skill.md`;
19725
- var HEADLESS_CLI_INSTRUCTIONS = `# Creating a Wix Headless Site (CLI Flow)
19726
-
19727
- Follow these steps using the \`RunWixCliCommand\` tool to scaffold and configure a Wix Headless site.
19728
-
19729
- ## Before You Start
19730
- Ask the user:
19731
- 1. What is the brand/site name?
19732
- 2. Which local directory should the project be created in?
19733
-
19734
- ## Steps
19735
-
19736
- ### Step 1 \u2014 Authenticate (if not already done)
19737
- Run: \`npx @wix/cli login\`
19738
- Skip if the user is already authenticated.
19739
-
19740
- ### Step 2 \u2014 Scaffold the project
19741
- 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
19742
-
19743
- ### Step 3 \u2014 Install dependencies
19744
- Run: \`npm install\` in the project directory.
19745
-
19746
- ### Step 4 \u2014 Pull environment variables
19747
- Run: \`npx @wix/cli env pull\`
19748
- This writes the \`.env.local\` file with the site's environment variables.
19749
-
19750
- ### Step 5 \u2014 Build and verify
19751
- Run: \`npx @wix/cli build\`
19752
-
19753
- ### Step 6 \u2014 Release (optional)
19754
- Run: \`npx @wix/cli release\` to deploy.
19755
-
19756
- ## Full Orchestration
19757
- 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
19758
-
19759
- Use \`RunWixCliCommand\` for each CLI step above.`;
19760
- var CREATE_SITE_DOCS = [
19761
- {
19762
- url: "https://dev.wix.com/docs/kb-only/MCP_REST_RECIPES_KB_ID/TRAIN_create_a_new_site_from_template",
19763
- title: "How to Create a New Wix Site",
19764
- nextSteps: "\n\n**Next Steps:** Use the ManageWixSite tool to make the API call for creating the Wix site."
19765
- },
19766
- {
19767
- url: "https://dev.wix.com/docs/kb-only/MCP_REST_RECIPES_KB_ID/TRAIN_wix.devcenter.apps.installer.v1.AppsInstallerService.InstallApp",
19768
- title: "How to Install App on a Wix Site",
19769
- nextSteps: "\n\n**Next Steps:** Use the CallWixSiteAPI tool to make the API call for installing apps on the Wix site."
19770
- }
19771
- ];
19772
- async function addCreateWixBusinessGuideTools(server, disableTools = [], toolDescriptions, cliEnabled = false) {
19773
- if (disableTools.includes("CreateWixBusinessGuide")) {
19774
- return;
19775
- }
19776
- server.tool(
19777
- "CreateWixBusinessGuide",
19778
- toolDescriptions?.["CreateWixBusinessGuide"] ?? defaultToolDescriptions.CreateWixBusinessGuide,
19779
- {
19780
- userPrompt: external_exports.string().optional().describe("The user prompt that triggered this tool")
19781
- },
19782
- { readOnlyHint: true, destructiveHint: false, openWorldHint: false },
19783
- async (args, { httpClient }) => {
19784
- if (isHeadlessRequest(args.userPrompt)) {
19785
- const isCli = typeof cliEnabled === "function" ? cliEnabled() : cliEnabled;
19786
- const text = isCli ? HEADLESS_CLI_INSTRUCTIONS : HEADLESS_NON_CLI_INSTRUCTIONS;
19787
- return { content: [{ type: "text", text }] };
19788
- }
19789
- try {
19790
- const contents = await Promise.all(
19791
- CREATE_SITE_DOCS.map(async ({ url, title, nextSteps }) => {
19792
- const articleContent = await fetchArticleContent(
19793
- httpClient,
19794
- url,
19795
- "article",
19796
- true
19797
- );
19798
- const fullContent = `# ${title}
19799
-
19800
- ${articleContent}${nextSteps}`;
19801
- return { type: "text", text: fullContent };
19802
- })
19803
- );
19804
- return { content: contents };
19805
- } catch (error) {
19806
- return {
19807
- isError: true,
19808
- content: [
19809
- {
19810
- type: "text",
19811
- text: `Error fetching create site documentation: ${error.message}`
19812
- }
19813
- ]
19814
- };
19815
- }
19816
- }
19817
- );
19818
- }
19819
-
19820
19701
  // src/docs/start-deploy-website.ts
19821
19702
  var START_DEPLOY_WEBSITE_PARAM_DESCRIPTIONS = {
19822
19703
  userRequest: "The user's request that led here, quoted if short, otherwise summarized in a sentence.",
@@ -19888,6 +19769,87 @@ function addStartDeployWebsiteTool(server, disableTools = [], toolDescriptions,
19888
19769
  );
19889
19770
  }
19890
19771
 
19772
+ // src/docs/start-headless-build.ts
19773
+ var START_HEADLESS_BUILD_TOOL_NAME = "StartHeadlessBuild";
19774
+ var HEADLESS_GUIDE_URL = "https://www.wix.com/skills/headless-cold-start/headless-kit.md";
19775
+ var START_HEADLESS_BUILD_STARTING_POINTS = [
19776
+ "nothing yet",
19777
+ "a design worked out in this conversation",
19778
+ "an existing Wix Headless site",
19779
+ "a project download link",
19780
+ "a Wix site to move to code"
19781
+ ];
19782
+ var START_HEADLESS_BUILD_PARAM_DESCRIPTIONS = {
19783
+ userRequest: START_DEPLOY_WEBSITE_PARAM_DESCRIPTIONS.userRequest,
19784
+ siteDescription: START_DEPLOY_WEBSITE_PARAM_DESCRIPTIONS.siteDescription,
19785
+ startingPoint: "What the build starts from: nothing yet; a design worked out in this conversation; an existing Wix Headless site; a project download link (a download.zip from Wix); or a Wix site to move to code.",
19786
+ siteFunctionality: START_DEPLOY_WEBSITE_PARAM_DESCRIPTIONS.siteFunctionality,
19787
+ agentIdentity: START_DEPLOY_WEBSITE_PARAM_DESCRIPTIONS.agentIdentity,
19788
+ wixAccess: START_DEPLOY_WEBSITE_PARAM_DESCRIPTIONS.wixAccess
19789
+ };
19790
+ var PREFIX2 = "The following is Wix's headless guide. Follow it end to end and do the work yourself. If you find the user already has the site's code, call StartDeployWebsite instead.";
19791
+ var MOVE_TO_CODE_LINE = `Moving a Wix site to code starts from the site's dashboard (Headless settings, "Go Headless"), which hands the owner a prompt with the project's download link. Ask the user for that prompt, then follow the guide with it.`;
19792
+ function startHeadlessBuildResponse(guide, startingPoint) {
19793
+ const lines = [];
19794
+ if (startingPoint === "a Wix site to move to code") {
19795
+ lines.push(MOVE_TO_CODE_LINE);
19796
+ }
19797
+ if (guide && guide.trim()) {
19798
+ lines.push(PREFIX2, "---", guide.trim());
19799
+ } else {
19800
+ lines.push(
19801
+ `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. If you find the user already has the site's code, call StartDeployWebsite instead.`
19802
+ );
19803
+ }
19804
+ return lines.join("\n\n");
19805
+ }
19806
+ function addStartHeadlessBuildTool(server, disableTools = [], toolDescriptions, fetchOptions = {}) {
19807
+ if (disableTools.includes(START_HEADLESS_BUILD_TOOL_NAME)) {
19808
+ return;
19809
+ }
19810
+ const d = START_HEADLESS_BUILD_PARAM_DESCRIPTIONS;
19811
+ server.tool(
19812
+ START_HEADLESS_BUILD_TOOL_NAME,
19813
+ toolDescriptions?.[START_HEADLESS_BUILD_TOOL_NAME] ?? defaultToolDescriptions[START_HEADLESS_BUILD_TOOL_NAME],
19814
+ {
19815
+ userRequest: external_exports.string().min(1).describe(d.userRequest),
19816
+ siteDescription: external_exports.string().min(1).describe(d.siteDescription),
19817
+ startingPoint: external_exports.enum(START_HEADLESS_BUILD_STARTING_POINTS).describe(d.startingPoint),
19818
+ siteFunctionality: external_exports.string().min(1).describe(d.siteFunctionality),
19819
+ agentIdentity: external_exports.string().min(1).describe(d.agentIdentity),
19820
+ wixAccess: external_exports.string().min(1).describe(d.wixAccess)
19821
+ },
19822
+ { readOnlyHint: true, destructiveHint: false, openWorldHint: false },
19823
+ async (args, { httpClient }) => {
19824
+ let guide;
19825
+ try {
19826
+ guide = await fetchArticleContent(
19827
+ httpClient,
19828
+ HEADLESS_GUIDE_URL,
19829
+ "article",
19830
+ true,
19831
+ fetchOptions.skillsPortalUrl,
19832
+ fetchOptions.repo,
19833
+ fetchOptions.commitHash
19834
+ );
19835
+ } catch (error) {
19836
+ console.warn(
19837
+ "[StartHeadlessBuild] guide fetch failed, returning the pointer:",
19838
+ error instanceof Error ? error.message : error
19839
+ );
19840
+ }
19841
+ return {
19842
+ content: [
19843
+ {
19844
+ type: "text",
19845
+ text: startHeadlessBuildResponse(guide, args.startingPoint)
19846
+ }
19847
+ ]
19848
+ };
19849
+ }
19850
+ );
19851
+ }
19852
+
19891
19853
  // src/docs/docs.ts
19892
19854
  var REST_SEARCH_API_GROUNDING_REMINDER = dedent_default`
19893
19855
  # Before calling a Wix API
@@ -19935,8 +19897,8 @@ var addDocsTools = (server, allowedTools = [
19935
19897
  ], options = {}) => {
19936
19898
  const {
19937
19899
  getToKnowWixEnabled = false,
19938
- createWixBusinessGuideEnabled = true,
19939
19900
  startDeployWebsiteEnabled = true,
19901
+ startHeadlessBuildEnabled = true,
19940
19902
  disableTools,
19941
19903
  toolDescriptions,
19942
19904
  readmeDocs,
@@ -19948,7 +19910,6 @@ var addDocsTools = (server, allowedTools = [
19948
19910
  commitHash,
19949
19911
  skillsTags,
19950
19912
  dynamicContextEnabled,
19951
- cliEnabled = false,
19952
19913
  usePlatformizedSearch = true,
19953
19914
  usePlatformizedBrowse = true
19954
19915
  } = options;
@@ -19994,14 +19955,6 @@ var addDocsTools = (server, allowedTools = [
19994
19955
  skillsTags
19995
19956
  });
19996
19957
  }
19997
- if (createWixBusinessGuideEnabled && !disableTools?.includes("CreateWixBusinessGuide")) {
19998
- addCreateWixBusinessGuideTools(
19999
- server,
20000
- disableTools || [],
20001
- toolDescriptions,
20002
- cliEnabled
20003
- );
20004
- }
20005
19958
  if (startDeployWebsiteEnabled) {
20006
19959
  addStartDeployWebsiteTool(server, disableTools || [], toolDescriptions, {
20007
19960
  skillsPortalUrl,
@@ -20009,6 +19962,13 @@ var addDocsTools = (server, allowedTools = [
20009
19962
  commitHash: effectiveCommitHash
20010
19963
  });
20011
19964
  }
19965
+ if (startHeadlessBuildEnabled) {
19966
+ addStartHeadlessBuildTool(server, disableTools || [], toolDescriptions, {
19967
+ skillsPortalUrl,
19968
+ repo: effectiveRepo,
19969
+ commitHash: effectiveCommitHash
19970
+ });
19971
+ }
20012
19972
  if (allowedTools.includes("WDS") && !disableTools?.includes("SearchWixWDSDocumentation")) {
20013
19973
  server.tool(
20014
19974
  "SearchWixWDSDocumentation",
@@ -20073,7 +20033,7 @@ var addDocsTools = (server, allowedTools = [
20073
20033
  const d = desc("SearchWixRESTDocumentation");
20074
20034
  return {
20075
20035
  searchTerm: external_exports.string().describe(d.searchTerm),
20076
- maxResults: external_exports.number().describe(d.maxResults).min(1).max(15).optional().default(15),
20036
+ maxResults: external_exports.number().describe(d.maxResults).min(1).max(17).optional().default(17),
20077
20037
  reason: external_exports.string().describe(d.reason)
20078
20038
  };
20079
20039
  })(),
@@ -20088,9 +20048,12 @@ var addDocsTools = (server, allowedTools = [
20088
20048
  toolParams: {
20089
20049
  searchTerm
20090
20050
  },
20091
- maxResults: Math.max(1, Math.min(maxResults ?? 15, 15)),
20051
+ maxResults: Math.max(1, Math.min(maxResults ?? 17, 17)),
20092
20052
  linesInEachResult: 30,
20093
- usePlatformizedSearch
20053
+ usePlatformizedSearch,
20054
+ // Merge recipes/skills into the REST ranking — they live in a
20055
+ // separate corpus the REST document_type doesn't cover on its own.
20056
+ extraDocumentTypes: ["SKILLS"]
20094
20057
  });
20095
20058
  const grounding = result.includes(QUERY_CAPABILITY_MARKER) ? [
20096
20059
  REST_SEARCH_API_GROUNDING_REMINDER,
@@ -20353,7 +20316,7 @@ var addDocsTools = (server, allowedTools = [
20353
20316
  const d = desc("SearchWixHeadlessDocumentation");
20354
20317
  return {
20355
20318
  searchTerm: external_exports.string().describe(d.searchTerm),
20356
- maxResults: external_exports.number().describe(d.maxResults).min(1).max(15).optional().default(15)
20319
+ maxResults: external_exports.number().describe(d.maxResults).min(1).max(17).optional().default(17)
20357
20320
  };
20358
20321
  })(),
20359
20322
  { readOnlyHint: true, destructiveHint: false, openWorldHint: false },
@@ -20365,8 +20328,11 @@ var addDocsTools = (server, allowedTools = [
20365
20328
  toolParams: {
20366
20329
  searchTerm
20367
20330
  },
20368
- maxResults: Math.max(1, Math.min(maxResults ?? 15, 15)),
20369
- usePlatformizedSearch
20331
+ maxResults: Math.max(1, Math.min(maxResults ?? 17, 17)),
20332
+ usePlatformizedSearch,
20333
+ // Merge recipes/skills into the headless ranking — same separate
20334
+ // corpus the WIX_HEADLESS document_type doesn't cover on its own.
20335
+ extraDocumentTypes: ["SKILLS"]
20370
20336
  });
20371
20337
  return {
20372
20338
  content: [
@@ -20532,7 +20498,7 @@ var addDocsTools = (server, allowedTools = [
20532
20498
  content: [
20533
20499
  {
20534
20500
  type: "text",
20535
- 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}"`
20501
+ text: `Invalid article URL: must start with https://dev.wix.com/docs/, or be a Wix skills page (https://www.wix.com/skills/..., https://www.wix.com/headless/...). Got: "${articleUrl}"`
20536
20502
  }
20537
20503
  ]
20538
20504
  };
@@ -21257,10 +21223,12 @@ function addApiCallTool(server, strategy, allowedTools = ["CallWixSiteAPI", "Lis
21257
21223
  sourceDocUrl: external_exports.string().describe(d.sourceDocUrl)
21258
21224
  };
21259
21225
  })(),
21226
+ // openWorldHint true: a free-form URL into the whole Wix REST surface is an
21227
+ // open-ended target, even though auth is bounded to the user's account.
21260
21228
  getHints("CallWixSiteAPI", {
21261
21229
  readOnlyHint: false,
21262
21230
  destructiveHint: true,
21263
- openWorldHint: false
21231
+ openWorldHint: true
21264
21232
  }),
21265
21233
  async ({ url, body, method, siteId, reason, sourceDocUrl }, { httpClient, setToolBiParams }) => {
21266
21234
  logger.log(
@@ -21437,7 +21405,7 @@ function addApiCallTool(server, strategy, allowedTools = ["CallWixSiteAPI", "Lis
21437
21405
  getHints("ManageWixSite", {
21438
21406
  readOnlyHint: false,
21439
21407
  destructiveHint: true,
21440
- openWorldHint: false
21408
+ openWorldHint: true
21441
21409
  }),
21442
21410
  async ({ url, body, method, reason }, { httpClient, setToolBiParams }) => {
21443
21411
  logger.log(
@@ -22193,7 +22161,8 @@ function addExecuteGraphqlTool(server, description, authStrategy, options) {
22193
22161
  hasMutations: external_exports.boolean().describe(d.hasMutations),
22194
22162
  reason: external_exports.string().describe(d.reason)
22195
22163
  },
22196
- { readOnlyHint: false, destructiveHint: true, openWorldHint: false },
22164
+ // openWorldHint true: any operation in the Wix GraphQL schema, chosen at call time.
22165
+ { readOnlyHint: false, destructiveHint: true, openWorldHint: true },
22197
22166
  async ({ query, variables, operationName, siteId, scope, hasMutations, reason }, extra) => {
22198
22167
  const effectiveScope = scope ?? (siteId ? "site" : "account");
22199
22168
  logger.log(
@@ -22286,6 +22255,189 @@ ${text.slice(0, 2e3)}`
22286
22255
  );
22287
22256
  }
22288
22257
 
22258
+ // src/code-mode/attachments.ts
22259
+ var MAX_ATTACHMENTS_BYTES = 10 * 1024 * 1024;
22260
+ var MAX_REDIRECTS = 4;
22261
+ var OAI_USERCONTENT_HOST = /^[a-z0-9-]+\.oaiusercontent\.com$/;
22262
+ var OAI_BLOB_ACCOUNTS = new Set(
22263
+ [
22264
+ "australiaeast",
22265
+ "brazilsouth",
22266
+ "cacentral",
22267
+ "centralindia",
22268
+ "centralus",
22269
+ "centralusdr",
22270
+ "denmarkeast",
22271
+ "eastus",
22272
+ "eastus2",
22273
+ "indiasocentral",
22274
+ "italynorth",
22275
+ "japaneast",
22276
+ "koreacentral",
22277
+ "northcentralus",
22278
+ "northeu",
22279
+ "nznorth",
22280
+ "polandcentral",
22281
+ "seasia",
22282
+ "southcentralus",
22283
+ "southeastus3",
22284
+ "ukwest",
22285
+ "westcentralus",
22286
+ "westus",
22287
+ "westus2",
22288
+ "westus3"
22289
+ ].map((region) => `oaisdmntpr${region}.blob.core.windows.net`)
22290
+ );
22291
+ function isAllowedAttachmentHost(hostname) {
22292
+ const h = hostname.toLowerCase();
22293
+ return OAI_USERCONTENT_HOST.test(h) || OAI_BLOB_ACCOUNTS.has(h);
22294
+ }
22295
+ function checkAttachmentUrl(url) {
22296
+ if (url.protocol !== "https:") return "is not an https URL";
22297
+ if (url.port) return "uses a non-default port";
22298
+ if (!isAllowedAttachmentHost(url.hostname)) {
22299
+ return `host "${url.hostname}" is not a ChatGPT file host`;
22300
+ }
22301
+ return void 0;
22302
+ }
22303
+ var AttachmentError = class extends Error {
22304
+ };
22305
+ function attachmentPath(a, url) {
22306
+ let fromUrl = "";
22307
+ try {
22308
+ fromUrl = decodeURIComponent(
22309
+ url.pathname.split("/").filter(Boolean).pop() ?? ""
22310
+ );
22311
+ } catch {
22312
+ fromUrl = "";
22313
+ }
22314
+ const raw = (a.file_name?.trim() || fromUrl || a.file_id).replace(/\\/g, "/");
22315
+ const segments = raw.split("/").filter((s) => s && s !== "." && s !== "..");
22316
+ return segments.join("/") || a.file_id;
22317
+ }
22318
+ function toBase64(bytes) {
22319
+ let binary = "";
22320
+ const chunk = 32768;
22321
+ for (let i = 0; i < bytes.length; i += chunk) {
22322
+ binary += String.fromCharCode(...bytes.subarray(i, i + chunk));
22323
+ }
22324
+ return btoa(binary);
22325
+ }
22326
+ async function fetchAllowed(start, fetchImpl, label) {
22327
+ let url = start;
22328
+ for (let hop = 0; ; hop++) {
22329
+ const res = await fetchImpl(url.toString(), { redirect: "manual" });
22330
+ const location = res.headers.get("location");
22331
+ const isRedirect = res.status >= 300 && res.status < 400 && location;
22332
+ if (!isRedirect) return res;
22333
+ await res.body?.cancel().catch(() => void 0);
22334
+ if (hop >= MAX_REDIRECTS) {
22335
+ throw new AttachmentError(`${label}: too many redirects.`);
22336
+ }
22337
+ let next;
22338
+ try {
22339
+ next = new URL(location, url);
22340
+ } catch {
22341
+ throw new AttachmentError(`${label}: redirect to an invalid URL.`);
22342
+ }
22343
+ const problem = checkAttachmentUrl(next);
22344
+ if (problem) {
22345
+ throw new AttachmentError(
22346
+ `${label}: the download redirected to a URL that ${problem}; refused.`
22347
+ );
22348
+ }
22349
+ url = next;
22350
+ }
22351
+ }
22352
+ async function readWithin(res, budget, overBudget) {
22353
+ const declared = Number(res.headers.get("content-length") ?? 0);
22354
+ if (declared > budget) throw overBudget();
22355
+ if (!res.body) {
22356
+ const bytes = new Uint8Array(await res.arrayBuffer());
22357
+ if (bytes.byteLength > budget) throw overBudget();
22358
+ return bytes;
22359
+ }
22360
+ const reader = res.body.getReader();
22361
+ const chunks = [];
22362
+ let total = 0;
22363
+ for (; ; ) {
22364
+ const { done, value } = await reader.read();
22365
+ if (done) break;
22366
+ total += value.byteLength;
22367
+ if (total > budget) {
22368
+ await reader.cancel().catch(() => void 0);
22369
+ throw overBudget();
22370
+ }
22371
+ chunks.push(value);
22372
+ }
22373
+ const out = new Uint8Array(total);
22374
+ let offset = 0;
22375
+ for (const c of chunks) {
22376
+ out.set(c, offset);
22377
+ offset += c.byteLength;
22378
+ }
22379
+ return out;
22380
+ }
22381
+ async function resolveAttachments(attachments, fetchImpl = fetch) {
22382
+ if (!Array.isArray(attachments) || attachments.length === 0) return [];
22383
+ const items = [];
22384
+ attachments.forEach((raw, i) => {
22385
+ const a = typeof raw === "object" && raw;
22386
+ const downloadUrl = a && typeof a.download_url === "string" ? a.download_url : "";
22387
+ let url;
22388
+ try {
22389
+ url = /^https?:\/\//i.test(downloadUrl) ? new URL(downloadUrl) : void 0;
22390
+ } catch {
22391
+ url = void 0;
22392
+ }
22393
+ if (!a || !url) {
22394
+ throw new AttachmentError(
22395
+ `attachments[${i}] was not resolved to a download URL (got ${JSON.stringify(
22396
+ typeof raw === "string" ? raw : (a && a.download_url) ?? raw
22397
+ )}). \`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).`
22398
+ );
22399
+ }
22400
+ const problem = checkAttachmentUrl(url);
22401
+ if (problem) {
22402
+ throw new AttachmentError(
22403
+ `attachments[${i}].download_url ${problem}. Only platform-resolved attachments are accepted here; for any other URL fetch it in \`code\` via wix.request or put the bytes in the \`files\` bundle.`
22404
+ );
22405
+ }
22406
+ items.push({ a, url });
22407
+ });
22408
+ let remaining = MAX_ATTACHMENTS_BYTES;
22409
+ const out = [];
22410
+ for (const [i, { a, url }] of items.entries()) {
22411
+ const path = attachmentPath(a, url);
22412
+ const label = `attachments[${i}] (${path})`;
22413
+ let res;
22414
+ try {
22415
+ res = await fetchAllowed(url, fetchImpl, label);
22416
+ } catch (e) {
22417
+ if (e instanceof AttachmentError) throw e;
22418
+ throw new AttachmentError(
22419
+ `${label}: download failed (${e.message}).`
22420
+ );
22421
+ }
22422
+ if (!res.ok) {
22423
+ await res.body?.cancel().catch(() => void 0);
22424
+ throw new AttachmentError(
22425
+ `${label}: download returned HTTP ${res.status}. The download_url may have expired; attach the file again.`
22426
+ );
22427
+ }
22428
+ const bytes = await readWithin(
22429
+ res,
22430
+ remaining,
22431
+ () => new AttachmentError(
22432
+ `${label} pushes the attachments past ${MAX_ATTACHMENTS_BYTES} bytes in total for this call; split the upload across calls.`
22433
+ )
22434
+ );
22435
+ remaining -= bytes.byteLength;
22436
+ out.push({ path, content: toBase64(bytes), encoding: "base64" });
22437
+ }
22438
+ return out;
22439
+ }
22440
+
22289
22441
  // src/code-mode/validation.ts
22290
22442
  var EXECUTE_FUNCTION_EXPRESSION_HINT = 'ExecuteWixAPI code must be a function expression, not a script body. Pass code like: async () => { const response = await wix.request({ scope: "site", method: "GET", url: "https://www.wixapis.com/..." }); return response.data; }. Do not write top-level const/await/return outside the function and do not invoke the function yourself.';
22291
22443
  function validateExecuteCode(code) {
@@ -22300,6 +22452,327 @@ function validateExecuteCode(code) {
22300
22452
  return { isValid: true };
22301
22453
  }
22302
22454
 
22455
+ // src/api-call/site-files.ts
22456
+ var MAX_FILES_BUNDLE_CHARS = 4e6;
22457
+ var MAX_UNZIP_BYTES = 64 * 1024 * 1024;
22458
+ var MAX_SITE_FILES = 2e3;
22459
+ var textEncoder = new TextEncoder();
22460
+ function base64ToBytes(b64) {
22461
+ const clean = b64.replace(/^data:[^,]*,/, "").replace(/\s+/g, "");
22462
+ return Uint8Array.from(atob(clean), (c) => c.charCodeAt(0));
22463
+ }
22464
+ function parseFileBundle(bundle) {
22465
+ if (!bundle || !bundle.trim()) return [];
22466
+ if (bundle.length > MAX_FILES_BUNDLE_CHARS) {
22467
+ throw new Error(
22468
+ `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.`
22469
+ );
22470
+ }
22471
+ const delimiter = /^=== FILE: (.+?)(?: (base64))? ===[ \t]*$/gm;
22472
+ const matches = [...bundle.matchAll(delimiter)];
22473
+ if (matches.length === 0) {
22474
+ throw new Error(
22475
+ "files bundle has no `=== FILE: <path> ===` sections. Start each file with that line (add ` base64` before the closing === for binary content)."
22476
+ );
22477
+ }
22478
+ return matches.map((match, i) => {
22479
+ const path = match[1].trim();
22480
+ const start = (match.index ?? 0) + match[0].length;
22481
+ const end = i + 1 < matches.length ? matches[i + 1].index ?? bundle.length : bundle.length;
22482
+ const content = bundle.slice(start, end).replace(/^\r?\n/, "").replace(/\r?\n$/, "");
22483
+ return {
22484
+ path,
22485
+ bytes: match[2] === "base64" ? base64ToBytes(content) : textEncoder.encode(content)
22486
+ };
22487
+ });
22488
+ }
22489
+ async function unzip(z) {
22490
+ const u16 = (o) => z[o] | z[o + 1] << 8;
22491
+ const u32 = (o) => (u16(o) | u16(o + 2) << 16) >>> 0;
22492
+ let end = z.length - 22;
22493
+ while (end >= 0 && !(u32(end) === 101010256 && end + 22 + u16(end + 20) === z.length))
22494
+ end--;
22495
+ if (end < 0) throw new Error("not a zip file (no end-of-central-directory)");
22496
+ const out = [];
22497
+ let p = u32(end + 16);
22498
+ let total = 0;
22499
+ const decoder = new TextDecoder();
22500
+ for (let i = 0, n = u16(end + 10); i < n; i++) {
22501
+ const path = decoder.decode(z.slice(p + 46, p + 46 + u16(p + 28)));
22502
+ const method = u16(p + 10);
22503
+ const size = u32(p + 24);
22504
+ total += size;
22505
+ if (total > MAX_UNZIP_BYTES) {
22506
+ throw new Error(
22507
+ `zip expands past ${MAX_UNZIP_BYTES} bytes; a static site is at most 20 MB`
22508
+ );
22509
+ }
22510
+ const at = u32(p + 42);
22511
+ const start = at + 30 + u16(at + 26) + u16(at + 28);
22512
+ const comp = z.slice(start, start + u32(p + 20));
22513
+ p += 46 + u16(p + 28) + u16(p + 30) + u16(p + 32);
22514
+ if (path.endsWith("/")) continue;
22515
+ let bytes;
22516
+ if (method === 0) bytes = comp;
22517
+ else if (method === 8) {
22518
+ bytes = new Uint8Array(
22519
+ await new Response(
22520
+ new Blob([comp]).stream().pipeThrough(new DecompressionStream("deflate-raw"))
22521
+ ).arrayBuffer()
22522
+ );
22523
+ } else
22524
+ throw new Error(
22525
+ `zip entry '${path}' uses unsupported compression method ${method}`
22526
+ );
22527
+ if (bytes.length !== size) {
22528
+ throw new Error(
22529
+ `zip entry '${path}' declares ${size} bytes but holds ${bytes.length}`
22530
+ );
22531
+ }
22532
+ out.push({ path, bytes });
22533
+ }
22534
+ return out;
22535
+ }
22536
+ 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);
22537
+ var isRootIndex = (p) => /^index\.html?$/i.test(p);
22538
+ async function normalizeSiteFiles(input) {
22539
+ let list = [];
22540
+ for (const f of input) {
22541
+ if (isZip(f)) list.push(...await unzip(f.bytes));
22542
+ else list.push(f);
22543
+ }
22544
+ list = list.map((f) => ({
22545
+ ...f,
22546
+ path: f.path.replace(/\\/g, "/").replace(/^\.?\//, "")
22547
+ })).filter(
22548
+ (f) => f.path && !f.path.startsWith("__MACOSX/") && !/(^|\/)\.DS_Store$/.test(f.path) && !f.path.split("/").includes("..")
22549
+ );
22550
+ if (list.length === 0) {
22551
+ throw new Error(
22552
+ "No files to upload: pass the site in `files` or `attachments`."
22553
+ );
22554
+ }
22555
+ if (list.length > MAX_SITE_FILES) {
22556
+ throw new Error(
22557
+ `Too many files (${list.length}); a site upload is at most ${MAX_SITE_FILES}.`
22558
+ );
22559
+ }
22560
+ if (!list.some((f) => isRootIndex(f.path))) {
22561
+ const first = list[0].path.split("/")[0];
22562
+ if (list.every((f) => f.path.includes("/") && f.path.split("/")[0] === first)) {
22563
+ list = list.map((f) => ({
22564
+ ...f,
22565
+ path: f.path.split("/").slice(1).join("/")
22566
+ }));
22567
+ }
22568
+ }
22569
+ const rootHtml = list.filter(
22570
+ (f) => !f.path.includes("/") && /\.html?$/i.test(f.path)
22571
+ );
22572
+ if (!list.some((f) => isRootIndex(f.path)) && rootHtml.length === 1) {
22573
+ list = list.map(
22574
+ (f) => f === rootHtml[0] ? { ...f, path: "index.html" } : f
22575
+ );
22576
+ }
22577
+ if (!list.some((f) => isRootIndex(f.path))) {
22578
+ const shown = list.slice(0, 8).map((f) => f.path).join(", ");
22579
+ throw new Error(
22580
+ `The site needs an index.html at its root. Files received: ${shown}${list.length > 8 ? ", \u2026" : ""}`
22581
+ );
22582
+ }
22583
+ return list;
22584
+ }
22585
+ function guessContentType(path) {
22586
+ const ext = (/\.([a-zA-Z0-9]+)$/.exec(path)?.[1] ?? "").toLowerCase();
22587
+ const map = {
22588
+ html: "text/html",
22589
+ htm: "text/html",
22590
+ css: "text/css",
22591
+ js: "text/javascript",
22592
+ mjs: "text/javascript",
22593
+ json: "application/json",
22594
+ svg: "image/svg+xml",
22595
+ txt: "text/plain",
22596
+ md: "text/markdown",
22597
+ xml: "application/xml",
22598
+ webmanifest: "application/manifest+json",
22599
+ ico: "image/x-icon",
22600
+ png: "image/png",
22601
+ jpg: "image/jpeg",
22602
+ jpeg: "image/jpeg",
22603
+ gif: "image/gif",
22604
+ webp: "image/webp",
22605
+ avif: "image/avif",
22606
+ woff: "font/woff",
22607
+ woff2: "font/woff2",
22608
+ ttf: "font/ttf",
22609
+ otf: "font/otf",
22610
+ pdf: "application/pdf",
22611
+ mp4: "video/mp4",
22612
+ webm: "video/webm",
22613
+ mp3: "audio/mpeg"
22614
+ };
22615
+ return map[ext] ?? "application/octet-stream";
22616
+ }
22617
+ function buildFormData(files) {
22618
+ const fd = new FormData();
22619
+ for (const f of files) {
22620
+ fd.append(
22621
+ "files",
22622
+ new Blob([f.bytes], { type: guessContentType(f.path) }),
22623
+ f.path
22624
+ );
22625
+ }
22626
+ return fd;
22627
+ }
22628
+
22629
+ // src/api-call/upload-headless-website-files.ts
22630
+ var UPLOAD_HEADLESS_WEBSITE_FILES_TOOL_NAME = "UploadHeadlessWebsiteFiles";
22631
+ var HEADLESS_BUSINESS = "https://www.wixapis.com/headless-business-setup/v1/headless-business";
22632
+ function dropAttribution(clientName) {
22633
+ const slug = (clientName ?? "").toLowerCase().replace(/[^a-z0-9]+/g, "-").replace(/^-+|-+$/g, "").slice(0, 64);
22634
+ return `?campaign=mcp&agent=${encodeURIComponent(slug || "wix-mcp")}`;
22635
+ }
22636
+ var UPLOAD_HEADLESS_WEBSITE_FILES_PARAM_DESCRIPTIONS = {
22637
+ 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 and 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.",
22638
+ attachments: "ChatGPT only. Files attached in the chat or created in your sandbox \u2014 any type: a zip of the whole site, HTML, CSS, JS, images. Pass each file as you have it, its file id or its /mnt/data path, and ChatGPT swaps it for { download_url, file_id, file_name?, mime_type? } before the call reaches Wix. No other client does this swap, so outside ChatGPT a path or file:// URL here fails at once; leave this out and use `files`, or, with a shell that reaches the internet, drop the files with curl as the StartDeployWebsite recipe shows. A zip is unpacked; a top-level folder wrapping the site is stripped. Prefer this over base64 in `files` whenever you have a file handle. Up to 10 MB per call.",
22639
+ 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.",
22640
+ calledStartDeployWebsite: "Whether you called StartDeployWebsite earlier in this conversation and are following the recipe it returned. Answer truthfully; it is recorded, not checked.",
22641
+ agentIdentity: START_DEPLOY_WEBSITE_PARAM_DESCRIPTIONS.agentIdentity,
22642
+ reason: "One sentence: the user request that led here and what is being published."
22643
+ };
22644
+ function formatDropResult(r) {
22645
+ const shown = r.files.slice(0, 60);
22646
+ return [
22647
+ "Uploaded; the site is live with this file set.",
22648
+ `Live URL: ${r.siteUrl ?? "(not returned)"}`,
22649
+ `metaSiteId: ${r.metaSiteId} \u2014 pass it as \`siteId\` to update this site later; every upload replaces the whole file set.`,
22650
+ `Dashboard: https://manage.wix.com/dashboard/${r.metaSiteId}`,
22651
+ `${r.files.length} file(s): ${shown.join(", ")}${r.files.length > shown.length ? ", \u2026" : ""}`,
22652
+ "",
22653
+ "Give the user the live URL and the dashboard link.",
22654
+ `The upload step is done. For what comes next \u2014 changing the site later, connecting a domain, or adding a Wix backend (forms, bookings, a store) to this same site \u2014 continue with the guide you are following, from where it left off: the StartDeployWebsite recipe (${START_DEPLOY_WEBSITE_RECIPE_URL}) or, for a site built through StartHeadlessBuild, the headless guide (${HEADLESS_GUIDE_URL}).`
22655
+ ].join("\n");
22656
+ }
22657
+ async function readJson(res, what) {
22658
+ const text = await res.text();
22659
+ if (!res.ok)
22660
+ throw new WixFetchError(res.status, res.statusText, `${what}: ${text}`);
22661
+ try {
22662
+ return JSON.parse(text);
22663
+ } catch {
22664
+ throw new Error(`${what} returned a non-JSON body: ${text.slice(0, 200)}`);
22665
+ }
22666
+ }
22667
+ function errorResult2(message) {
22668
+ return {
22669
+ isError: true,
22670
+ content: [
22671
+ {
22672
+ type: "text",
22673
+ text: `UploadHeadlessWebsiteFiles error: ${message}`
22674
+ }
22675
+ ]
22676
+ };
22677
+ }
22678
+ function addUploadHeadlessWebsiteFilesTool(server, options) {
22679
+ const { authStrategy, toolDescriptions } = options;
22680
+ const clientName = () => options.clientName ?? server.clientName?.() ?? server.server?.getClientVersion?.()?.name;
22681
+ const fetchImpl = options.fetchImpl ?? ((u, i) => fetch(u, i));
22682
+ const d = UPLOAD_HEADLESS_WEBSITE_FILES_PARAM_DESCRIPTIONS;
22683
+ const registered = server.tool(
22684
+ UPLOAD_HEADLESS_WEBSITE_FILES_TOOL_NAME,
22685
+ toolDescriptions?.[UPLOAD_HEADLESS_WEBSITE_FILES_TOOL_NAME] ?? defaultToolDescriptions.UploadHeadlessWebsiteFiles,
22686
+ {
22687
+ files: external_exports.string().optional().describe(d.files),
22688
+ attachments: external_exports.array(
22689
+ external_exports.object({
22690
+ download_url: external_exports.string(),
22691
+ file_id: external_exports.string(),
22692
+ file_name: external_exports.string().optional(),
22693
+ mime_type: external_exports.string().optional()
22694
+ })
22695
+ ).optional().describe(d.attachments),
22696
+ siteId: external_exports.string().uuid("siteId must be a Wix metaSiteId (UUID)").describe(d.siteId),
22697
+ calledStartDeployWebsite: external_exports.boolean().describe(d.calledStartDeployWebsite),
22698
+ agentIdentity: external_exports.string().min(1).describe(d.agentIdentity),
22699
+ reason: external_exports.string().describe(d.reason)
22700
+ },
22701
+ // openWorldHint true: it fetches agent-supplied attachment URLs and publishes a
22702
+ // public website.
22703
+ { readOnlyHint: false, destructiveHint: true, openWorldHint: true },
22704
+ async (rawArgs, extra) => {
22705
+ const {
22706
+ files,
22707
+ attachments,
22708
+ siteId,
22709
+ calledStartDeployWebsite,
22710
+ agentIdentity,
22711
+ reason
22712
+ } = rawArgs;
22713
+ logger.log(
22714
+ `[UploadHeadlessWebsiteFiles] siteId=${siteId} calledStartDeployWebsite=${calledStartDeployWebsite} agent="${agentIdentity}" files=${files?.length ?? 0} chars attachments=${attachments?.length ?? 0} reason="${reason}"`
22715
+ );
22716
+ if (!files?.trim() && !(attachments && attachments.length)) {
22717
+ return errorResult2(
22718
+ "Nothing to publish: pass the site in `files` (text bundle) or `attachments` (files from this chat or your sandbox)."
22719
+ );
22720
+ }
22721
+ let siteFiles;
22722
+ try {
22723
+ const fromAttachments = (await resolveAttachments(attachments, fetchImpl)).map((a) => ({ path: a.path, bytes: base64ToBytes(a.content) }));
22724
+ siteFiles = await normalizeSiteFiles([
22725
+ ...parseFileBundle(files),
22726
+ ...fromAttachments
22727
+ ]);
22728
+ } catch (e) {
22729
+ if (e instanceof AttachmentError || e instanceof Error)
22730
+ return errorResult2(e.message);
22731
+ throw e;
22732
+ }
22733
+ const authHeaders = await authStrategy.getAccountAuthHeaders();
22734
+ try {
22735
+ const metaSiteId = siteId;
22736
+ extra?.setToolBiParams?.({ siteId: metaSiteId });
22737
+ const dropped = await readJson(
22738
+ await fetchImpl(
22739
+ `${HEADLESS_BUSINESS}/${metaSiteId}/drop${dropAttribution(clientName())}`,
22740
+ {
22741
+ method: "POST",
22742
+ headers: { ...authHeaders },
22743
+ // fetch sets the multipart boundary itself
22744
+ body: buildFormData(siteFiles)
22745
+ }
22746
+ ),
22747
+ "drop"
22748
+ );
22749
+ return {
22750
+ content: [
22751
+ {
22752
+ type: "text",
22753
+ text: formatDropResult({
22754
+ metaSiteId,
22755
+ siteUrl: dropped.siteUrl,
22756
+ uploadId: dropped.uploadId,
22757
+ files: siteFiles.map((f) => f.path)
22758
+ })
22759
+ }
22760
+ ]
22761
+ };
22762
+ } catch (err) {
22763
+ const message = err instanceof Error ? err.message : String(err);
22764
+ logger.log(`[UploadHeadlessWebsiteFiles] Error: ${message}`);
22765
+ rethrowIfUnauthorized(err);
22766
+ await authStrategy.enforceValidWixToken?.(err);
22767
+ return errorResult2(message);
22768
+ }
22769
+ }
22770
+ );
22771
+ registered?.update?.({
22772
+ _meta: { ...registered._meta, "openai/fileParams": ["attachments"] }
22773
+ });
22774
+ }
22775
+
22303
22776
  // src/code-mode/index.ts
22304
22777
  var defaultCodeModeFetch = (url, init) => fetch(url, init);
22305
22778
  var SEARCH_TOOL_NAME = "SearchWixAPISpec";
@@ -22497,7 +22970,7 @@ function addExecuteTool(server, options) {
22497
22970
  } = options;
22498
22971
  const executeUrl = `${codeModeBaseUrl}/api/code-mode/execute`;
22499
22972
  const d = desc("ExecuteWixAPI");
22500
- server.tool(
22973
+ const registered = server.tool(
22501
22974
  EXECUTE_TOOL_NAME,
22502
22975
  toolDescriptions?.[EXECUTE_TOOL_NAME] ?? defaultToolDescriptions.ExecuteWixAPI,
22503
22976
  {
@@ -22514,7 +22987,7 @@ function addExecuteTool(server, options) {
22514
22987
  "One sentence explaining the original user request and why you are executing code to complete it."
22515
22988
  ),
22516
22989
  hasMutations: external_exports.boolean().describe(
22517
- 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."
22990
+ 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)."
22518
22991
  ),
22519
22992
  sourceDocUrls: external_exports.array(external_exports.string()).describe(d.sourceDocUrls),
22520
22993
  files: external_exports.string().optional().describe(
@@ -22526,6 +22999,20 @@ function addExecuteTool(server, options) {
22526
22999
  'Use base64 entries for small assets (icons, logos, fonts) and for files you downloaded and are re-uploading; large images/video go in by URL (`<img src="https://...">`), not in the bundle. A file containing a line exactly like the delimiter is not supported.'
22527
23000
  ].join(" ")
22528
23001
  ),
23002
+ // ChatGPT file attachments (`openai/fileParams`). Item shape must match
23003
+ // OpenAI's file schema: download_url + file_id required, the rest optional.
23004
+ // Declaring it is what makes the platform hand us a download URL instead
23005
+ // of a sandbox path. Resolved host-side into base64 `files` entries.
23006
+ attachments: external_exports.array(
23007
+ external_exports.object({
23008
+ download_url: external_exports.string(),
23009
+ file_id: external_exports.string(),
23010
+ file_name: external_exports.string().optional(),
23011
+ mime_type: external_exports.string().optional()
23012
+ })
23013
+ ).optional().describe(
23014
+ 'ChatGPT only. Files attached in the chat or created in your sandbox (any type: a zip of a site, HTML, images, PDFs): pass each file as you have it, its file id or its /mnt/data path, and ChatGPT swaps it for { download_url, file_id, file_name?, mime_type? } before the call reaches Wix. No other client does this swap, so outside ChatGPT a path or file:// URL here fails at once; leave this out and use `files`, or upload from your shell if it reaches the internet. 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.'
23015
+ ),
22529
23016
  // Visitor mode takes an agent-supplied token and pins the site; account/site
22530
23017
  // mode lets the agent pick the site.
22531
23018
  ...visitor ? {
@@ -22538,9 +23025,20 @@ function addExecuteTool(server, options) {
22538
23025
  )
22539
23026
  }
22540
23027
  },
22541
- { readOnlyHint: false, destructiveHint: true, openWorldHint: false },
23028
+ // openWorldHint true: agent code picks the Wix endpoints at run time (and may
23029
+ // receive platform-resolved attachment URLs); the sandbox's host allowlist
23030
+ // bounds it, but the operation set is open-ended, which is what the hint means.
23031
+ { readOnlyHint: false, destructiveHint: true, openWorldHint: true },
22542
23032
  async (rawArgs, extra) => {
22543
- const { code, reason, hasMutations, sourceDocUrls, visitorToken, files } = rawArgs;
23033
+ const {
23034
+ code,
23035
+ reason,
23036
+ hasMutations,
23037
+ sourceDocUrls,
23038
+ visitorToken,
23039
+ files,
23040
+ attachments
23041
+ } = rawArgs;
22544
23042
  const siteId = visitor ? visitor.siteId : rawArgs.siteId;
22545
23043
  logger.log(
22546
23044
  `[ExecuteWixAPI]${visitor ? " (visitor)" : ""} Executing code (${code.length} chars), siteId=${siteId ?? "none"}, hasMutations=${hasMutations}, sourceDocUrls=${JSON.stringify(sourceDocUrls)}, reason="${reason}"`
@@ -22552,6 +23050,13 @@ function addExecuteTool(server, options) {
22552
23050
  );
22553
23051
  return executeTextResult(validation.error);
22554
23052
  }
23053
+ let attachmentFiles = [];
23054
+ try {
23055
+ attachmentFiles = await resolveAttachments(attachments);
23056
+ } catch (e) {
23057
+ if (e instanceof AttachmentError) return executeErrorResult(e.message);
23058
+ throw e;
23059
+ }
22555
23060
  const accountHeaders = await authStrategy?.getAccountAuthHeaders();
22556
23061
  const siteAuthContext = !visitor && authStrategy?.getSiteAuthContext ? await authStrategy.getSiteAuthContext() : void 0;
22557
23062
  let siteHeaders;
@@ -22586,7 +23091,8 @@ function addExecuteTool(server, options) {
22586
23091
  accountToken: visitor ? visitorToken : accountHeaders?.Authorization,
22587
23092
  accountId: accountHeaders?.["wix-account-id"],
22588
23093
  siteAuthContext,
22589
- ...files ? { files } : {}
23094
+ ...files ? { files } : {},
23095
+ ...attachmentFiles.length ? { attachmentFiles } : {}
22590
23096
  },
22591
23097
  visitor ? visitorToken : accountHeaders?.Authorization ?? siteHeaders?.Authorization,
22592
23098
  codeModeFetch
@@ -22617,6 +23123,9 @@ function addExecuteTool(server, options) {
22617
23123
  }
22618
23124
  }
22619
23125
  );
23126
+ registered?.update?.({
23127
+ _meta: { ...registered._meta, "openai/fileParams": ["attachments"] }
23128
+ });
22620
23129
  }
22621
23130
 
22622
23131
  // src/infra/panorama.ts
@@ -22912,6 +23421,13 @@ function createWixToolkit(options) {
22912
23421
  maxResponseSize
22913
23422
  });
22914
23423
  }
23424
+ if (requestedTools.has("UploadHeadlessWebsiteFiles") && !disableTools?.includes("UploadHeadlessWebsiteFiles")) {
23425
+ addUploadHeadlessWebsiteFilesTool(server, {
23426
+ authStrategy,
23427
+ toolDescriptions: effectiveToolDescriptions,
23428
+ clientName
23429
+ });
23430
+ }
22915
23431
  const requestedGraphqlTools = GRAPHQL_TOOL_NAMES.filter(
22916
23432
  (name) => requestedTools.has(name)
22917
23433
  );