@wix/mcp 1.0.23 → 1.0.24

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 (100) hide show
  1. package/build/bin-standalone.js +714 -252
  2. package/build/bin-standalone.js.map +4 -4
  3. package/build/cjs/index.cjs +1137 -362
  4. package/build/cjs/index.cjs.map +4 -4
  5. package/build/dts/api-call/index.d.ts +7 -1
  6. package/build/dts/api-call/index.d.ts.map +1 -1
  7. package/build/dts/api-call/index.js +110 -42
  8. package/build/dts/api-call/index.js.map +1 -1
  9. package/build/dts/api-call/upload-image-tool.d.ts +8 -0
  10. package/build/dts/api-call/upload-image-tool.d.ts.map +1 -0
  11. package/build/dts/api-call/upload-image-tool.js +150 -0
  12. package/build/dts/api-call/upload-image-tool.js.map +1 -0
  13. package/build/dts/api-call/validation.d.ts +1 -0
  14. package/build/dts/api-call/validation.d.ts.map +1 -1
  15. package/build/dts/api-call/validation.js +7 -7
  16. package/build/dts/api-call/validation.js.map +1 -1
  17. package/build/dts/cli-tools/cli.d.ts.map +1 -1
  18. package/build/dts/cli-tools/cli.js +6 -4
  19. package/build/dts/cli-tools/cli.js.map +1 -1
  20. package/build/dts/config/default-config.d.ts +41 -0
  21. package/build/dts/config/default-config.d.ts.map +1 -0
  22. package/build/dts/config/default-config.js +169 -0
  23. package/build/dts/config/default-config.js.map +1 -0
  24. package/build/dts/docs/docs.d.ts +12 -2
  25. package/build/dts/docs/docs.d.ts.map +1 -1
  26. package/build/dts/docs/docs.js +27 -101
  27. package/build/dts/docs/docs.js.map +1 -1
  28. package/build/dts/docs/fetch-article.d.ts +1 -1
  29. package/build/dts/docs/fetch-article.d.ts.map +1 -1
  30. package/build/dts/docs/fetch-article.js +39 -1
  31. package/build/dts/docs/fetch-article.js.map +1 -1
  32. package/build/dts/docs/get-to-know.d.ts +9 -4
  33. package/build/dts/docs/get-to-know.d.ts.map +1 -1
  34. package/build/dts/docs/get-to-know.js +76 -81
  35. package/build/dts/docs/get-to-know.js.map +1 -1
  36. package/build/dts/docs/semanticSearch.d.ts.map +1 -1
  37. package/build/dts/docs/semanticSearch.js +4 -1
  38. package/build/dts/docs/semanticSearch.js.map +1 -1
  39. package/build/dts/docs/semanticSearch.test.js +5 -14
  40. package/build/dts/docs/semanticSearch.test.js.map +1 -1
  41. package/build/dts/index.d.ts +4 -3
  42. package/build/dts/index.d.ts.map +1 -1
  43. package/build/dts/index.js +4 -2
  44. package/build/dts/index.js.map +1 -1
  45. package/build/dts/infra/logger.d.ts +1 -0
  46. package/build/dts/infra/logger.d.ts.map +1 -1
  47. package/build/dts/infra/logger.js +4 -0
  48. package/build/dts/infra/logger.js.map +1 -1
  49. package/build/dts/infra/widget-payload.d.ts +11 -0
  50. package/build/dts/infra/widget-payload.d.ts.map +1 -0
  51. package/build/dts/infra/widget-payload.js +2 -0
  52. package/build/dts/infra/widget-payload.js.map +1 -0
  53. package/build/dts/site-widget-tools/constants.d.ts +4 -0
  54. package/build/dts/site-widget-tools/constants.d.ts.map +1 -0
  55. package/build/dts/site-widget-tools/constants.js +6 -0
  56. package/build/dts/site-widget-tools/constants.js.map +1 -0
  57. package/build/dts/site-widget-tools/edit-site-tool/index.d.ts +4 -0
  58. package/build/dts/site-widget-tools/edit-site-tool/index.d.ts.map +1 -0
  59. package/build/dts/site-widget-tools/edit-site-tool/index.js +171 -0
  60. package/build/dts/site-widget-tools/edit-site-tool/index.js.map +1 -0
  61. package/build/dts/site-widget-tools/index.d.ts +4 -0
  62. package/build/dts/site-widget-tools/index.d.ts.map +1 -0
  63. package/build/dts/site-widget-tools/index.js +4 -0
  64. package/build/dts/site-widget-tools/index.js.map +1 -0
  65. package/build/dts/site-widget-tools/pull-site-creation-job-tool/index.d.ts +4 -0
  66. package/build/dts/site-widget-tools/pull-site-creation-job-tool/index.d.ts.map +1 -0
  67. package/build/dts/{pull-site-creation-job-tool → site-widget-tools/pull-site-creation-job-tool}/index.js +60 -27
  68. package/build/dts/site-widget-tools/pull-site-creation-job-tool/index.js.map +1 -0
  69. package/build/dts/site-widget-tools/pull-site-creation-job-tool/types.d.ts +52 -0
  70. package/build/dts/site-widget-tools/pull-site-creation-job-tool/types.d.ts.map +1 -0
  71. package/build/dts/site-widget-tools/pull-site-creation-job-tool/types.js +2 -0
  72. package/build/dts/site-widget-tools/pull-site-creation-job-tool/types.js.map +1 -0
  73. package/build/dts/site-widget-tools/site-builder-tool/index.d.ts +4 -0
  74. package/build/dts/site-widget-tools/site-builder-tool/index.d.ts.map +1 -0
  75. package/build/dts/{site-builder-tool → site-widget-tools/site-builder-tool}/index.js +13 -16
  76. package/build/dts/site-widget-tools/site-builder-tool/index.js.map +1 -0
  77. package/build/dts/support/index.d.ts.map +1 -1
  78. package/build/dts/support/index.js +10 -16
  79. package/build/dts/support/index.js.map +1 -1
  80. package/build/dts/wix-mcp-server.d.ts +2 -0
  81. package/build/dts/wix-mcp-server.d.ts.map +1 -1
  82. package/build/dts/wix-mcp-server.js +8 -0
  83. package/build/dts/wix-mcp-server.js.map +1 -1
  84. package/build/esm/index.js +1129 -362
  85. package/build/esm/index.js.map +4 -4
  86. package/package.json +28 -25
  87. package/build/dts/pull-site-creation-job-tool/constants.d.ts +0 -3
  88. package/build/dts/pull-site-creation-job-tool/constants.d.ts.map +0 -1
  89. package/build/dts/pull-site-creation-job-tool/constants.js +0 -3
  90. package/build/dts/pull-site-creation-job-tool/constants.js.map +0 -1
  91. package/build/dts/pull-site-creation-job-tool/index.d.ts +0 -21
  92. package/build/dts/pull-site-creation-job-tool/index.d.ts.map +0 -1
  93. package/build/dts/pull-site-creation-job-tool/index.js.map +0 -1
  94. package/build/dts/site-builder-tool/constants.d.ts +0 -7
  95. package/build/dts/site-builder-tool/constants.d.ts.map +0 -1
  96. package/build/dts/site-builder-tool/constants.js +0 -7
  97. package/build/dts/site-builder-tool/constants.js.map +0 -1
  98. package/build/dts/site-builder-tool/index.d.ts +0 -4
  99. package/build/dts/site-builder-tool/index.d.ts.map +0 -1
  100. package/build/dts/site-builder-tool/index.js.map +0 -1
@@ -207,7 +207,7 @@ var require_toPropertyKey = __commonJS({
207
207
  var require_defineProperty = __commonJS({
208
208
  "../../node_modules/@babel/runtime/helpers/defineProperty.js"(exports, module) {
209
209
  var toPropertyKey = require_toPropertyKey();
210
- function _defineProperty(e, r, t) {
210
+ function _defineProperty2(e, r, t) {
211
211
  return (r = toPropertyKey(r)) in e ? Object.defineProperty(e, r, {
212
212
  value: t,
213
213
  enumerable: true,
@@ -215,7 +215,7 @@ var require_defineProperty = __commonJS({
215
215
  writable: true
216
216
  }) : e[r] = t, e;
217
217
  }
218
- module.exports = _defineProperty, module.exports.__esModule = true, module.exports["default"] = module.exports;
218
+ module.exports = _defineProperty2, module.exports.__esModule = true, module.exports["default"] = module.exports;
219
219
  }
220
220
  });
221
221
 
@@ -1721,7 +1721,7 @@ function __importStar(mod) {
1721
1721
  if (mod && mod.__esModule) return mod;
1722
1722
  var result = {};
1723
1723
  if (mod != null) {
1724
- for (var k = ownKeys(mod), i = 0; i < k.length; i++) if (k[i] !== "default") __createBinding(result, mod, k[i]);
1724
+ for (var k = ownKeys2(mod), i = 0; i < k.length; i++) if (k[i] !== "default") __createBinding(result, mod, k[i]);
1725
1725
  }
1726
1726
  __setModuleDefault(result, mod);
1727
1727
  return result;
@@ -1805,7 +1805,7 @@ function __rewriteRelativeImportExtension(path3, preserveJsx) {
1805
1805
  }
1806
1806
  return path3;
1807
1807
  }
1808
- var extendStatics, __assign, __createBinding, __setModuleDefault, ownKeys, _SuppressedError, tslib_es6_default;
1808
+ var extendStatics, __assign, __createBinding, __setModuleDefault, ownKeys2, _SuppressedError, tslib_es6_default;
1809
1809
  var init_tslib_es6 = __esm({
1810
1810
  "../../node_modules/tslib/tslib.es6.mjs"() {
1811
1811
  extendStatics = function(d, b) {
@@ -1844,13 +1844,13 @@ var init_tslib_es6 = __esm({
1844
1844
  }) : function(o, v) {
1845
1845
  o["default"] = v;
1846
1846
  };
1847
- ownKeys = function(o) {
1848
- ownKeys = Object.getOwnPropertyNames || function(o2) {
1847
+ ownKeys2 = function(o) {
1848
+ ownKeys2 = Object.getOwnPropertyNames || function(o2) {
1849
1849
  var ar = [];
1850
1850
  for (var k in o2) if (Object.prototype.hasOwnProperty.call(o2, k)) ar[ar.length] = k;
1851
1851
  return ar;
1852
1852
  };
1853
- return ownKeys(o);
1853
+ return ownKeys2(o);
1854
1854
  };
1855
1855
  _SuppressedError = typeof SuppressedError === "function" ? SuppressedError : function(error, suppressed, message) {
1856
1856
  var e = new Error(message);
@@ -10317,7 +10317,6 @@ var runSemanticSearch = async (toolName, toolParams, maxResults = 20, rerank = f
10317
10317
  url.searchParams.append("kbName", "REST_METHODS_KB_ID");
10318
10318
  }
10319
10319
  url.searchParams.append("kbName", "REST_DOCS_KB_ID");
10320
- url.searchParams.append("kbName", "MCP_REST_RECIPES_KB_ID");
10321
10320
  } else if (toolName === "WDS") {
10322
10321
  url.searchParams.append("kbName", "WDS_DOCS_KB_ID");
10323
10322
  } else if (toolName === "BUILD_APPS") {
@@ -10432,6 +10431,22 @@ var GET_ARTICLE_CONTENT_URL = `${RAW_DOCS_API_URL}/get-article-content`;
10432
10431
  var PORTAL_INDEX_URL = `${RAW_DOCS_API_URL}/portal-index`;
10433
10432
 
10434
10433
  // src/docs/fetch-article.ts
10434
+ var PICASSO_URL_PREFIX = "https://dev.wix.com/docs/picasso/";
10435
+ function applyPicassoUrlOverride(articleUrl, picassoPortalUrl) {
10436
+ if (!picassoPortalUrl) {
10437
+ return articleUrl;
10438
+ }
10439
+ if (articleUrl.startsWith(PICASSO_URL_PREFIX)) {
10440
+ const baseUrl = picassoPortalUrl.replace(/\/$/, "");
10441
+ const pathAfterPicasso = articleUrl.slice(PICASSO_URL_PREFIX.length);
10442
+ const overriddenUrl = `${baseUrl}/${pathAfterPicasso}`;
10443
+ logger.log(
10444
+ `[Picasso URL Override] Redirecting ${articleUrl} to ${overriddenUrl}`
10445
+ );
10446
+ return overriddenUrl;
10447
+ }
10448
+ return articleUrl;
10449
+ }
10435
10450
  async function fetchArticleContentFromDigor(httpClient, articleUrl, mode, stripHeader = false) {
10436
10451
  const url = new URL(GET_ARTICLE_CONTENT_URL);
10437
10452
  url.searchParams.set("articleUrl", articleUrl);
@@ -10451,7 +10466,20 @@ async function fetchArticleContentFromDigor(httpClient, articleUrl, mode, stripH
10451
10466
  }
10452
10467
  return data.articleContent;
10453
10468
  }
10454
- async function fetchArticleContent(httpClient, articleUrl, mode, stripHeader = false) {
10469
+ async function fetchArticleContent(httpClient, articleUrl, mode, stripHeader = false, picassoPortalUrl) {
10470
+ const effectiveUrl = applyPicassoUrlOverride(articleUrl, picassoPortalUrl);
10471
+ const isOverridden = effectiveUrl !== articleUrl;
10472
+ if (isOverridden) {
10473
+ try {
10474
+ const { data: doc } = await httpClient.get(effectiveUrl);
10475
+ return doc;
10476
+ } catch (error) {
10477
+ console.warn(
10478
+ `[fetch] Override failed for ${effectiveUrl}, falling back to ${articleUrl}:`,
10479
+ error instanceof Error ? error.message : error
10480
+ );
10481
+ }
10482
+ }
10455
10483
  if (mode === "raw") {
10456
10484
  let parsedUrl;
10457
10485
  try {
@@ -10476,117 +10504,365 @@ async function fetchArticleContent(httpClient, articleUrl, mode, stripHeader = f
10476
10504
  );
10477
10505
  }
10478
10506
 
10479
- // src/docs/get-to-know.ts
10480
- var DEFAULT_DOC_URLS = [
10507
+ // ../../node_modules/dedent/dist/dedent.mjs
10508
+ function ownKeys(object, enumerableOnly) {
10509
+ var keys = Object.keys(object);
10510
+ if (Object.getOwnPropertySymbols) {
10511
+ var symbols = Object.getOwnPropertySymbols(object);
10512
+ enumerableOnly && (symbols = symbols.filter(function(sym) {
10513
+ return Object.getOwnPropertyDescriptor(object, sym).enumerable;
10514
+ })), keys.push.apply(keys, symbols);
10515
+ }
10516
+ return keys;
10517
+ }
10518
+ function _objectSpread(target) {
10519
+ for (var i = 1; i < arguments.length; i++) {
10520
+ var source = null != arguments[i] ? arguments[i] : {};
10521
+ i % 2 ? ownKeys(Object(source), true).forEach(function(key) {
10522
+ _defineProperty(target, key, source[key]);
10523
+ }) : Object.getOwnPropertyDescriptors ? Object.defineProperties(target, Object.getOwnPropertyDescriptors(source)) : ownKeys(Object(source)).forEach(function(key) {
10524
+ Object.defineProperty(target, key, Object.getOwnPropertyDescriptor(source, key));
10525
+ });
10526
+ }
10527
+ return target;
10528
+ }
10529
+ function _defineProperty(obj, key, value) {
10530
+ key = _toPropertyKey(key);
10531
+ if (key in obj) {
10532
+ Object.defineProperty(obj, key, { value, enumerable: true, configurable: true, writable: true });
10533
+ } else {
10534
+ obj[key] = value;
10535
+ }
10536
+ return obj;
10537
+ }
10538
+ function _toPropertyKey(arg) {
10539
+ var key = _toPrimitive(arg, "string");
10540
+ return typeof key === "symbol" ? key : String(key);
10541
+ }
10542
+ function _toPrimitive(input, hint) {
10543
+ if (typeof input !== "object" || input === null) return input;
10544
+ var prim = input[Symbol.toPrimitive];
10545
+ if (prim !== void 0) {
10546
+ var res = prim.call(input, hint || "default");
10547
+ if (typeof res !== "object") return res;
10548
+ throw new TypeError("@@toPrimitive must return a primitive value.");
10549
+ }
10550
+ return (hint === "string" ? String : Number)(input);
10551
+ }
10552
+ var dedent = createDedent({});
10553
+ var dedent_default = dedent;
10554
+ function createDedent(options) {
10555
+ dedent2.withOptions = (newOptions) => createDedent(_objectSpread(_objectSpread({}, options), newOptions));
10556
+ return dedent2;
10557
+ function dedent2(strings, ...values) {
10558
+ const raw = typeof strings === "string" ? [strings] : strings.raw;
10559
+ const {
10560
+ alignValues = false,
10561
+ escapeSpecialCharacters = Array.isArray(strings),
10562
+ trimWhitespace = true
10563
+ } = options;
10564
+ let result = "";
10565
+ for (let i = 0; i < raw.length; i++) {
10566
+ let next = raw[i];
10567
+ if (escapeSpecialCharacters) {
10568
+ next = next.replace(/\\\n[ \t]*/g, "").replace(/\\`/g, "`").replace(/\\\$/g, "$").replace(/\\\{/g, "{");
10569
+ }
10570
+ result += next;
10571
+ if (i < values.length) {
10572
+ const value = alignValues ? alignValue(values[i], result) : values[i];
10573
+ result += value;
10574
+ }
10575
+ }
10576
+ const lines = result.split("\n");
10577
+ let mindent = null;
10578
+ for (const l of lines) {
10579
+ const m = l.match(/^(\s+)\S+/);
10580
+ if (m) {
10581
+ const indent = m[1].length;
10582
+ if (!mindent) {
10583
+ mindent = indent;
10584
+ } else {
10585
+ mindent = Math.min(mindent, indent);
10586
+ }
10587
+ }
10588
+ }
10589
+ if (mindent !== null) {
10590
+ const m = mindent;
10591
+ result = lines.map((l) => l[0] === " " || l[0] === " " ? l.slice(m) : l).join("\n");
10592
+ }
10593
+ if (trimWhitespace) {
10594
+ result = result.trim();
10595
+ }
10596
+ if (escapeSpecialCharacters) {
10597
+ result = result.replace(/\\n/g, "\n");
10598
+ }
10599
+ if (typeof Bun !== "undefined") {
10600
+ result = result.replace(
10601
+ // Matches e.g. \\u{1f60a} or \\u5F1F
10602
+ /\\u(?:\{([\da-fA-F]{1,6})\}|([\da-fA-F]{4}))/g,
10603
+ (_, braced, unbraced) => {
10604
+ var _ref;
10605
+ const hex = (_ref = braced !== null && braced !== void 0 ? braced : unbraced) !== null && _ref !== void 0 ? _ref : "";
10606
+ return String.fromCodePoint(parseInt(hex, 16));
10607
+ }
10608
+ );
10609
+ }
10610
+ return result;
10611
+ }
10612
+ }
10613
+ function alignValue(value, precedingText) {
10614
+ if (typeof value !== "string" || !value.includes("\n")) {
10615
+ return value;
10616
+ }
10617
+ const currentLine = precedingText.slice(precedingText.lastIndexOf("\n") + 1);
10618
+ const indentMatch = currentLine.match(/^(\s+)/);
10619
+ if (indentMatch) {
10620
+ const indent = indentMatch[1];
10621
+ return value.replace(/\n/g, `
10622
+ ${indent}`);
10623
+ }
10624
+ return value;
10625
+ }
10626
+
10627
+ // src/config/default-config.ts
10628
+ var SYSTEM_REMINDER = dedent_default`
10629
+ <system-reminder>
10630
+ Wix MCP Site Management Flows:
10631
+ - RECIPE BASED (PREFERRED!): WixREADME() -> find relevant recipe for the user's prompt/task -> read recipe using ReadFullDocsArticle() -> call API using CallWixSiteAPI() based on the recipe
10632
+ - EXAMPLE BASED: WixREADME() -> no relevant recipe found for user's prompt/task -> SearchWixRESTDocumentation() -> find relevant method -> read method article using ReadFullDocsArticle() to get method code examples -> call API using CallWixSiteAPI() based on the method code examples
10633
+ - SCHEMA BASED, FALLBACK: WixREADME() -> no relevant recipe found for user's prompt/task -> SearchWixRESTDocumentation() -> find relevant method -> read method article using ReadFullDocsArticle() -> no method code examples found -> read method schema using ReadFullDocsMethodSchema() -> call API using CallWixSiteAPI() based on the schema
10634
+ </system-reminder>
10635
+ `;
10636
+ var defaultToolDescriptions = {
10637
+ WixREADME: dedent_default`
10638
+ # Tool: WixREADME
10639
+ **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**.
10640
+ ${SYSTEM_REMINDER}
10641
+ `,
10642
+ SearchWixRESTDocumentation: dedent_default`
10643
+ Searches the official Wix REST API documentation.
10644
+ Use this tool whenever you need to to interact with the Wix platform via HTTP requests.
10645
+ Specify the API endpoint, resource, or action you need information about (e.g., 'get site details endpoint', 'create data collection', 'update product API', 'REST authentication').
10646
+ If you can't find what you need, try to rephrase your search term or use bigger maxResults value.
10647
+ ${SYSTEM_REMINDER}
10648
+ `,
10649
+ ReadFullDocsArticle: dedent_default`
10650
+ Fetches the full Wix docs article or method article with code examples for using the method.
10651
+ Docs articles looks like this: https://dev.wix.com/docs/... and they can either be general docs articles or method articles.
10652
+ ${SYSTEM_REMINDER}
10653
+ `,
10654
+ ReadFullDocsMethodSchema: dedent_default`
10655
+ Fetches the full method schema for a given method.
10656
+ This will give you the entire request/response schema with all the fields and their descriptions.
10657
+ ${SYSTEM_REMINDER}
10658
+ `,
10659
+ CallWixSiteAPI: dedent_default`
10660
+ 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,
10661
+ The API endpoint url param MUST ALWAYS be taken from the conversation context.
10662
+ By conversation context we mean the endpoint url was given in the user prompt or got into the conversation context by the "WixREADME" tool or by the "SearchWixRESTDocumentation" tool or by the "ReadFullDocsArticle" tool.
10663
+ Error Handling:
10664
+ If the error is related to missing installed app or "WDE0110: Wix Code not enabled", you should install the missing app by using ReadFullDocsArticle tool to fetch the article - https://dev.wix.com/docs/kb-only/MCP_REST_RECIPES_KB_ID/TRAIN_wix.devcenter.apps.installer.v1.AppsInstallerService.InstallApp
10665
+ **Note:** there is no need to check if an app is installed/ Wix Code enabled in advance, just call the API and handle the error if it occurs, the API error message will state it clearly.
10666
+ For any other error, use your default error handling mechanism
10667
+ Allowed API urls are: wix.com, dev.wix.com, manage.wix.com, editor.wix.com, wixapis.com
10668
+ Docs urls like https://dev.wix.com/docs/... are not api urls, if you want to read the docs, use the "ReadFullDocsArticle" tool
10669
+ ${SYSTEM_REMINDER}
10670
+ `,
10671
+ ListWixSites: dedent_default`
10672
+ List Wix sites for the current user, by default it will return all sites, but you can filter by name
10673
+ ${SYSTEM_REMINDER}
10674
+ `,
10675
+ ManageWixSite: dedent_default`
10676
+ Use account level API in order to create a site, update a site and publish site.
10677
+ The API endpoint url param MUST ALWAYS be taken from the conversation context.
10678
+ By conversation context we mean the endpoint url was given in the user prompt or got into the conversation context by the "WixREADME" tool or by the "SearchWixRESTDocumentation" tool or by the "ReadFullDocsArticle" tool.
10679
+ ${SYSTEM_REMINDER}
10680
+ `,
10681
+ UploadImageToWixSite: dedent_default`
10682
+ Upload an image file to a Wix site Media Manager.
10683
+ This tool accepts an image from the user and uploads it to the specified Wix site.
10684
+ Returns the uploaded file URL (wixstatic.com) and media ID that can be used in other Wix APIs.
10685
+ Use this when the user wants to upload a local image to their Wix site.
10686
+ `,
10687
+ SupportAndFeedback: dedent_default`
10688
+ If the user would like to provide Wix with some feedback (good or bad), about the tools in Wix MCP,
10689
+ for example they used the tools provided, and they reflected satisfaction or dissatisfaction with the tools.
10690
+ Also, if you encounter too many errors tyring to call the Wix API, you can also suggest the user to provide feedback to Wix using this tool.
10691
+ **IMPORTANT NOTE**
10692
+ This tool is not sending the message, but formats it in order to another tool to actually send it
10693
+ `
10694
+ };
10695
+ var defaultReadmeDocs = [
10481
10696
  {
10482
- url: "https://dev.wix.com/docs/picasso/wix-ai-docs/index/get-to-know-wix-llm-instructions",
10483
- action: "include"
10697
+ action: "text",
10698
+ content: dedent_default`
10699
+ <system>
10700
+
10701
+ The main goal of the WixREADME tool is to help you manage your Wix business by making API calls to the Wix API.
10702
+
10703
+ A common flow would be:
10704
+ 1. User asks you to do something,
10705
+ 2. You use the "WixREADME" tool to get the context,
10706
+ 3. You find a relevant recipe in the recipes index,
10707
+ 4. You use the "ReadFullDocsArticle" tool to get the full recipe,
10708
+ 5. You use the "CallWixSiteAPI" tool to call the API (No need to search or read the full schema, just call the API according to the recipe)
10709
+
10710
+ Another flow would be:
10711
+ 1. User asks you to do something,
10712
+ 2. You use the "WixREADME" tool to get the context,
10713
+ 3. You do not find a relevant recipe in the recipes index,
10714
+ 4. You use the "SearchWixRESTDocumentation" tool to search for the API you should invoke,
10715
+ 5. You read the relevant articles using the "ReadFullDocsArticle" tool,
10716
+ 6. You find a relevant code example in the articles,
10717
+ 7. You use the "CallWixSiteAPI" tool to call the API. (No need to read the full schema, just call the API according to the code example)
10718
+
10719
+ Fallback flow (No relevant recipe or code example found, or you failed using the other flows):
10720
+ 1. User asks you to do something,
10721
+ 2. You use the "WixREADME" tool to get the context,
10722
+ 3. You do not find a relevant recipe in the recipes index,
10723
+ 4. You use the "SearchWixRESTDocumentation" tool to search for the API you should invoke,
10724
+ 5. You read the relevant articles using the "ReadFullDocsArticle" tool,
10725
+ 6. You do not find a relevant code example in the articles,
10726
+ 7. You use the "ReadFullDocsMethodSchema" tool to get the full method schema,
10727
+ 8. You use the "CallWixSiteAPI" tool to call the API. (No need to search or read the full schema, just call the API according to the method schema)
10728
+ </system>
10729
+ `
10484
10730
  },
10485
10731
  {
10486
- url: "https://dev.wix.com/docs/picasso/wix-ai-docs/index/wix-concepts",
10732
+ url: "https://dev.wix.com/docs/picasso/wix-ai-docs/recipes-v2/manage/management-recipes-index",
10487
10733
  action: "include"
10488
10734
  },
10489
10735
  {
10490
10736
  url: "https://dev.wix.com/docs/picasso/wix-ai-docs/index/wix-business-solutions",
10491
10737
  action: "index",
10492
10738
  title: "Wix Business Solutions",
10493
- description: `This document provides an overview of the all business solutions available in Wix.
10494
-
10495
- Use this document under the following scenarios:
10496
- 1. The user asks general questions about Wix business solutions.
10497
- 2. The user asks about a specific business solution, and you want to provide a high-level overview of it.
10498
- 3. The user looks for a specific business solution, and you want to provide a list of all available solutions.
10499
-
10500
- Please note that this is a large document. Only use it for the scenarios mentioned above.`
10501
- },
10502
- {
10503
- url: "https://dev.wix.com/docs/picasso/wix-ai-docs/index/wix-business-solutions-recipes",
10504
- action: "include"
10739
+ description: dedent_default`
10740
+ This document provides an overview of the all business solutions available in Wix.
10741
+
10742
+ Use this document under the following scenarios:
10743
+ 1. The user asks general questions about Wix business solutions.
10744
+ 2. The user asks about a specific business solution, and you want to provide a high-level overview of it.
10745
+ 3. The user looks for a specific business solution, and you want to provide a list of all available solutions.
10746
+
10747
+ Please note that this is a large document. Only use it for the scenarios mentioned above.
10748
+ `
10505
10749
  }
10506
10750
  ];
10507
- var DESCRIPTION = `# Tool: WixREADME
10508
-
10509
- **Directive:** \`WixREADME\` is the **MANDATORY FIRST STEP** for all Wix-related tasks EXCEPT when the user explicitly asks to build/create a site - in which case you should use the \`WixSiteBuilderWidget\` tool directly. Its output (including relevant linked documents) provides foundational context for all other Wix tools. Adherence to this protocol is **NON-NEGOTIABLE**.
10510
-
10511
- **Operational Protocol (Strictly Sequential):**
10512
-
10513
- 1. **Execute \`WixREADME\`:**
10514
- * **Action:** Invoke \`WixREADME\`.
10515
- * **Constraint:** MUST complete successfully. NO other Wix tool before this.
10516
-
10517
- 2. **Process \`WixREADME\` Output (Link Identification & Relevance Assessment):**
10518
- * **A. Identify Candidate Links:** Scan \`WixREADME\` output. Extract *only* URLs found within \`<urls>{urls}</urls>\` tags. Ignore all other URLs.
10519
- * **B. Assess Relevance:** For EACH candidate URL from (A), assess its relevance to the **current user's specific prompt/task**.
10520
- * **Outcome:** A list of *relevant* document URLs. If no links are found in \`<urls>\` tags or none are deemed relevant, note this and proceed to Step 4.
10521
-
10522
- 3. **Fetch Relevant Documents (via \`ReadFullDocsArticle\`):**
10523
- * **Condition:** ONLY if Step 2B identified one or more *relevant* URLs.
10524
- * **Action:** For EACH *relevant* URL, invoke \`ReadFullDocsArticle\` to fetch its full content.
10525
- * **Constraint:** All *relevant* documents MUST be fetched before Step 4.
10526
-
10527
- 4. **Proceed with Other Wix Tools:**
10528
- * **Condition:** ONLY after completing Steps 1, 2, and 3 (if Step 3 was applicable).
10529
- * **Action:** Use other Wix tools as needed, utilizing the full context from \`WixREADME\` and fetched relevant documents.
10530
-
10531
- **Summary of Critical Rules:**
10532
- * \`WixREADME\` is **ALWAYS FIRST**.
10533
- * Analyze \`WixREADME\` output: Extract links *only* from \`<urls>{urls}</urls>\` tags.
10534
- * Assess relevance of *each* extracted link against the user's current task.
10535
- * Fetch **ONLY RELEVANT** linked documents using \`ReadFullDocsArticle\` before any other Wix tool.
10536
- * **FAILURE TO FOLLOW THIS EXACT SEQUENCE WILL LEAD TO ERRORS.** Strict adherence is mandatory.`;
10537
- var WixREADME_DEPENDENT_DESCRIPTION = "**Dependency:** Must be used after 'WixREADME' has successfully run.";
10538
- async function addGetToKnowTools(server2, disableTools = [], toolDescriptions, readmeDocs) {
10751
+
10752
+ // src/docs/get-to-know.ts
10753
+ async function addGetToKnowTools(server2, disableTools = [], toolDescriptions, readmeDocs, authStrategy, picassoPortalUrl) {
10539
10754
  if (disableTools.includes("WixREADME")) {
10540
10755
  return;
10541
10756
  }
10542
- const docsToUse = readmeDocs && readmeDocs.length > 0 ? readmeDocs : DEFAULT_DOC_URLS;
10757
+ const docsToUse = readmeDocs ?? defaultReadmeDocs;
10543
10758
  server2.tool(
10544
10759
  "WixREADME",
10545
- toolDescriptions?.["WixREADME"] ?? DESCRIPTION,
10760
+ toolDescriptions?.["WixREADME"] ?? defaultToolDescriptions.WixREADME,
10546
10761
  {},
10547
10762
  { readOnlyHint: true, destructiveHint: false, openWorldHint: false },
10548
10763
  async (_, { httpClient }) => {
10549
- try {
10550
- const contents = await Promise.all(
10551
- docsToUse.map(async ({ url, action, description, title }) => {
10552
- if (action === "index") {
10553
- return {
10554
- type: "text",
10555
- text: `## ${title}
10764
+ const contents = await Promise.all(
10765
+ docsToUse.map(
10766
+ async ({
10767
+ url,
10768
+ action,
10769
+ description,
10770
+ title,
10771
+ content,
10772
+ method,
10773
+ body
10774
+ }) => {
10775
+ try {
10776
+ if (action === "index") {
10777
+ return {
10778
+ type: "text",
10779
+ text: `## ${title}
10556
10780
 
10557
10781
  <urls>
10558
10782
  ${url}
10559
10783
  </urls>
10560
10784
 
10561
10785
  ${description ?? ""}`
10786
+ };
10787
+ }
10788
+ if (action === "text") {
10789
+ const textContent = title ? `## ${title}
10790
+
10791
+ ${content ?? ""}` : content ?? "";
10792
+ return {
10793
+ type: "text",
10794
+ text: textContent
10795
+ };
10796
+ }
10797
+ if (action === "api") {
10798
+ if (!url) {
10799
+ throw new Error('URL is required for "api" action');
10800
+ }
10801
+ if (!authStrategy) {
10802
+ throw new Error(
10803
+ 'Authentication strategy is required for "api" action. The "api" action cannot be used without proper authentication configuration.'
10804
+ );
10805
+ }
10806
+ const httpMethod = method ?? "GET";
10807
+ const accountHeaders = await authStrategy.getAccountAuthHeaders();
10808
+ const response = await httpClient.request({
10809
+ url,
10810
+ method: httpMethod,
10811
+ headers: {
10812
+ ...accountHeaders,
10813
+ ...body ? { "Content-Type": "application/json" } : {}
10814
+ },
10815
+ data: httpMethod === "GET" ? void 0 : body
10816
+ });
10817
+ const responseText = typeof response.data === "string" ? response.data : JSON.stringify(response.data, null, 2);
10818
+ const textContent = title ? `## ${title}
10819
+
10820
+ ${responseText}` : responseText;
10821
+ return {
10822
+ type: "text",
10823
+ text: textContent
10824
+ };
10825
+ }
10826
+ if (!url) {
10827
+ throw new Error('URL is required for "include" action');
10828
+ }
10829
+ const fetchedContent = await fetchArticleContent(
10830
+ httpClient,
10831
+ url,
10832
+ "article",
10833
+ true,
10834
+ picassoPortalUrl
10835
+ );
10836
+ return {
10837
+ type: "text",
10838
+ text: fetchedContent
10839
+ };
10840
+ } catch (error) {
10841
+ const errorMsg = error.message;
10842
+ const identifier = title ?? url ?? action;
10843
+ if (action === "api") {
10844
+ console.error(
10845
+ `[WixREADME] API call failed for "${identifier}": ${errorMsg}`
10846
+ );
10847
+ return null;
10848
+ }
10849
+ return {
10850
+ type: "text",
10851
+ text: `## Error loading "${identifier}"
10852
+
10853
+ Failed to fetch content: ${errorMsg}`
10562
10854
  };
10563
10855
  }
10564
- const content = await fetchArticleContent(
10565
- httpClient,
10566
- url,
10567
- "article",
10568
- true
10569
- );
10570
- return {
10571
- type: "text",
10572
- text: content
10573
- };
10574
- })
10575
- );
10576
- return {
10577
- content: contents
10578
- };
10579
- } catch (error) {
10580
- return {
10581
- isError: true,
10582
- content: [
10583
- {
10584
- type: "text",
10585
- text: `Error fetching the document: ${error.message}`
10586
- }
10587
- ]
10588
- };
10589
- }
10856
+ }
10857
+ )
10858
+ );
10859
+ const filteredContents = contents.filter(
10860
+ (item) => item !== null
10861
+ );
10862
+ const concatenatedText = filteredContents.map((item) => item.text).join("\n\n");
10863
+ return {
10864
+ content: [{ type: "text", text: concatenatedText }]
10865
+ };
10590
10866
  }
10591
10867
  );
10592
10868
  }
@@ -10699,11 +10975,20 @@ var addDocsTools = (server2, allowedTools = [
10699
10975
  createWixBusinessGuideEnabled = true,
10700
10976
  disableTools,
10701
10977
  toolDescriptions,
10702
- readmeDocs
10978
+ readmeDocs,
10979
+ authStrategy,
10980
+ picassoPortalUrl
10703
10981
  } = options;
10704
10982
  const getDescription = (toolName, defaultDesc) => toolDescriptions?.[toolName] ?? defaultDesc;
10705
10983
  if (getToKnowWixEnabled && !disableTools?.includes("WixREADME")) {
10706
- addGetToKnowTools(server2, disableTools || [], toolDescriptions, readmeDocs);
10984
+ addGetToKnowTools(
10985
+ server2,
10986
+ disableTools || [],
10987
+ toolDescriptions,
10988
+ readmeDocs,
10989
+ authStrategy,
10990
+ picassoPortalUrl
10991
+ );
10707
10992
  }
10708
10993
  if (createWixBusinessGuideEnabled && !disableTools?.includes("CreateWixBusinessGuide")) {
10709
10994
  addCreateWixBusinessGuideTools(
@@ -10713,16 +10998,12 @@ var addDocsTools = (server2, allowedTools = [
10713
10998
  );
10714
10999
  }
10715
11000
  if (allowedTools.includes("WDS") && !disableTools?.includes("SearchWixWDSDocumentation")) {
10716
- const defaultWdsDesc = [
10717
- "Searches the Wix Design System Documentation for components and patterns.",
10718
- "Use this tool when you need to understand or implement UI components and design patterns in a Wix project.",
10719
- "Search for specific component names, patterns, or UI requirements.",
10720
- "If you can't find what you need, try to rephrase your search term or use bigger maxResults value.",
10721
- getToKnowWixEnabled ? WixREADME_DEPENDENT_DESCRIPTION : ""
10722
- ].join("\n");
10723
11001
  server2.tool(
10724
11002
  "SearchWixWDSDocumentation",
10725
- getDescription("SearchWixWDSDocumentation", defaultWdsDesc),
11003
+ getDescription(
11004
+ "SearchWixWDSDocumentation",
11005
+ defaultToolDescriptions.SearchWixWDSDocumentation ?? ""
11006
+ ),
10726
11007
  {
10727
11008
  searchTerm: z.string().describe(
10728
11009
  "The search term to search for in the Wix Design System Documentation"
@@ -10770,16 +11051,12 @@ var addDocsTools = (server2, allowedTools = [
10770
11051
  );
10771
11052
  }
10772
11053
  if (allowedTools.includes("REST") && !disableTools?.includes("SearchWixRESTDocumentation")) {
10773
- const defaultRestDesc = [
10774
- "Searches the official Wix REST API documentation.",
10775
- "Use this tool whenever you need to to interact with the Wix platform via HTTP requests.",
10776
- "Specify the API endpoint, resource, or action you need information about (e.g., 'get site details endpoint', 'create data collection', 'update product API', 'REST authentication').",
10777
- "If you can't find what you need, try to rephrase your search term or use bigger maxResults value.",
10778
- getToKnowWixEnabled ? WixREADME_DEPENDENT_DESCRIPTION : ""
10779
- ].join("\n");
10780
11054
  server2.tool(
10781
11055
  "SearchWixRESTDocumentation",
10782
- getDescription("SearchWixRESTDocumentation", defaultRestDesc),
11056
+ getDescription(
11057
+ "SearchWixRESTDocumentation",
11058
+ defaultToolDescriptions.SearchWixRESTDocumentation
11059
+ ),
10783
11060
  {
10784
11061
  searchTerm: z.string().describe(
10785
11062
  "The search term to search for in the Wix REST API Documentation"
@@ -10805,10 +11082,6 @@ var addDocsTools = (server2, allowedTools = [
10805
11082
  {
10806
11083
  type: "text",
10807
11084
  text: result
10808
- },
10809
- {
10810
- type: "text",
10811
- text: "Next, you MUST use the ReadFullDocsArticle tool if you want to read the full documentation for a specific article or method."
10812
11085
  }
10813
11086
  ]
10814
11087
  };
@@ -10832,19 +11105,12 @@ var addDocsTools = (server2, allowedTools = [
10832
11105
  );
10833
11106
  }
10834
11107
  if (allowedTools.includes("BUSINESS_SOLUTIONS") && !getToKnowWixEnabled && !disableTools?.includes("WixBusinessFlowsDocumentation")) {
10835
- const defaultBusinessDesc = [
10836
- "This tool provides step-by-step recipes for setting up complex Wix business solutions that involve multiple API calls.",
10837
- "It excels at guiding the creation of features like booking systems with payments.",
10838
- "For example, it can guide the setup of a service in Wix Bookings where customers can pay using Wix Payments, such as creating a bookable yoga class",
10839
- "It searches the Wix Business Solutions documentation for these integrated workflows involving services, bookings, payments, stores, blogs, and more.",
10840
- "This tool returns a list of articles that are potentially relevant to the input search term.",
10841
- "**IMPORTANT NOTES:**",
10842
- "1. Before attempting to implement a multi step API calls on Wix, YOU MUST TRY THIS TOOL FIRST.",
10843
- "2. Out of the returned list of articles that you will receive, you MUST select the most relevant one and use the ReadFullDocsArticle tool to fetch it."
10844
- ].join("\n");
10845
11108
  server2.tool(
10846
11109
  "WixBusinessFlowsDocumentation",
10847
- getDescription("WixBusinessFlowsDocumentation", defaultBusinessDesc),
11110
+ getDescription(
11111
+ "WixBusinessFlowsDocumentation",
11112
+ defaultToolDescriptions.WixBusinessFlowsDocumentation ?? ""
11113
+ ),
10848
11114
  {
10849
11115
  searchTerm: z.string().describe(
10850
11116
  'The search term for the required sample flow (e.g. "setup a new business")'
@@ -10868,11 +11134,10 @@ var addDocsTools = (server2, allowedTools = [
10868
11134
  content: [
10869
11135
  {
10870
11136
  type: "text",
10871
- text: result
10872
- },
10873
- {
10874
- type: "text",
10875
- text: `Out of the included list of articles, you **MUST** select the one that is most relevant to the user's request and use the ReadFullDocsArticle tool to fetch it.`
11137
+ text: [
11138
+ result,
11139
+ `Out of the included list of articles, you **MUST** select the one that is most relevant to the user's request and use the ReadFullDocsArticle tool to fetch it.`
11140
+ ].join("\n\n")
10876
11141
  }
10877
11142
  ]
10878
11143
  };
@@ -10896,16 +11161,12 @@ var addDocsTools = (server2, allowedTools = [
10896
11161
  );
10897
11162
  }
10898
11163
  if (allowedTools.includes("SDK") && !disableTools?.includes("SearchWixSDKDocumentation")) {
10899
- const defaultSdkDesc = [
10900
- "Searches the official Wix javascript SDK documentation.",
10901
- "Use this tool whenever you need to write or modify Wix related SDK code.",
10902
- "Specify the SDK module, function, or feature you need information about (e.g., 'how to query all items from a data collection?', 'how to use wix-stores-backend', 'authentication methods in the SDK').",
10903
- "If you can't find what you need, try to rephrase your search term or use bigger maxResults value.",
10904
- getToKnowWixEnabled ? WixREADME_DEPENDENT_DESCRIPTION : ""
10905
- ].join("\n");
10906
11164
  server2.tool(
10907
11165
  "SearchWixSDKDocumentation",
10908
- getDescription("SearchWixSDKDocumentation", defaultSdkDesc),
11166
+ getDescription(
11167
+ "SearchWixSDKDocumentation",
11168
+ defaultToolDescriptions.SearchWixSDKDocumentation ?? ""
11169
+ ),
10909
11170
  {
10910
11171
  searchTerm: z.string().describe(
10911
11172
  "The search term to search for in the Wix SDK Documentation"
@@ -10932,11 +11193,10 @@ var addDocsTools = (server2, allowedTools = [
10932
11193
  content: [
10933
11194
  {
10934
11195
  type: "text",
10935
- text: result
10936
- },
10937
- {
10938
- type: "text",
10939
- text: "Next, you MUST use ReadFullDocsArticle tool if you want to read full documentation for a specific article or method."
11196
+ text: [
11197
+ result,
11198
+ "you should use ReadFullDocsArticle tool if you want to read full documentation for a specific article or method."
11199
+ ].join("\n---\n")
10940
11200
  }
10941
11201
  ]
10942
11202
  };
@@ -10960,16 +11220,12 @@ var addDocsTools = (server2, allowedTools = [
10960
11220
  );
10961
11221
  }
10962
11222
  if (allowedTools.includes("BUILD_APPS") && !disableTools?.includes("SearchBuildAppsDocumentation")) {
10963
- const defaultBuildAppsDesc = [
10964
- "Searches the official Build Apps documentation.",
10965
- "Use this tool when you need to understand or implement Wix CLI applications related code.",
10966
- "The search term should be a specific Wix CLI command or specific topic related to Wix CLI applications or its ecosystem (e.g. deployment, creating new extensions etc).",
10967
- "If you can't find what you need, try to rephrase your search term or use bigger maxResults value.",
10968
- getToKnowWixEnabled ? WixREADME_DEPENDENT_DESCRIPTION : ""
10969
- ].join("\n");
10970
11223
  server2.tool(
10971
11224
  "SearchBuildAppsDocumentation",
10972
- getDescription("SearchBuildAppsDocumentation", defaultBuildAppsDesc),
11225
+ getDescription(
11226
+ "SearchBuildAppsDocumentation",
11227
+ defaultToolDescriptions.SearchBuildAppsDocumentation ?? ""
11228
+ ),
10973
11229
  {
10974
11230
  searchTerm: z.string().describe(
10975
11231
  "The search term to search for in the Build Apps Documentation"
@@ -11016,16 +11272,12 @@ var addDocsTools = (server2, allowedTools = [
11016
11272
  );
11017
11273
  }
11018
11274
  if (allowedTools.includes("WIX_HEADLESS") && !disableTools?.includes("SearchWixHeadlessDocumentation")) {
11019
- const defaultHeadlessDesc = [
11020
- "Searches the official Wix Headless Documentation.",
11021
- "Use this tool when you need to understand or implement Headless related code.",
11022
- "The search term should be a specific Wix Headless topic or feature you need information about.",
11023
- "If you can't find what you need, try to rephrase your search term or use bigger maxResults value.",
11024
- getToKnowWixEnabled ? WixREADME_DEPENDENT_DESCRIPTION : ""
11025
- ].join("\n");
11026
11275
  server2.tool(
11027
11276
  "SearchWixHeadlessDocumentation",
11028
- getDescription("SearchWixHeadlessDocumentation", defaultHeadlessDesc),
11277
+ getDescription(
11278
+ "SearchWixHeadlessDocumentation",
11279
+ defaultToolDescriptions.SearchWixHeadlessDocumentation ?? ""
11280
+ ),
11029
11281
  {
11030
11282
  searchTerm: z.string().describe(
11031
11283
  "The search term to search for in the Headless Documentation"
@@ -11072,16 +11324,12 @@ var addDocsTools = (server2, allowedTools = [
11072
11324
  );
11073
11325
  }
11074
11326
  if (allowedTools.includes("VELO") && !disableTools?.includes("SearchWixVeloDocumentation")) {
11075
- const defaultVeloDesc = [
11076
- "Searches the official Velo documentation.",
11077
- "Use this tool when you need to understand or implement Velo related code.",
11078
- "The search term should be a specific Velo topic or feature you need information about.",
11079
- "If you can't find what you need, try to rephrase your search term or use bigger maxResults value.",
11080
- getToKnowWixEnabled ? WixREADME_DEPENDENT_DESCRIPTION : ""
11081
- ].join("\n");
11082
11327
  server2.tool(
11083
11328
  "SearchWixVeloDocumentation",
11084
- getDescription("SearchWixVeloDocumentation", defaultVeloDesc),
11329
+ getDescription(
11330
+ "SearchWixVeloDocumentation",
11331
+ defaultToolDescriptions.SearchWixVeloDocumentation ?? ""
11332
+ ),
11085
11333
  {
11086
11334
  searchTerm: z.string().describe("The search term to search for in the Velo Documentation"),
11087
11335
  maxResults: z.number().describe(
@@ -11106,11 +11354,10 @@ var addDocsTools = (server2, allowedTools = [
11106
11354
  content: [
11107
11355
  {
11108
11356
  type: "text",
11109
- text: result
11110
- },
11111
- {
11112
- type: "text",
11113
- text: "Next, you MUST use ReadFullDocsArticle tool if you want to read full documentation for a specific article or method."
11357
+ text: [
11358
+ result,
11359
+ "you should use ReadFullDocsArticle tool if you want to read full documentation for a specific article or method."
11360
+ ].join("\n---\n")
11114
11361
  }
11115
11362
  ]
11116
11363
  };
@@ -11132,14 +11379,12 @@ var addDocsTools = (server2, allowedTools = [
11132
11379
  );
11133
11380
  }
11134
11381
  if (!disableTools?.includes("ReadFullDocsArticle")) {
11135
- const defaultReadArticleDesc = [
11136
- "Fetches the full Wix docs article or method article.",
11137
- "Use this tool when you read a summary of a docs article or method article, you have the docs url and want to read the full article.",
11138
- getToKnowWixEnabled ? WixREADME_DEPENDENT_DESCRIPTION : ""
11139
- ].join("\n");
11140
11382
  server2.tool(
11141
11383
  "ReadFullDocsArticle",
11142
- getDescription("ReadFullDocsArticle", defaultReadArticleDesc),
11384
+ getDescription(
11385
+ "ReadFullDocsArticle",
11386
+ defaultToolDescriptions.ReadFullDocsArticle
11387
+ ),
11143
11388
  {
11144
11389
  articleUrl: z.string().url().describe(
11145
11390
  "The URL of the docs article or method article to fetch. Should be something like https://dev.wix.com/docs/.../.../..."
@@ -11151,7 +11396,9 @@ var addDocsTools = (server2, allowedTools = [
11151
11396
  const articleContent = await fetchArticleContent(
11152
11397
  httpClient,
11153
11398
  articleUrl,
11154
- "article"
11399
+ "article",
11400
+ false,
11401
+ picassoPortalUrl
11155
11402
  );
11156
11403
  if (!articleContent) {
11157
11404
  throw new Error("Article content is empty");
@@ -11161,13 +11408,6 @@ var addDocsTools = (server2, allowedTools = [
11161
11408
  {
11162
11409
  type: "text",
11163
11410
  text: articleContent
11164
- },
11165
- {
11166
- type: "text",
11167
- text: [
11168
- "---",
11169
- "Next, if you are dealing with a method - you MUST call ReadFullDocsMethodSchema tool - it will give you the full request schema for the method."
11170
- ].join("\n")
11171
11411
  }
11172
11412
  ]
11173
11413
  };
@@ -11188,13 +11428,12 @@ var addDocsTools = (server2, allowedTools = [
11188
11428
  );
11189
11429
  }
11190
11430
  if (!disableTools?.includes("ReadFullDocsMethodSchema")) {
11191
- const defaultMethodSchemaDesc = [
11192
- "Fetches the full method schema for a given method. Always use it before calling the method.",
11193
- "This will give you the entire request/response schema with all the fields and their descriptions."
11194
- ].join("\n");
11195
11431
  server2.tool(
11196
11432
  "ReadFullDocsMethodSchema",
11197
- getDescription("ReadFullDocsMethodSchema", defaultMethodSchemaDesc),
11433
+ getDescription(
11434
+ "ReadFullDocsMethodSchema",
11435
+ defaultToolDescriptions.ReadFullDocsMethodSchema
11436
+ ),
11198
11437
  {
11199
11438
  articleUrl: z.string().url().describe(
11200
11439
  "The URL of the documentation to fetch. Should be something like https://dev.wix.com/docs/.../.../..."
@@ -11206,7 +11445,9 @@ var addDocsTools = (server2, allowedTools = [
11206
11445
  const articleContent = await fetchArticleContent(
11207
11446
  httpClient,
11208
11447
  articleUrl,
11209
- "methodSchema"
11448
+ "methodSchema",
11449
+ false,
11450
+ picassoPortalUrl
11210
11451
  );
11211
11452
  if (!articleContent) {
11212
11453
  throw new Error("Method schema is empty");
@@ -11356,8 +11597,10 @@ function addCliTools(server2, allowedTools = ["CLI_COMMAND"], isWixOne2 = false)
11356
11597
  logger.log(`RunWixCliCommand: stderr: ${stderr}`);
11357
11598
  return {
11358
11599
  content: [
11359
- { type: "text", text: stdout },
11360
- ...stderr ? [{ type: "text", text: `Error: ${stderr}` }] : []
11600
+ {
11601
+ type: "text",
11602
+ text: stderr ? [stdout, `Error: ${stderr}`].join("\n\n") : stdout
11603
+ }
11361
11604
  ]
11362
11605
  };
11363
11606
  } catch (error) {
@@ -11474,6 +11717,14 @@ var WixMcpServer = class extends McpServer {
11474
11717
  setClientNameGetter(getClientName) {
11475
11718
  this.getClientName = getClientName;
11476
11719
  }
11720
+ getWidgetExtras() {
11721
+ return {
11722
+ biContext: {
11723
+ userId: this.getUserId?.() ?? "",
11724
+ sessionId: this.sessionId
11725
+ }
11726
+ };
11727
+ }
11477
11728
  tool(...args) {
11478
11729
  const cbIndex = args.findIndex((arg) => typeof arg === "function");
11479
11730
  if (cbIndex !== -1) {
@@ -11656,7 +11907,7 @@ var addDocsResources = async (server2, portals) => {
11656
11907
 
11657
11908
  // src/api-call/index.ts
11658
11909
  var import_http_client2 = __toESM(require_index_node2(), 1);
11659
- import { z as z3 } from "zod";
11910
+ import { z as z4 } from "zod";
11660
11911
 
11661
11912
  // src/tool-utils.ts
11662
11913
  var safeParseJSON = (text) => {
@@ -11697,6 +11948,13 @@ var handleWixAPIResponse = async (response) => {
11697
11948
  };
11698
11949
 
11699
11950
  // src/api-call/validation.ts
11951
+ var ALLOWED_HOSTNAMES = [
11952
+ "wix.com",
11953
+ "dev.wix.com",
11954
+ "manage.wix.com",
11955
+ "editor.wix.com",
11956
+ "wixapis.com"
11957
+ ];
11700
11958
  function isApiUrlAllowed(url) {
11701
11959
  let parsedUrl;
11702
11960
  try {
@@ -11707,13 +11965,6 @@ function isApiUrlAllowed(url) {
11707
11965
  error: `Invalid URL format: ${url}`
11708
11966
  };
11709
11967
  }
11710
- const ALLOWED_HOSTNAMES = [
11711
- "wix.com",
11712
- "dev.wix.com",
11713
- "manage.wix.com",
11714
- "editor.wix.com",
11715
- "wixapis.com"
11716
- ];
11717
11968
  const hostname = parsedUrl.hostname.replace("www.", "");
11718
11969
  const isAllowedHostname = ALLOWED_HOSTNAMES.some(
11719
11970
  (domain) => hostname === domain
@@ -11729,38 +11980,219 @@ function isApiUrlAllowed(url) {
11729
11980
  };
11730
11981
  }
11731
11982
 
11983
+ // src/api-call/upload-image-tool.ts
11984
+ import { z as z3 } from "zod";
11985
+ var TOOL_NAME = "UploadImageToWixSite";
11986
+ var POLL_TIMEOUT_MS = 1e4;
11987
+ var POLL_INTERVAL_MS = 1e3;
11988
+ async function waitForFileReady(httpClient, fileId, authHeaders, timeoutMs = POLL_TIMEOUT_MS) {
11989
+ const startTime = Date.now();
11990
+ while (Date.now() - startTime < timeoutMs) {
11991
+ await new Promise((resolve) => setTimeout(resolve, POLL_INTERVAL_MS));
11992
+ try {
11993
+ const response = await httpClient.get(
11994
+ `https://www.wixapis.com/site-media/v1/files/get-file-by-id?fileId=${encodeURIComponent(fileId)}`,
11995
+ { headers: authHeaders }
11996
+ );
11997
+ const file = response.data?.file;
11998
+ if (file && file.operationStatus !== "PENDING") {
11999
+ return file;
12000
+ }
12001
+ } catch {
12002
+ return null;
12003
+ }
12004
+ }
12005
+ return null;
12006
+ }
12007
+ function addUploadImageTool(server2, strategy, options) {
12008
+ const description = options?.description ?? defaultToolDescriptions.UploadImageToWixSite;
12009
+ const hints = {
12010
+ readOnlyHint: options?.hints?.readOnlyHint ?? false,
12011
+ destructiveHint: options?.hints?.destructiveHint ?? false,
12012
+ openWorldHint: options?.hints?.openWorldHint ?? false
12013
+ };
12014
+ server2.registerTool(
12015
+ TOOL_NAME,
12016
+ {
12017
+ title: "Upload Image to Wix Site",
12018
+ description,
12019
+ inputSchema: {
12020
+ siteId: z3.string().describe("The ID of the Wix site to upload to"),
12021
+ image: z3.object({
12022
+ download_url: z3.string().url(),
12023
+ file_id: z3.string()
12024
+ }).describe("The image file provided by the user"),
12025
+ displayName: z3.string().optional().describe(
12026
+ "Optional display name for the file in Media Manager. If not provided, uses the original filename."
12027
+ )
12028
+ },
12029
+ _meta: {
12030
+ "openai/fileParams": ["image"],
12031
+ "openai/toolInvocation/invoking": "Uploading image to Wix Media Manager...",
12032
+ "openai/toolInvocation/invoked": "Image uploaded successfully"
12033
+ },
12034
+ annotations: hints
12035
+ },
12036
+ async ({
12037
+ siteId,
12038
+ image,
12039
+ displayName
12040
+ }, { httpClient, setToolBiParams }) => {
12041
+ logger.log(
12042
+ `Uploading image to Wix site: ${siteId}, file_id: ${image.file_id}`
12043
+ );
12044
+ setToolBiParams({ siteId });
12045
+ try {
12046
+ const importResponse = await httpClient.post(
12047
+ "https://www.wixapis.com/site-media/v1/files/import",
12048
+ {
12049
+ url: image.download_url,
12050
+ ...displayName ? { displayName } : {}
12051
+ },
12052
+ {
12053
+ headers: {
12054
+ ...await strategy.getSiteAuthHeaders(siteId),
12055
+ "Content-Type": "application/json"
12056
+ }
12057
+ }
12058
+ );
12059
+ let file = importResponse.data?.file;
12060
+ if (!file) {
12061
+ return {
12062
+ isError: true,
12063
+ content: [
12064
+ {
12065
+ type: "text",
12066
+ text: "Failed to upload image: No file returned from Wix API"
12067
+ }
12068
+ ]
12069
+ };
12070
+ }
12071
+ if (file.operationStatus === "PENDING") {
12072
+ const authHeaders = await strategy.getSiteAuthHeaders(siteId);
12073
+ const updatedFile = await waitForFileReady(
12074
+ httpClient,
12075
+ file.id,
12076
+ authHeaders
12077
+ );
12078
+ if (updatedFile) {
12079
+ file = updatedFile;
12080
+ }
12081
+ }
12082
+ const result = {
12083
+ id: file.id,
12084
+ displayName: file.displayName,
12085
+ url: file.url,
12086
+ operationStatus: file.operationStatus,
12087
+ mediaType: file.mediaType,
12088
+ sourceUrl: file.sourceUrl,
12089
+ ...file.media?.image?.image ? {
12090
+ width: file.media.image.image.width,
12091
+ height: file.media.image.image.height
12092
+ } : {}
12093
+ };
12094
+ logger.log(`Image uploaded successfully: ${JSON.stringify(result)}`);
12095
+ let responseText = `Image uploaded successfully!
12096
+
12097
+ `;
12098
+ responseText += `**Media ID:** ${result.id}
12099
+ `;
12100
+ responseText += `**URL:** ${result.url}
12101
+ `;
12102
+ responseText += `**Status:** ${result.operationStatus}
12103
+ `;
12104
+ if (result.width && result.height) {
12105
+ responseText += `**Dimensions:** ${result.width}x${result.height}
12106
+ `;
12107
+ }
12108
+ if (result.operationStatus === "PENDING") {
12109
+ responseText += `
12110
+ **Note:** The file is still being processed (timeout reached). `;
12111
+ responseText += `You can use the URL immediately, but some operations may require waiting for status to become READY.`;
12112
+ }
12113
+ return {
12114
+ content: [
12115
+ {
12116
+ type: "text",
12117
+ text: responseText
12118
+ }
12119
+ ],
12120
+ structuredContent: result
12121
+ };
12122
+ } catch (error) {
12123
+ const errorMessage = `Failed to upload image to Wix: ${error}`;
12124
+ logger.error(errorMessage);
12125
+ return {
12126
+ isError: true,
12127
+ content: [
12128
+ {
12129
+ type: "text",
12130
+ text: errorMessage
12131
+ }
12132
+ ]
12133
+ };
12134
+ }
12135
+ }
12136
+ );
12137
+ }
12138
+
11732
12139
  // src/api-call/index.ts
11733
- function addApiCallTool(server2, strategy, allowedTools = ["CallWixSiteAPI", "ListWixSites", "ManageWixSite"], disableTools = [], toolDescriptions) {
12140
+ var MAX_RESPONSE_SIZE = 5e4;
12141
+ function formatApiResponse(responseData) {
12142
+ if (typeof responseData === "string" && responseData.trim().startsWith("<!DOCTYPE")) {
12143
+ return {
12144
+ text: "Error: API returned HTML instead of JSON. This usually means the URL is incorrect or points to a web page instead of an API endpoint. Please verify the URL.",
12145
+ isError: true
12146
+ };
12147
+ }
12148
+ let responseText = JSON.stringify(responseData);
12149
+ if (responseText.length > MAX_RESPONSE_SIZE) {
12150
+ responseText = responseText.slice(0, MAX_RESPONSE_SIZE) + `
12151
+ ...[TRUNCATED - response was ${responseText.length} chars, showing first ${MAX_RESPONSE_SIZE}]`;
12152
+ }
12153
+ return { text: responseText, isError: false };
12154
+ }
12155
+ function addApiCallTool(server2, strategy, allowedTools = ["CallWixSiteAPI", "ListWixSites", "ManageWixSite"], disableTools = [], enableTools = [], toolDescriptions, toolHints) {
12156
+ const effectiveAllowedTools = [
12157
+ .../* @__PURE__ */ new Set([...allowedTools, ...enableTools])
12158
+ ].filter((tool) => !disableTools.includes(tool));
12159
+ const getHints = (toolName, defaults) => ({
12160
+ readOnlyHint: toolHints?.[toolName]?.readOnlyHint ?? defaults.readOnlyHint,
12161
+ destructiveHint: toolHints?.[toolName]?.destructiveHint ?? defaults.destructiveHint,
12162
+ openWorldHint: toolHints?.[toolName]?.openWorldHint ?? defaults.openWorldHint
12163
+ });
11734
12164
  const getDescription = (toolName, defaultDesc) => toolDescriptions?.[toolName] ?? defaultDesc;
11735
- if (allowedTools.includes("CallWixSiteAPI") && !disableTools.includes("CallWixSiteAPI")) {
11736
- const defaultCallApiDesc = [
11737
- "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,",
11738
- `You should ALWAYS check the rest docs - "SearchWixRESTDocumentation" for the specific API you want to call, don't just call it without knowing what it does, CHECK THE DOCS`,
11739
- "Error Handling:",
11740
- 'If the error is related to missing installed app or "WDE0110: Wix Code not enabled", you should install the missing app by using ReadFullDocsArticle tool to fetch the article - https://dev.wix.com/docs/kb-only/MCP_REST_RECIPES_KB_ID/TRAIN_wix.devcenter.apps.installer.v1.AppsInstallerService.InstallApp',
11741
- "**Note:** there is no need to check if an app is installed/ Wix Code enabled in advance, just call the API and handle the error if it occurs, the API error message will state it clearly.",
11742
- "For any other error, use your default error handling mechanism"
11743
- ].join("\n");
12165
+ if (effectiveAllowedTools.includes("CallWixSiteAPI") && !disableTools.includes("CallWixSiteAPI")) {
11744
12166
  server2.tool(
11745
12167
  "CallWixSiteAPI",
11746
- getDescription("CallWixSiteAPI", defaultCallApiDesc),
12168
+ getDescription("CallWixSiteAPI", defaultToolDescriptions.CallWixSiteAPI),
11747
12169
  {
11748
- siteId: z3.string().describe("The id of the site selected using site selection tool"),
11749
- url: z3.string().url().describe(
11750
- "The url of the api to call - ALWAYS get the information from the Wix REST docs or from the conversation context, the URL MUST BE ABSOLUTE URL"
12170
+ siteId: z4.string().describe("The id of the site selected using site selection tool"),
12171
+ url: z4.string().url().describe(
12172
+ [
12173
+ "The url of the api to call - ALWAYS get the API url from the Wix REST docs or from the conversation context, the URL MUST BE ABSOLUTE URL",
12174
+ 'NEVER guess the API url, ALWAYS get it from the conversation context, i.e from the user prompt or from the "WixREADME" tool or from the "SearchWixRESTDocumentation" tool or from the "ReadFullDocsArticle" tool',
12175
+ `Allowed API urls are: ${ALLOWED_HOSTNAMES.join(", ")}`,
12176
+ `Docs urls like https://dev.wix.com/docs/... are not API urls, if you want to read the docs, use the "ReadFullDocsArticle" tool`
12177
+ ].join("\n")
11751
12178
  ),
11752
- method: z3.string().describe(
12179
+ method: z4.string().describe(
11753
12180
  "The HTTP method to use for the API call (e.g. GET, POST, PUT, DELETE)"
11754
12181
  ),
11755
- body: z3.string().optional().describe(
11756
- "A string representing of a valid JSON object to describe the body of the request"
12182
+ body: z4.object({}).passthrough().optional().describe(
12183
+ 'The request body object. YOU MUST NEVER MAKE UP A BODY - this should be based on the conversation context, i.e from the user prompt or from the "WixREADME" tool or from the "SearchWixRESTDocumentation" tool or from the "ReadFullDocsArticle" tool or from the "ReadFullDocsMethodSchema" tool - i.e based on the API docs. YOU MUST NEVER ASSUME YOU KNOW WHAT THE SCHEMA IS WITHOUT CONCRETE EXAMPLES OR SCHEMA DEFINITIONS FROM THE CONVERSATION CONTEXT.'
11757
12184
  )
11758
12185
  },
11759
- { readOnlyHint: false, destructiveHint: true, openWorldHint: false },
12186
+ getHints("CallWixSiteAPI", {
12187
+ readOnlyHint: false,
12188
+ destructiveHint: true,
12189
+ openWorldHint: false
12190
+ }),
11760
12191
  async ({ url, body, method, siteId }, { httpClient, setToolBiParams }) => {
11761
- logger.log(
11762
- `Calling Wix Site API: ${siteId} ${url}, body: ${JSON.stringify(body)}`
11763
- );
12192
+ const requestHeaders = {
12193
+ ...await strategy.getSiteAuthHeaders(siteId),
12194
+ ...body ? { "Content-Type": "application/json" } : {}
12195
+ };
11764
12196
  const { isAllowed, error: urlError } = isApiUrlAllowed(url);
11765
12197
  if (!isAllowed) {
11766
12198
  return {
@@ -11777,20 +12209,29 @@ function addApiCallTool(server2, strategy, allowedTools = ["CallWixSiteAPI", "Li
11777
12209
  const response = await httpClient.request({
11778
12210
  url,
11779
12211
  method,
11780
- headers: {
11781
- ...await strategy.getSiteAuthHeaders(siteId),
11782
- ...body ? { "Content-Type": "application/json" } : {}
11783
- },
12212
+ headers: requestHeaders,
11784
12213
  data: method === "GET" ? void 0 : body
11785
12214
  });
11786
12215
  const requestId = response.headers?.["x-wix-request-id"];
11787
12216
  setToolBiParams({ requestId, siteId });
11788
12217
  const responseData = await handleWixAPIResponse(response);
12218
+ const formatted = formatApiResponse(responseData);
12219
+ if (formatted.isError) {
12220
+ return {
12221
+ content: [
12222
+ {
12223
+ type: "text",
12224
+ text: formatted.text
12225
+ }
12226
+ ],
12227
+ isError: true
12228
+ };
12229
+ }
11789
12230
  return {
11790
12231
  content: [
11791
12232
  {
11792
12233
  type: "text",
11793
- text: `Wix Site API call successful: ${JSON.stringify(responseData)}`
12234
+ text: `Wix Site API call successful: ${formatted.text}`
11794
12235
  }
11795
12236
  ]
11796
12237
  };
@@ -11800,9 +12241,9 @@ function addApiCallTool(server2, strategy, allowedTools = ["CallWixSiteAPI", "Li
11800
12241
  requestId = error.requestId;
11801
12242
  }
11802
12243
  setToolBiParams({ requestId, siteId });
12244
+ const response = error.response;
11803
12245
  const errorMessage = `Failed to call Wix Site API: ${error}. ${requestId ? `Request ID: ${requestId}` : ""}`;
11804
12246
  logger.error(errorMessage);
11805
- const response = error.response;
11806
12247
  if (!response) {
11807
12248
  throw new Error(errorMessage);
11808
12249
  }
@@ -11811,19 +12252,22 @@ function addApiCallTool(server2, strategy, allowedTools = ["CallWixSiteAPI", "Li
11811
12252
  }
11812
12253
  );
11813
12254
  }
11814
- if (allowedTools.includes("ListWixSites") && !disableTools.includes("ListWixSites")) {
11815
- const defaultListSitesDesc = "List Wix sites for the current user, by default it will return all sites, but you can filter by name";
12255
+ if (effectiveAllowedTools.includes("ListWixSites") && !disableTools.includes("ListWixSites")) {
11816
12256
  server2.tool(
11817
12257
  "ListWixSites",
11818
- getDescription("ListWixSites", defaultListSitesDesc),
12258
+ getDescription("ListWixSites", defaultToolDescriptions.ListWixSites),
11819
12259
  {
11820
- nameSearch: z3.string().optional().describe(
12260
+ nameSearch: z4.string().optional().describe(
11821
12261
  "optional filer by name, if not provided all sites will be returned"
11822
12262
  ),
11823
12263
  // Hack for Cursor ignoring tools with no params (when nameSearch is optional)
11824
- alwaysTrue: z3.boolean().describe("Always pass true to this parameter")
12264
+ alwaysTrue: z4.boolean().describe("Always pass true to this parameter")
11825
12265
  },
11826
- { readOnlyHint: true, destructiveHint: false, openWorldHint: false },
12266
+ getHints("ListWixSites", {
12267
+ readOnlyHint: true,
12268
+ destructiveHint: false,
12269
+ openWorldHint: false
12270
+ }),
11827
12271
  async ({ nameSearch }, { httpClient }) => {
11828
12272
  const sitesRes = await httpClient.post(
11829
12273
  "https://www.wixapis.com/site-list/v2/sites/query",
@@ -11856,36 +12300,36 @@ function addApiCallTool(server2, strategy, allowedTools = ["CallWixSiteAPI", "Li
11856
12300
  content: [
11857
12301
  {
11858
12302
  type: "text",
11859
- text: JSON.stringify(result)
11860
- },
11861
- {
11862
- type: "text",
11863
- text: "if there is more than one site returned, the user should pick one from a list, list the sites (only name) for the user and ask them to pick one,If more than 20 are found you should list all 20 and suggest to search by the name of the site they are looking for"
12303
+ text: [
12304
+ JSON.stringify(result),
12305
+ "if there is more than one site returned, the user should pick one from a list, list the sites (only name) for the user and ask them to pick one, If more than 20 are found you should list all 20 and suggest to search by the name of the site they are looking for"
12306
+ ].join("\n\n")
11864
12307
  }
11865
12308
  ]
11866
12309
  };
11867
12310
  }
11868
12311
  );
11869
12312
  }
11870
- if (allowedTools.includes("ManageWixSite") && !disableTools.includes("ManageWixSite")) {
11871
- const defaultManageSiteDesc = `Use account level API in order to create a site, update a site and publish site.
11872
- ALWAYS use "SearchWixRESTDocumentation" to search for the API you should invoke, NEVER GUESS THE SITE API URL
11873
- You should ALWAYS check the rest docs - "SearchWixRESTDocumentation" for the specific API you want to call, don't just call it without knowing what it does, CHECK THE DOCS`;
12313
+ if (effectiveAllowedTools.includes("ManageWixSite") && !disableTools.includes("ManageWixSite")) {
11874
12314
  server2.tool(
11875
12315
  "ManageWixSite",
11876
- getDescription("ManageWixSite", defaultManageSiteDesc),
12316
+ getDescription("ManageWixSite", defaultToolDescriptions.ManageWixSite),
11877
12317
  {
11878
- url: z3.string().url().describe(
12318
+ url: z4.string().url().describe(
11879
12319
  "The url of the api to call - ALWAYS get the information from the Wix REST docs DONT GUESS IT, the URL MUST BE ABSOLUTE URL"
11880
12320
  ),
11881
- method: z3.string().describe(
12321
+ method: z4.string().describe(
11882
12322
  "The HTTP method to use for the API call (e.g. GET, POST, PUT, DELETE)"
11883
12323
  ),
11884
- body: z3.string().optional().describe(
11885
- "A string representing of a valid JSON object to describe the body of the request"
12324
+ body: z4.object({}).passthrough().optional().describe(
12325
+ 'The request body object. YOU MUST NEVER MAKE UP A BODY - this should be based on the conversation context, i.e from the user prompt or from the "WixREADME" tool or from the "SearchWixRESTDocumentation" tool or from the "ReadFullDocsArticle" tool or from the "ReadFullDocsMethodSchema" tool - i.e based on the API docs. YOU MUST NEVER ASSUME YOU KNOW WHAT THE SCHEMA IS WITHOUT CONCRETE EXAMPLES OR SCHEMA DEFINITIONS FROM THE CONVERSATION CONTEXT.'
11886
12326
  )
11887
12327
  },
11888
- { readOnlyHint: false, destructiveHint: true, openWorldHint: false },
12328
+ getHints("ManageWixSite", {
12329
+ readOnlyHint: false,
12330
+ destructiveHint: true,
12331
+ openWorldHint: false
12332
+ }),
11889
12333
  async ({ url, body, method }, { httpClient }) => {
11890
12334
  logger.log(
11891
12335
  `Calling Wix Account level API: ${url}, body: ${JSON.stringify(body)}`
@@ -11913,11 +12357,23 @@ function addApiCallTool(server2, strategy, allowedTools = ["CallWixSiteAPI", "Li
11913
12357
  data: method === "GET" ? void 0 : body
11914
12358
  });
11915
12359
  const responseData = await handleWixAPIResponse(response);
12360
+ const formatted = formatApiResponse(responseData);
12361
+ if (formatted.isError) {
12362
+ return {
12363
+ content: [
12364
+ {
12365
+ type: "text",
12366
+ text: formatted.text
12367
+ }
12368
+ ],
12369
+ isError: true
12370
+ };
12371
+ }
11916
12372
  return {
11917
12373
  content: [
11918
12374
  {
11919
12375
  type: "text",
11920
- text: `Wix Account API call successful: ${JSON.stringify(responseData)}`
12376
+ text: `Wix Account API call successful: ${formatted.text}`
11921
12377
  }
11922
12378
  ]
11923
12379
  };
@@ -11932,6 +12388,12 @@ function addApiCallTool(server2, strategy, allowedTools = ["CallWixSiteAPI", "Li
11932
12388
  }
11933
12389
  );
11934
12390
  }
12391
+ if (effectiveAllowedTools.includes("UploadImageToWixSite") && !disableTools.includes("UploadImageToWixSite")) {
12392
+ addUploadImageTool(server2, strategy, {
12393
+ description: getDescription("UploadImageToWixSite", ""),
12394
+ hints: toolHints?.["UploadImageToWixSite"]
12395
+ });
12396
+ }
11935
12397
  }
11936
12398
 
11937
12399
  // src/docs/velo-readme.ts