@wix/mcp 1.0.10 → 1.0.12

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.
@@ -1585,7 +1585,7 @@ var require_error_utils = __commonJS({
1585
1585
  "../../node_modules/@wix/panorama-client/dist/cjs/utils/error-utils.js"(exports2) {
1586
1586
  "use strict";
1587
1587
  exports2.__esModule = true;
1588
- exports2.normalizeError = exports2.extractWixHttpErrorDetails = void 0;
1588
+ exports2.normalizeError = exports2.extractWixHttpErrorDetails = exports2.createUndedupableError = void 0;
1589
1589
  var _generalUtils = require_general_utils();
1590
1590
  var extractWixHttpErrorDetailsRec = (error) => {
1591
1591
  var _httpClientError$resp;
@@ -1613,6 +1613,21 @@ var require_error_utils = __commonJS({
1613
1613
  return error;
1614
1614
  };
1615
1615
  exports2.normalizeError = normalizeError;
1616
+ var createUndedupableError = (error) => {
1617
+ const {
1618
+ message,
1619
+ stack,
1620
+ cause
1621
+ } = error;
1622
+ const res = Object.assign(Object.create(Object.getPrototypeOf(error)), {
1623
+ name: `${Date.now() + Math.random()}`,
1624
+ message,
1625
+ stack,
1626
+ cause
1627
+ });
1628
+ return res;
1629
+ };
1630
+ exports2.createUndedupableError = createUndedupableError;
1616
1631
  }
1617
1632
  });
1618
1633
 
@@ -1621,8 +1636,9 @@ var require_constants = __commonJS({
1621
1636
  "../../node_modules/@wix/panorama-client/dist/cjs/constants.js"(exports2) {
1622
1637
  "use strict";
1623
1638
  exports2.__esModule = true;
1624
- exports2.MAX_STACK_TRACE_SIZE_BYTES = void 0;
1639
+ exports2.MAX_STACK_TRACE_SIZE_BYTES = exports2.MAX_SESSION_TIME_MS = void 0;
1625
1640
  var MAX_STACK_TRACE_SIZE_BYTES = exports2.MAX_STACK_TRACE_SIZE_BYTES = 32 * 1024;
1641
+ var MAX_SESSION_TIME_MS = exports2.MAX_SESSION_TIME_MS = 24 * 60 * 60 * 1e3;
1626
1642
  }
1627
1643
  });
1628
1644
 
@@ -1635,7 +1651,8 @@ var require_payload_sanitizer = __commonJS({
1635
1651
  var _constants = require_constants();
1636
1652
  var sanitizePayload = (payload) => {
1637
1653
  const {
1638
- errorStack
1654
+ errorStack,
1655
+ sessionTime
1639
1656
  } = payload;
1640
1657
  if (errorStack && errorStack.length > _constants.MAX_STACK_TRACE_SIZE_BYTES) {
1641
1658
  const truncationMessage = `...[truncated by Panorama client to ${_constants.MAX_STACK_TRACE_SIZE_BYTES / 1024}kb]`;
@@ -1645,6 +1662,12 @@ var require_payload_sanitizer = __commonJS({
1645
1662
  errorStack: `${truncatedErrorStack}${truncationMessage}`
1646
1663
  };
1647
1664
  }
1665
+ if (sessionTime && sessionTime > _constants.MAX_SESSION_TIME_MS) {
1666
+ payload = {
1667
+ ...payload,
1668
+ sessionTime: _constants.MAX_SESSION_TIME_MS
1669
+ };
1670
+ }
1648
1671
  return payload;
1649
1672
  };
1650
1673
  exports2.sanitizePayload = sanitizePayload;
@@ -2059,6 +2082,7 @@ var require_types2 = __commonJS({
2059
2082
  var StacktraceScriptType = exports2.StacktraceScriptType = /* @__PURE__ */ function(StacktraceScriptType2) {
2060
2083
  StacktraceScriptType2["WIX_SERVICE"] = "WIX_SERVICE";
2061
2084
  StacktraceScriptType2["WIX_APP"] = "WIX_APP";
2085
+ StacktraceScriptType2["WIX_CLI_APP"] = "WIX_CLI_APP";
2062
2086
  StacktraceScriptType2["WIX_CHAT"] = "WIX_CHAT_WIDGET";
2063
2087
  StacktraceScriptType2["BROWSER_EXTENSION"] = "BROWSER_EXTENSION";
2064
2088
  return StacktraceScriptType2;
@@ -2519,7 +2543,7 @@ var require_artifact_utils = __commonJS({
2519
2543
  "../../node_modules/@wix/panorama-client/dist/cjs/utils/artifact-utils.js"(exports2) {
2520
2544
  "use strict";
2521
2545
  exports2.__esModule = true;
2522
- exports2.isSameArtifact = exports2.isArtifactMismatch = exports2.getFirstMatchingArtifact = exports2.getArtifactDataFromBaseParams = exports2.fullArtifactIdToArtifactId = exports2.extractArtifactDataFromScriptUrl = void 0;
2546
+ exports2.isSameArtifact = exports2.isArtifactMismatch = exports2.getFirstMatchingArtifact = exports2.getArtifactDataFromBaseParams = exports2.fullArtifactIdToArtifactId = exports2.extractArtifactDataFromFrameUrl = exports2.extractArtifactDataFromFrameMetadata = void 0;
2523
2547
  var _types = require_types2();
2524
2548
  var _generalUtils = require_general_utils();
2525
2549
  var scriptRegexs = [{
@@ -2535,13 +2559,36 @@ var require_artifact_utils = __commonJS({
2535
2559
  scriptType: _types.StacktraceScriptType.BROWSER_EXTENSION,
2536
2560
  regex: () => /^chrome-extension:/
2537
2561
  }];
2538
- var extractArtifactDataFromScriptUrl = (url) => {
2562
+ var extractArtifactDataFromFrameMetadata = (frame) => {
2563
+ if (!frame.module_metadata) {
2564
+ return null;
2565
+ }
2566
+ const {
2567
+ artifactId,
2568
+ fingerprint
2569
+ } = frame.module_metadata;
2570
+ return {
2571
+ artifactId,
2572
+ artifactVersion: fingerprint,
2573
+ scriptType: _types.StacktraceScriptType.WIX_CLI_APP
2574
+ };
2575
+ };
2576
+ exports2.extractArtifactDataFromFrameMetadata = extractArtifactDataFromFrameMetadata;
2577
+ var extractArtifactDataFromFrameUrl = (frame) => {
2578
+ const {
2579
+ filename,
2580
+ raw
2581
+ } = frame;
2582
+ const element = filename ?? raw;
2583
+ if (!element) {
2584
+ return null;
2585
+ }
2539
2586
  return scriptRegexs.reduce((res, {
2540
2587
  scriptType,
2541
2588
  regex
2542
2589
  }) => {
2543
2590
  if (!res) {
2544
- const match = regex().exec(url);
2591
+ const match = regex().exec(element);
2545
2592
  if (match) {
2546
2593
  const [, artifactId, artifactVersion] = match;
2547
2594
  res = {
@@ -2554,7 +2601,7 @@ var require_artifact_utils = __commonJS({
2554
2601
  return res;
2555
2602
  }, null);
2556
2603
  };
2557
- exports2.extractArtifactDataFromScriptUrl = extractArtifactDataFromScriptUrl;
2604
+ exports2.extractArtifactDataFromFrameUrl = extractArtifactDataFromFrameUrl;
2558
2605
  var fullArtifactIdToArtifactId = (fullArtifactId) => {
2559
2606
  if (typeof fullArtifactId !== "string") {
2560
2607
  return "";
@@ -2794,11 +2841,15 @@ var require_sentry_plugin_utils = __commonJS({
2794
2841
  if (!(error instanceof Error)) {
2795
2842
  return;
2796
2843
  }
2844
+ const data = {
2845
+ ...panoramaData
2846
+ };
2847
+ delete data.originalErrorName;
2797
2848
  try {
2798
- baseClient.reportError(error, panoramaData);
2849
+ baseClient.reportError(error, data);
2799
2850
  } catch (e) {
2800
2851
  createSafePanoramaLogger(baseClient)(_types.LogLevel.Error, "[panorama-sentry-plugin] Failed to report error to Panorama", {
2801
- ...panoramaData,
2852
+ ...data,
2802
2853
  error: e == null ? void 0 : e.toString()
2803
2854
  });
2804
2855
  }
@@ -2967,6 +3018,7 @@ var require_sentry_plugin_enricher = __commonJS({
2967
3018
  });
2968
3019
  exports2.enrichPanoramaDataWithSentryEventData = enrichPanoramaDataWithSentryEventData;
2969
3020
  var enrichSentryEventWithPanoramaData = (event, data, baseClient) => {
3021
+ var _event$exception;
2970
3022
  const dataWithDefaults = baseClient.getErrorMonitorDataWithDefaults({
2971
3023
  tags: {
2972
3024
  exceptionType: data.exceptionType
@@ -2986,6 +3038,9 @@ var require_sentry_plugin_enricher = __commonJS({
2986
3038
  contexts: dataWithDefaults == null ? void 0 : dataWithDefaults.context,
2987
3039
  environment: dataWithDefaults == null ? void 0 : dataWithDefaults.environment
2988
3040
  };
3041
+ if (data.originalErrorName && (_event$exception = event.exception) != null && (_event$exception = _event$exception.values) != null && _event$exception[0]) {
3042
+ event.exception.values[0].type = data.originalErrorName;
3043
+ }
2989
3044
  return event;
2990
3045
  };
2991
3046
  exports2.enrichSentryEventWithPanoramaData = enrichSentryEventWithPanoramaData;
@@ -3112,15 +3167,7 @@ var require_sentry_plugin_stacktrace = __commonJS({
3112
3167
  const map = /* @__PURE__ */ new Map();
3113
3168
  const frames = ((_event$exception = event.exception) == null || (_event$exception = _event$exception.values) == null || (_event$exception = _event$exception[0]) == null || (_event$exception = _event$exception.stacktrace) == null ? void 0 : _event$exception.frames) || splitOriginalStacktraceIntoFrames(hint == null ? void 0 : hint.originalException);
3114
3169
  for (let i = frames.length - 1; i >= 0; i--) {
3115
- const {
3116
- filename,
3117
- raw
3118
- } = frames[i];
3119
- const element = filename ?? raw;
3120
- if (!element) {
3121
- continue;
3122
- }
3123
- const artifactData = (0, _artifactUtils.extractArtifactDataFromScriptUrl)(element);
3170
+ const artifactData = (0, _artifactUtils.extractArtifactDataFromFrameMetadata)(frames[i]) ?? (0, _artifactUtils.extractArtifactDataFromFrameUrl)(frames[i]);
3124
3171
  if (!artifactData) {
3125
3172
  continue;
3126
3173
  }
@@ -3235,19 +3282,27 @@ var require_sentry_plugin = __commonJS({
3235
3282
  const sentryBeforeSend = (handler) => {
3236
3283
  sentryBeforeSendHook = handler;
3237
3284
  };
3238
- const create = (loadedSentry) => new loadedSentry.Hub(new loadedSentry.BrowserClient({
3239
- dsn: sentryDsn,
3240
- environment: sentryEnvironment ?? (0, _environmentUtils.calculateEnvironment)(),
3241
- release: (0, _sentryPluginUtils.buildReleaseString)(artifactData),
3242
- transport: sentryTransport,
3243
- integrations: [...loadedSentry.defaultIntegrations],
3244
- normalizeDepth: 4,
3245
- // Change the default nesting depth of (3) because we use one level of nesting when encoding the Panorama context
3246
- beforeBreadcrumb: _sentryPluginBreadcrumbs.enrichBreadcrumbsWithDataHooks,
3247
- beforeSend(event, hint) {
3248
- return typeof sentryBeforeSendHook === "function" ? sentryBeforeSendHook(event, hint) : event;
3249
- }
3250
- }));
3285
+ const create = (loadedSentry) => {
3286
+ const isLegacySentry = !loadedSentry.makeFetchTransport;
3287
+ const transport = isLegacySentry || sentryTransport ? sentryTransport : loadedSentry.makeFetchTransport;
3288
+ const stackParser = isLegacySentry ? void 0 : loadedSentry.defaultStackParser;
3289
+ const integrations = isLegacySentry ? [...loadedSentry.defaultIntegrations] : [...loadedSentry.getDefaultIntegrations({}), ...typeof loadedSentry.moduleMetadataIntegration === "function" ? [loadedSentry.moduleMetadataIntegration()] : []];
3290
+ return new loadedSentry.Hub(new loadedSentry.BrowserClient({
3291
+ dsn: sentryDsn,
3292
+ environment: sentryEnvironment ?? (0, _environmentUtils.calculateEnvironment)(),
3293
+ release: (0, _sentryPluginUtils.buildReleaseString)(artifactData),
3294
+ transport,
3295
+ stackParser,
3296
+ integrations,
3297
+ normalizeDepth: 4,
3298
+ // Change the default nesting depth of (3) because we use one level of nesting when encoding the Panorama context
3299
+ beforeBreadcrumb: _sentryPluginBreadcrumbs.enrichBreadcrumbsWithDataHooks,
3300
+ beforeSend(event, hint) {
3301
+ return typeof sentryBeforeSendHook === "function" ? sentryBeforeSendHook(event, hint) : event;
3302
+ },
3303
+ debug: true
3304
+ }));
3305
+ };
3251
3306
  sentry = globalConfig.getStateValue("sentryResolved") ?? sentry;
3252
3307
  if ((0, _sentryPluginHubUtils.isLazySentry)(sentry)) {
3253
3308
  return (0, _sentryPluginHubUtils.createLazyHubResult)(globalConfig, sentry, create, sentryBeforeSend);
@@ -3279,11 +3334,9 @@ var require_sentry_plugin = __commonJS({
3279
3334
  hub,
3280
3335
  sentry
3281
3336
  } = resolvedHubResult;
3282
- if (uuid) {
3283
- hub.setUser({
3284
- id: uuid
3285
- });
3286
- }
3337
+ hub.setUser({
3338
+ id: uuid ?? ""
3339
+ });
3287
3340
  hub.setTags({
3288
3341
  fullArtifactId,
3289
3342
  componentId,
@@ -3357,11 +3410,13 @@ var require_sentry_plugin = __commonJS({
3357
3410
  reportToPanorama = false;
3358
3411
  reportToSentry = false;
3359
3412
  targetHub.withScope((scope) => {
3413
+ var _event$exception;
3360
3414
  (0, _sentryPluginEnricher.attachPanoramaDataToSentryScope)(scope, {
3361
3415
  ...panoramaData,
3362
- originalHandler: artifactData
3416
+ originalHandler: artifactData,
3417
+ originalErrorName: (_event$exception = event.exception) == null || (_event$exception = _event$exception.values) == null || (_event$exception = _event$exception[0]) == null ? void 0 : _event$exception.type
3363
3418
  });
3364
- targetHub.captureException(error);
3419
+ targetHub.captureException((0, _errorUtils.createUndedupableError)(error));
3365
3420
  });
3366
3421
  break;
3367
3422
  case _sentryPluginTypes.RoutingAction.CONTINUE:
@@ -3395,8 +3450,8 @@ var require_sentry_plugin = __commonJS({
3395
3450
  if (data != null && data.externalId) {
3396
3451
  return;
3397
3452
  }
3398
- const reportErrorToSentry = (resolvedHbResult) => {
3399
- let sentryHub = resolvedHbResult.hub;
3453
+ const reportErrorToSentry = (resolvedHubResult) => {
3454
+ let sentryHub = resolvedHubResult.hub;
3400
3455
  const {
3401
3456
  sentryLookupDsn,
3402
3457
  sentryEnvironment
@@ -12031,6 +12086,7 @@ var require_utils9 = __commonJS({
12031
12086
  "use strict";
12032
12087
  exports2.__esModule = true;
12033
12088
  exports2.isCI = isCI;
12089
+ exports2.isNode = isNode;
12034
12090
  function isCI() {
12035
12091
  if (isNode()) {
12036
12092
  return !!process.env.TEAMCITY_VERSION || !!process.env.BUILDKITE;
@@ -12052,7 +12108,7 @@ var require_artifact_id3 = __commonJS({
12052
12108
  exports2.artifactId = artifactId;
12053
12109
  var _utils = require_utils9();
12054
12110
  function artifactId(override) {
12055
- const artifactIdToUse = process.env.ARTIFACT_ID ?? process.env.APP_NAME ?? "";
12111
+ const artifactIdToUse = (0, _utils.isNode)() ? process.env.ARTIFACT_ID ?? process.env.APP_NAME ?? "" : "";
12056
12112
  return {
12057
12113
  "X-Wix-Client-Artifact-Id": override ?? (!(0, _utils.isCI)() ? artifactIdToUse : "")
12058
12114
  };
@@ -16960,13 +17016,14 @@ var base64urlRegex = /^([0-9a-zA-Z-_]{4})*(([0-9a-zA-Z-_]{2}(==)?)|([0-9a-zA-Z-_
16960
17016
  var dateRegexSource = `((\\d\\d[2468][048]|\\d\\d[13579][26]|\\d\\d0[48]|[02468][048]00|[13579][26]00)-02-29|\\d{4}-((0[13578]|1[02])-(0[1-9]|[12]\\d|3[01])|(0[469]|11)-(0[1-9]|[12]\\d|30)|(02)-(0[1-9]|1\\d|2[0-8])))`;
16961
17017
  var dateRegex = new RegExp(`^${dateRegexSource}$`);
16962
17018
  function timeRegexSource(args) {
16963
- let regex = `([01]\\d|2[0-3]):[0-5]\\d:[0-5]\\d`;
17019
+ let secondsRegexSource = `[0-5]\\d`;
16964
17020
  if (args.precision) {
16965
- regex = `${regex}\\.\\d{${args.precision}}`;
17021
+ secondsRegexSource = `${secondsRegexSource}\\.\\d{${args.precision}}`;
16966
17022
  } else if (args.precision == null) {
16967
- regex = `${regex}(\\.\\d+)?`;
17023
+ secondsRegexSource = `${secondsRegexSource}(\\.\\d+)?`;
16968
17024
  }
16969
- return regex;
17025
+ const secondsQuantifier = args.precision ? "+" : "?";
17026
+ return `([01]\\d|2[0-3]):[0-5]\\d(:${secondsRegexSource})${secondsQuantifier}`;
16970
17027
  }
16971
17028
  function timeRegex(args) {
16972
17029
  return new RegExp(`^${timeRegexSource(args)}$`);
@@ -20177,21 +20234,23 @@ var z = /* @__PURE__ */ Object.freeze({
20177
20234
  });
20178
20235
 
20179
20236
  // ../../node_modules/@modelcontextprotocol/sdk/dist/esm/types.js
20180
- var LATEST_PROTOCOL_VERSION = "2024-11-05";
20237
+ var LATEST_PROTOCOL_VERSION = "2025-03-26";
20181
20238
  var SUPPORTED_PROTOCOL_VERSIONS = [
20182
20239
  LATEST_PROTOCOL_VERSION,
20240
+ "2024-11-05",
20183
20241
  "2024-10-07"
20184
20242
  ];
20185
20243
  var JSONRPC_VERSION = "2.0";
20186
20244
  var ProgressTokenSchema = z.union([z.string(), z.number().int()]);
20187
20245
  var CursorSchema = z.string();
20246
+ var RequestMetaSchema = z.object({
20247
+ /**
20248
+ * If specified, the caller is requesting out-of-band progress notifications for this request (as represented by notifications/progress). The value of this parameter is an opaque token that will be attached to any subsequent notifications. The receiver is not obligated to provide these notifications.
20249
+ */
20250
+ progressToken: z.optional(ProgressTokenSchema)
20251
+ }).passthrough();
20188
20252
  var BaseRequestParamsSchema = z.object({
20189
- _meta: z.optional(z.object({
20190
- /**
20191
- * If specified, the caller is requesting out-of-band progress notifications for this request (as represented by notifications/progress). The value of this parameter is an opaque token that will be attached to any subsequent notifications. The receiver is not obligated to provide these notifications.
20192
- */
20193
- progressToken: z.optional(ProgressTokenSchema)
20194
- }).passthrough())
20253
+ _meta: z.optional(RequestMetaSchema)
20195
20254
  }).passthrough();
20196
20255
  var RequestSchema = z.object({
20197
20256
  method: z.string(),
@@ -20218,14 +20277,17 @@ var JSONRPCRequestSchema = z.object({
20218
20277
  jsonrpc: z.literal(JSONRPC_VERSION),
20219
20278
  id: RequestIdSchema
20220
20279
  }).merge(RequestSchema).strict();
20280
+ var isJSONRPCRequest = (value) => JSONRPCRequestSchema.safeParse(value).success;
20221
20281
  var JSONRPCNotificationSchema = z.object({
20222
20282
  jsonrpc: z.literal(JSONRPC_VERSION)
20223
20283
  }).merge(NotificationSchema).strict();
20284
+ var isJSONRPCNotification = (value) => JSONRPCNotificationSchema.safeParse(value).success;
20224
20285
  var JSONRPCResponseSchema = z.object({
20225
20286
  jsonrpc: z.literal(JSONRPC_VERSION),
20226
20287
  id: RequestIdSchema,
20227
20288
  result: ResultSchema
20228
20289
  }).strict();
20290
+ var isJSONRPCResponse = (value) => JSONRPCResponseSchema.safeParse(value).success;
20229
20291
  var ErrorCode;
20230
20292
  (function(ErrorCode2) {
20231
20293
  ErrorCode2[ErrorCode2["ConnectionClosed"] = -32e3] = "ConnectionClosed";
@@ -20254,6 +20316,7 @@ var JSONRPCErrorSchema = z.object({
20254
20316
  data: z.optional(z.unknown())
20255
20317
  })
20256
20318
  }).strict();
20319
+ var isJSONRPCError = (value) => JSONRPCErrorSchema.safeParse(value).success;
20257
20320
  var JSONRPCMessageSchema = z.union([
20258
20321
  JSONRPCRequestSchema,
20259
20322
  JSONRPCNotificationSchema,
@@ -20629,6 +20692,45 @@ var GetPromptResultSchema = ResultSchema.extend({
20629
20692
  var PromptListChangedNotificationSchema = NotificationSchema.extend({
20630
20693
  method: z.literal("notifications/prompts/list_changed")
20631
20694
  });
20695
+ var ToolAnnotationsSchema = z.object({
20696
+ /**
20697
+ * A human-readable title for the tool.
20698
+ */
20699
+ title: z.optional(z.string()),
20700
+ /**
20701
+ * If true, the tool does not modify its environment.
20702
+ *
20703
+ * Default: false
20704
+ */
20705
+ readOnlyHint: z.optional(z.boolean()),
20706
+ /**
20707
+ * If true, the tool may perform destructive updates to its environment.
20708
+ * If false, the tool performs only additive updates.
20709
+ *
20710
+ * (This property is meaningful only when `readOnlyHint == false`)
20711
+ *
20712
+ * Default: true
20713
+ */
20714
+ destructiveHint: z.optional(z.boolean()),
20715
+ /**
20716
+ * If true, calling the tool repeatedly with the same arguments
20717
+ * will have no additional effect on the its environment.
20718
+ *
20719
+ * (This property is meaningful only when `readOnlyHint == false`)
20720
+ *
20721
+ * Default: false
20722
+ */
20723
+ idempotentHint: z.optional(z.boolean()),
20724
+ /**
20725
+ * If true, this tool may interact with an "open world" of external
20726
+ * entities. If false, the tool's domain of interaction is closed.
20727
+ * For example, the world of a web search tool is open, whereas that
20728
+ * of a memory tool is not.
20729
+ *
20730
+ * Default: true
20731
+ */
20732
+ openWorldHint: z.optional(z.boolean())
20733
+ }).passthrough();
20632
20734
  var ToolSchema = z.object({
20633
20735
  /**
20634
20736
  * The name of the tool.
@@ -20644,7 +20746,11 @@ var ToolSchema = z.object({
20644
20746
  inputSchema: z.object({
20645
20747
  type: z.literal("object"),
20646
20748
  properties: z.optional(z.object({}).passthrough())
20647
- }).passthrough()
20749
+ }).passthrough(),
20750
+ /**
20751
+ * Optional additional tool information.
20752
+ */
20753
+ annotations: z.optional(ToolAnnotationsSchema)
20648
20754
  }).passthrough();
20649
20755
  var ListToolsRequestSchema = PaginatedRequestSchema.extend({
20650
20756
  method: z.literal("tools/list")
@@ -20974,13 +21080,15 @@ var Protocol = class {
20974
21080
  this._transport.onerror = (error) => {
20975
21081
  this._onerror(error);
20976
21082
  };
20977
- this._transport.onmessage = (message) => {
20978
- if (!("method" in message)) {
21083
+ this._transport.onmessage = (message, extra) => {
21084
+ if (isJSONRPCResponse(message) || isJSONRPCError(message)) {
20979
21085
  this._onresponse(message);
20980
- } else if ("id" in message) {
20981
- this._onrequest(message);
20982
- } else {
21086
+ } else if (isJSONRPCRequest(message)) {
21087
+ this._onrequest(message, extra);
21088
+ } else if (isJSONRPCNotification(message)) {
20983
21089
  this._onnotification(message);
21090
+ } else {
21091
+ this._onerror(new Error(`Unknown message type: ${JSON.stringify(message)}`));
20984
21092
  }
20985
21093
  };
20986
21094
  await this._transport.start();
@@ -21009,8 +21117,8 @@ var Protocol = class {
21009
21117
  }
21010
21118
  Promise.resolve().then(() => handler(notification)).catch((error) => this._onerror(new Error(`Uncaught error in notification handler: ${error}`)));
21011
21119
  }
21012
- _onrequest(request) {
21013
- var _a, _b, _c;
21120
+ _onrequest(request, extra) {
21121
+ var _a, _b, _c, _d;
21014
21122
  const handler = (_a = this._requestHandlers.get(request.method)) !== null && _a !== void 0 ? _a : this.fallbackRequestHandler;
21015
21123
  if (handler === void 0) {
21016
21124
  (_b = this._transport) === null || _b === void 0 ? void 0 : _b.send({
@@ -21025,11 +21133,16 @@ var Protocol = class {
21025
21133
  }
21026
21134
  const abortController = new AbortController();
21027
21135
  this._requestHandlerAbortControllers.set(request.id, abortController);
21028
- const extra = {
21136
+ const fullExtra = {
21029
21137
  signal: abortController.signal,
21030
- sessionId: (_c = this._transport) === null || _c === void 0 ? void 0 : _c.sessionId
21031
- };
21032
- Promise.resolve().then(() => handler(request, extra)).then((result) => {
21138
+ sessionId: (_c = this._transport) === null || _c === void 0 ? void 0 : _c.sessionId,
21139
+ _meta: (_d = request.params) === null || _d === void 0 ? void 0 : _d._meta,
21140
+ sendNotification: (notification) => this.notification(notification, { relatedRequestId: request.id }),
21141
+ sendRequest: (r, resultSchema, options) => this.request(r, resultSchema, { ...options, relatedRequestId: request.id }),
21142
+ authInfo: extra === null || extra === void 0 ? void 0 : extra.authInfo,
21143
+ requestId: request.id
21144
+ };
21145
+ Promise.resolve().then(() => handler(request, fullExtra)).then((result) => {
21033
21146
  var _a2;
21034
21147
  if (abortController.signal.aborted) {
21035
21148
  return;
@@ -21086,7 +21199,7 @@ var Protocol = class {
21086
21199
  this._responseHandlers.delete(messageId);
21087
21200
  this._progressHandlers.delete(messageId);
21088
21201
  this._cleanupTimeout(messageId);
21089
- if ("result" in response) {
21202
+ if (isJSONRPCResponse(response)) {
21090
21203
  handler(response);
21091
21204
  } else {
21092
21205
  const error = new McpError(response.error.code, response.error.message, response.error.data);
@@ -21109,6 +21222,7 @@ var Protocol = class {
21109
21222
  * Do not use this method to emit notifications! Use notification() instead.
21110
21223
  */
21111
21224
  request(request, resultSchema, options) {
21225
+ const { relatedRequestId, resumptionToken, onresumptiontoken } = options !== null && options !== void 0 ? options : {};
21112
21226
  return new Promise((resolve, reject) => {
21113
21227
  var _a, _b, _c, _d, _e;
21114
21228
  if (!this._transport) {
@@ -21144,7 +21258,7 @@ var Protocol = class {
21144
21258
  requestId: messageId,
21145
21259
  reason: String(reason)
21146
21260
  }
21147
- }).catch((error) => this._onerror(new Error(`Failed to send cancellation: ${error}`)));
21261
+ }, { relatedRequestId, resumptionToken, onresumptiontoken }).catch((error) => this._onerror(new Error(`Failed to send cancellation: ${error}`)));
21148
21262
  reject(reason);
21149
21263
  };
21150
21264
  this._responseHandlers.set(messageId, (response) => {
@@ -21169,7 +21283,7 @@ var Protocol = class {
21169
21283
  const timeout = (_d = options === null || options === void 0 ? void 0 : options.timeout) !== null && _d !== void 0 ? _d : DEFAULT_REQUEST_TIMEOUT_MSEC;
21170
21284
  const timeoutHandler = () => cancel(new McpError(ErrorCode.RequestTimeout, "Request timed out", { timeout }));
21171
21285
  this._setupTimeout(messageId, timeout, options === null || options === void 0 ? void 0 : options.maxTotalTimeout, timeoutHandler, (_e = options === null || options === void 0 ? void 0 : options.resetTimeoutOnProgress) !== null && _e !== void 0 ? _e : false);
21172
- this._transport.send(jsonrpcRequest).catch((error) => {
21286
+ this._transport.send(jsonrpcRequest, { relatedRequestId, resumptionToken, onresumptiontoken }).catch((error) => {
21173
21287
  this._cleanupTimeout(messageId);
21174
21288
  reject(error);
21175
21289
  });
@@ -21178,7 +21292,7 @@ var Protocol = class {
21178
21292
  /**
21179
21293
  * Emits a notification, which is a one-way message that does not expect a response.
21180
21294
  */
21181
- async notification(notification) {
21295
+ async notification(notification, options) {
21182
21296
  if (!this._transport) {
21183
21297
  throw new Error("Not connected");
21184
21298
  }
@@ -21187,7 +21301,7 @@ var Protocol = class {
21187
21301
  ...notification,
21188
21302
  jsonrpc: "2.0"
21189
21303
  };
21190
- await this._transport.send(jsonrpcNotification);
21304
+ await this._transport.send(jsonrpcNotification, options);
21191
21305
  }
21192
21306
  /**
21193
21307
  * Registers a handler to invoke when this protocol object receives a request with the given method.
@@ -21197,7 +21311,9 @@ var Protocol = class {
21197
21311
  setRequestHandler(requestSchema, handler) {
21198
21312
  const method = requestSchema.shape.method.value;
21199
21313
  this.assertRequestHandlerCapability(method);
21200
- this._requestHandlers.set(method, (request, extra) => Promise.resolve(handler(requestSchema.parse(request), extra)));
21314
+ this._requestHandlers.set(method, (request, extra) => {
21315
+ return Promise.resolve(handler(requestSchema.parse(request), extra));
21316
+ });
21201
21317
  }
21202
21318
  /**
21203
21319
  * Removes the request handler for the given method.
@@ -22740,16 +22856,19 @@ var McpServer = class {
22740
22856
  this.server.assertCanSetRequestHandler(ListToolsRequestSchema.shape.method.value);
22741
22857
  this.server.assertCanSetRequestHandler(CallToolRequestSchema.shape.method.value);
22742
22858
  this.server.registerCapabilities({
22743
- tools: {}
22859
+ tools: {
22860
+ listChanged: true
22861
+ }
22744
22862
  });
22745
22863
  this.server.setRequestHandler(ListToolsRequestSchema, () => ({
22746
- tools: Object.entries(this._registeredTools).map(([name, tool]) => {
22864
+ tools: Object.entries(this._registeredTools).filter(([, tool]) => tool.enabled).map(([name, tool]) => {
22747
22865
  return {
22748
22866
  name,
22749
22867
  description: tool.description,
22750
22868
  inputSchema: tool.inputSchema ? zodToJsonSchema(tool.inputSchema, {
22751
22869
  strictUnions: true
22752
- }) : EMPTY_OBJECT_JSON_SCHEMA
22870
+ }) : EMPTY_OBJECT_JSON_SCHEMA,
22871
+ annotations: tool.annotations
22753
22872
  };
22754
22873
  })
22755
22874
  }));
@@ -22758,6 +22877,9 @@ var McpServer = class {
22758
22877
  if (!tool) {
22759
22878
  throw new McpError(ErrorCode.InvalidParams, `Tool ${request.params.name} not found`);
22760
22879
  }
22880
+ if (!tool.enabled) {
22881
+ throw new McpError(ErrorCode.InvalidParams, `Tool ${request.params.name} disabled`);
22882
+ }
22761
22883
  if (tool.inputSchema) {
22762
22884
  const parseResult = await tool.inputSchema.safeParseAsync(request.params.arguments);
22763
22885
  if (!parseResult.success) {
@@ -22817,7 +22939,10 @@ var McpServer = class {
22817
22939
  async handlePromptCompletion(request, ref) {
22818
22940
  const prompt = this._registeredPrompts[ref.name];
22819
22941
  if (!prompt) {
22820
- throw new McpError(ErrorCode.InvalidParams, `Prompt ${request.params.ref.name} not found`);
22942
+ throw new McpError(ErrorCode.InvalidParams, `Prompt ${ref.name} not found`);
22943
+ }
22944
+ if (!prompt.enabled) {
22945
+ throw new McpError(ErrorCode.InvalidParams, `Prompt ${ref.name} disabled`);
22821
22946
  }
22822
22947
  if (!prompt.argsSchema) {
22823
22948
  return EMPTY_COMPLETION_RESULT;
@@ -22853,10 +22978,12 @@ var McpServer = class {
22853
22978
  this.server.assertCanSetRequestHandler(ListResourceTemplatesRequestSchema.shape.method.value);
22854
22979
  this.server.assertCanSetRequestHandler(ReadResourceRequestSchema.shape.method.value);
22855
22980
  this.server.registerCapabilities({
22856
- resources: {}
22981
+ resources: {
22982
+ listChanged: true
22983
+ }
22857
22984
  });
22858
22985
  this.server.setRequestHandler(ListResourcesRequestSchema, async (request, extra) => {
22859
- const resources = Object.entries(this._registeredResources).map(([uri, resource]) => ({
22986
+ const resources = Object.entries(this._registeredResources).filter(([_, resource]) => resource.enabled).map(([uri, resource]) => ({
22860
22987
  uri,
22861
22988
  name: resource.name,
22862
22989
  ...resource.metadata
@@ -22888,6 +23015,9 @@ var McpServer = class {
22888
23015
  const uri = new URL(request.params.uri);
22889
23016
  const resource = this._registeredResources[uri.toString()];
22890
23017
  if (resource) {
23018
+ if (!resource.enabled) {
23019
+ throw new McpError(ErrorCode.InvalidParams, `Resource ${uri} disabled`);
23020
+ }
22891
23021
  return resource.readCallback(uri, extra);
22892
23022
  }
22893
23023
  for (const template of Object.values(this._registeredResourceTemplates)) {
@@ -22908,10 +23038,12 @@ var McpServer = class {
22908
23038
  this.server.assertCanSetRequestHandler(ListPromptsRequestSchema.shape.method.value);
22909
23039
  this.server.assertCanSetRequestHandler(GetPromptRequestSchema.shape.method.value);
22910
23040
  this.server.registerCapabilities({
22911
- prompts: {}
23041
+ prompts: {
23042
+ listChanged: true
23043
+ }
22912
23044
  });
22913
23045
  this.server.setRequestHandler(ListPromptsRequestSchema, () => ({
22914
- prompts: Object.entries(this._registeredPrompts).map(([name, prompt]) => {
23046
+ prompts: Object.entries(this._registeredPrompts).filter(([, prompt]) => prompt.enabled).map(([name, prompt]) => {
22915
23047
  return {
22916
23048
  name,
22917
23049
  description: prompt.description,
@@ -22924,6 +23056,9 @@ var McpServer = class {
22924
23056
  if (!prompt) {
22925
23057
  throw new McpError(ErrorCode.InvalidParams, `Prompt ${request.params.name} not found`);
22926
23058
  }
23059
+ if (!prompt.enabled) {
23060
+ throw new McpError(ErrorCode.InvalidParams, `Prompt ${request.params.name} disabled`);
23061
+ }
22927
23062
  if (prompt.argsSchema) {
22928
23063
  const parseResult = await prompt.argsSchema.safeParseAsync(request.params.arguments);
22929
23064
  if (!parseResult.success) {
@@ -22950,22 +23085,69 @@ var McpServer = class {
22950
23085
  if (this._registeredResources[uriOrTemplate]) {
22951
23086
  throw new Error(`Resource ${uriOrTemplate} is already registered`);
22952
23087
  }
22953
- this._registeredResources[uriOrTemplate] = {
23088
+ const registeredResource = {
22954
23089
  name,
22955
23090
  metadata,
22956
- readCallback
23091
+ readCallback,
23092
+ enabled: true,
23093
+ disable: () => registeredResource.update({ enabled: false }),
23094
+ enable: () => registeredResource.update({ enabled: true }),
23095
+ remove: () => registeredResource.update({ uri: null }),
23096
+ update: (updates) => {
23097
+ if (typeof updates.uri !== "undefined" && updates.uri !== uriOrTemplate) {
23098
+ delete this._registeredResources[uriOrTemplate];
23099
+ if (updates.uri)
23100
+ this._registeredResources[updates.uri] = registeredResource;
23101
+ }
23102
+ if (typeof updates.name !== "undefined")
23103
+ registeredResource.name = updates.name;
23104
+ if (typeof updates.metadata !== "undefined")
23105
+ registeredResource.metadata = updates.metadata;
23106
+ if (typeof updates.callback !== "undefined")
23107
+ registeredResource.readCallback = updates.callback;
23108
+ if (typeof updates.enabled !== "undefined")
23109
+ registeredResource.enabled = updates.enabled;
23110
+ this.sendResourceListChanged();
23111
+ }
22957
23112
  };
23113
+ this._registeredResources[uriOrTemplate] = registeredResource;
23114
+ this.setResourceRequestHandlers();
23115
+ this.sendResourceListChanged();
23116
+ return registeredResource;
22958
23117
  } else {
22959
23118
  if (this._registeredResourceTemplates[name]) {
22960
23119
  throw new Error(`Resource template ${name} is already registered`);
22961
23120
  }
22962
- this._registeredResourceTemplates[name] = {
23121
+ const registeredResourceTemplate = {
22963
23122
  resourceTemplate: uriOrTemplate,
22964
23123
  metadata,
22965
- readCallback
23124
+ readCallback,
23125
+ enabled: true,
23126
+ disable: () => registeredResourceTemplate.update({ enabled: false }),
23127
+ enable: () => registeredResourceTemplate.update({ enabled: true }),
23128
+ remove: () => registeredResourceTemplate.update({ name: null }),
23129
+ update: (updates) => {
23130
+ if (typeof updates.name !== "undefined" && updates.name !== name) {
23131
+ delete this._registeredResourceTemplates[name];
23132
+ if (updates.name)
23133
+ this._registeredResourceTemplates[updates.name] = registeredResourceTemplate;
23134
+ }
23135
+ if (typeof updates.template !== "undefined")
23136
+ registeredResourceTemplate.resourceTemplate = updates.template;
23137
+ if (typeof updates.metadata !== "undefined")
23138
+ registeredResourceTemplate.metadata = updates.metadata;
23139
+ if (typeof updates.callback !== "undefined")
23140
+ registeredResourceTemplate.readCallback = updates.callback;
23141
+ if (typeof updates.enabled !== "undefined")
23142
+ registeredResourceTemplate.enabled = updates.enabled;
23143
+ this.sendResourceListChanged();
23144
+ }
22966
23145
  };
23146
+ this._registeredResourceTemplates[name] = registeredResourceTemplate;
23147
+ this.setResourceRequestHandlers();
23148
+ this.sendResourceListChanged();
23149
+ return registeredResourceTemplate;
22967
23150
  }
22968
- this.setResourceRequestHandlers();
22969
23151
  }
22970
23152
  tool(name, ...rest) {
22971
23153
  if (this._registeredTools[name]) {
@@ -22976,16 +23158,51 @@ var McpServer = class {
22976
23158
  description = rest.shift();
22977
23159
  }
22978
23160
  let paramsSchema;
23161
+ let annotations;
22979
23162
  if (rest.length > 1) {
22980
- paramsSchema = rest.shift();
23163
+ const firstArg = rest[0];
23164
+ if (isZodRawShape(firstArg)) {
23165
+ paramsSchema = rest.shift();
23166
+ if (rest.length > 1 && typeof rest[0] === "object" && rest[0] !== null && !isZodRawShape(rest[0])) {
23167
+ annotations = rest.shift();
23168
+ }
23169
+ } else if (typeof firstArg === "object" && firstArg !== null) {
23170
+ annotations = rest.shift();
23171
+ }
22981
23172
  }
22982
23173
  const cb = rest[0];
22983
- this._registeredTools[name] = {
23174
+ const registeredTool = {
22984
23175
  description,
22985
23176
  inputSchema: paramsSchema === void 0 ? void 0 : z.object(paramsSchema),
22986
- callback: cb
22987
- };
23177
+ annotations,
23178
+ callback: cb,
23179
+ enabled: true,
23180
+ disable: () => registeredTool.update({ enabled: false }),
23181
+ enable: () => registeredTool.update({ enabled: true }),
23182
+ remove: () => registeredTool.update({ name: null }),
23183
+ update: (updates) => {
23184
+ if (typeof updates.name !== "undefined" && updates.name !== name) {
23185
+ delete this._registeredTools[name];
23186
+ if (updates.name)
23187
+ this._registeredTools[updates.name] = registeredTool;
23188
+ }
23189
+ if (typeof updates.description !== "undefined")
23190
+ registeredTool.description = updates.description;
23191
+ if (typeof updates.paramsSchema !== "undefined")
23192
+ registeredTool.inputSchema = z.object(updates.paramsSchema);
23193
+ if (typeof updates.callback !== "undefined")
23194
+ registeredTool.callback = updates.callback;
23195
+ if (typeof updates.annotations !== "undefined")
23196
+ registeredTool.annotations = updates.annotations;
23197
+ if (typeof updates.enabled !== "undefined")
23198
+ registeredTool.enabled = updates.enabled;
23199
+ this.sendToolListChanged();
23200
+ }
23201
+ };
23202
+ this._registeredTools[name] = registeredTool;
22988
23203
  this.setToolRequestHandlers();
23204
+ this.sendToolListChanged();
23205
+ return registeredTool;
22989
23206
  }
22990
23207
  prompt(name, ...rest) {
22991
23208
  if (this._registeredPrompts[name]) {
@@ -23000,17 +23217,80 @@ var McpServer = class {
23000
23217
  argsSchema = rest.shift();
23001
23218
  }
23002
23219
  const cb = rest[0];
23003
- this._registeredPrompts[name] = {
23220
+ const registeredPrompt = {
23004
23221
  description,
23005
23222
  argsSchema: argsSchema === void 0 ? void 0 : z.object(argsSchema),
23006
- callback: cb
23007
- };
23223
+ callback: cb,
23224
+ enabled: true,
23225
+ disable: () => registeredPrompt.update({ enabled: false }),
23226
+ enable: () => registeredPrompt.update({ enabled: true }),
23227
+ remove: () => registeredPrompt.update({ name: null }),
23228
+ update: (updates) => {
23229
+ if (typeof updates.name !== "undefined" && updates.name !== name) {
23230
+ delete this._registeredPrompts[name];
23231
+ if (updates.name)
23232
+ this._registeredPrompts[updates.name] = registeredPrompt;
23233
+ }
23234
+ if (typeof updates.description !== "undefined")
23235
+ registeredPrompt.description = updates.description;
23236
+ if (typeof updates.argsSchema !== "undefined")
23237
+ registeredPrompt.argsSchema = z.object(updates.argsSchema);
23238
+ if (typeof updates.callback !== "undefined")
23239
+ registeredPrompt.callback = updates.callback;
23240
+ if (typeof updates.enabled !== "undefined")
23241
+ registeredPrompt.enabled = updates.enabled;
23242
+ this.sendPromptListChanged();
23243
+ }
23244
+ };
23245
+ this._registeredPrompts[name] = registeredPrompt;
23008
23246
  this.setPromptRequestHandlers();
23247
+ this.sendPromptListChanged();
23248
+ return registeredPrompt;
23249
+ }
23250
+ /**
23251
+ * Checks if the server is connected to a transport.
23252
+ * @returns True if the server is connected
23253
+ */
23254
+ isConnected() {
23255
+ return this.server.transport !== void 0;
23256
+ }
23257
+ /**
23258
+ * Sends a resource list changed event to the client, if connected.
23259
+ */
23260
+ sendResourceListChanged() {
23261
+ if (this.isConnected()) {
23262
+ this.server.sendResourceListChanged();
23263
+ }
23264
+ }
23265
+ /**
23266
+ * Sends a tool list changed event to the client, if connected.
23267
+ */
23268
+ sendToolListChanged() {
23269
+ if (this.isConnected()) {
23270
+ this.server.sendToolListChanged();
23271
+ }
23272
+ }
23273
+ /**
23274
+ * Sends a prompt list changed event to the client, if connected.
23275
+ */
23276
+ sendPromptListChanged() {
23277
+ if (this.isConnected()) {
23278
+ this.server.sendPromptListChanged();
23279
+ }
23009
23280
  }
23010
23281
  };
23011
23282
  var EMPTY_OBJECT_JSON_SCHEMA = {
23012
23283
  type: "object"
23013
23284
  };
23285
+ function isZodRawShape(obj) {
23286
+ if (typeof obj !== "object" || obj === null)
23287
+ return false;
23288
+ const isEmptyObject = Object.keys(obj).length === 0;
23289
+ return isEmptyObject || Object.values(obj).some(isZodTypeLike);
23290
+ }
23291
+ function isZodTypeLike(value) {
23292
+ return value !== null && typeof value === "object" && "parse" in value && typeof value.parse === "function" && "safeParse" in value && typeof value.safeParse === "function";
23293
+ }
23014
23294
  function promptArgumentsFromSchema(schema) {
23015
23295
  return Object.entries(schema.shape).map(([name, field]) => ({
23016
23296
  name,
@@ -23101,6 +23381,22 @@ function getEnvironment(nodeEnv) {
23101
23381
 
23102
23382
  // src/wix-mcp-server.ts
23103
23383
  var import_http_client = __toESM(require_index_node3(), 1);
23384
+
23385
+ // src/infra/logger.ts
23386
+ var import_promises = __toESM(require("fs/promises"), 1);
23387
+ var import_path = __toESM(require("path"), 1);
23388
+ var import_os = require("os");
23389
+ var createNullLogger = () => {
23390
+ return {
23391
+ log: () => {
23392
+ },
23393
+ error: () => {
23394
+ }
23395
+ };
23396
+ };
23397
+ var logger2 = createNullLogger();
23398
+
23399
+ // src/wix-mcp-server.ts
23104
23400
  var WixMcpServer = class extends McpServer {
23105
23401
  biLogger;
23106
23402
  nodeEnv;
@@ -23113,6 +23409,7 @@ var WixMcpServer = class extends McpServer {
23113
23409
  this.biLogger = createBiLogger({
23114
23410
  _client_id: this.sessionId
23115
23411
  });
23412
+ logger2.log(`WixMcpServer created with sessionId: ${this.sessionId}`);
23116
23413
  }
23117
23414
  setUserIdGetter(getUserId) {
23118
23415
  this.getUserId = getUserId;
@@ -23208,20 +23505,6 @@ var WixMcpServer = class extends McpServer {
23208
23505
  }
23209
23506
  };
23210
23507
 
23211
- // src/infra/logger.ts
23212
- var import_promises = __toESM(require("fs/promises"), 1);
23213
- var import_path = __toESM(require("path"), 1);
23214
- var import_os = require("os");
23215
- var createNullLogger = () => {
23216
- return {
23217
- log: () => {
23218
- },
23219
- error: () => {
23220
- }
23221
- };
23222
- };
23223
- var logger2 = createNullLogger();
23224
-
23225
23508
  // src/docs/semanticSearch.ts
23226
23509
  var MAX_CONTENT_LENGTH = 1e4;
23227
23510
  var DEFAULT_MAX_RESULTS = 10;
@@ -23818,17 +24101,13 @@ var addDocsTools = (server, allowedTools = [
23818
24101
 
23819
24102
  // src/docs/get-to-know.ts
23820
24103
  var defaultDocUrl = "https://dev.wix.com/docs/picasso/wix-ai-docs/rules/get-to-know-wix-llm-instructions";
23821
- var DESCRIPTION = `\u{1F534} **REQUIRED FIRST STEP for all Wix tasks.** This tool is the primary guide for the Wix ecosystem, offering global setup instructions and current best practices.
23822
-
23823
- **Rule: ALWAYS run this tool successfully BEFORE any other Wix-specific action (e.g., doc searches, API calls, coding). NO EXCEPTIONS.** Failing to do so will likely cause errors.
24104
+ var DESCRIPTION = `**Tool Name:** WixREADME
24105
+ **Description for LLM:**
24106
+ "**Mandatory First Action for Wix Tasks.** This tool, 'WixREADME', MUST be executed at the very beginning of any process involving Wix functionalities. It provides the indispensable foundational Wix ecosystem context, global setup details, and current best practices.
23824
24107
 
23825
- The information from this tool is foundational and MUST inform all subsequent Wix actions.
24108
+ **Operational Rule:** Your processing protocol for any Wix-related task dictates that 'WixREADME' is successfully invoked and its output comprehensively analyzed BEFORE any other Wix-specific tool (such as 'ReadFullDocsArticle' or 'SearchX..') is considered or used. This is a non-negotiable prerequisite.
23826
24109
 
23827
- **Instructions for user requests:**
23828
-
23829
- 1. **Identify Wix concepts** relevant to the query (refer to ReadMe).
23830
- 2. **Read best practices:** For each concept, if a \`<best-practices>{url}</best-practices>\` document exists in ReadMe, use 'ReadFullDocsArticle' to access it.
23831
- 3. **Search:** If more information is needed, use 'SearchX' tools.`;
24110
+ **Function:** Acts as the sole authoritative source for Wix global operational standards and session initialization. Its output is essential for the correct and safe execution of all subsequent Wix-related actions. All other Wix tools are designed to rely on the information it provides."`;
23832
24111
  async function addGetToKnowTools(server, docUrl) {
23833
24112
  server.tool("WixREADME", DESCRIPTION, async ({ httpClient }) => {
23834
24113
  try {
@@ -23863,20 +24142,33 @@ var safeParseJSON = (text) => {
23863
24142
  return text;
23864
24143
  }
23865
24144
  };
24145
+ var buildErrorMessage = ({
24146
+ status,
24147
+ statusText,
24148
+ requestId,
24149
+ responseData
24150
+ }) => {
24151
+ const responseDataObject = typeof responseData === "string" ? safeParseJSON(responseData) : responseData;
24152
+ const errorDetails = typeof responseDataObject === "object" ? JSON.stringify(responseDataObject) : responseDataObject;
24153
+ return [
24154
+ `Failed to call Wix API:${status ? ` ${status}` : ""}${statusText ? ` ${statusText}` : ""}.`,
24155
+ requestId ? `request id: ${requestId}` : "",
24156
+ // Wix 404 for API does not exist is huge (generic 404 page) and loaded to the context
24157
+ status === 404 && errorDetails.includes("<html") ? "Not found" : errorDetails
24158
+ ].filter((str) => !!str).join("\n");
24159
+ };
23866
24160
  var handleWixAPIResponse = async (response) => {
23867
- const responseData = typeof response.data === "string" ? safeParseJSON(response.data) : response.data;
24161
+ const requestId = response.headers.get?.("x-wix-request-id");
23868
24162
  if (!response.status.toString().startsWith("2")) {
23869
- const requestId = response.headers.get("x-wix-request-id");
23870
- const errorDetails = typeof responseData === "object" ? JSON.stringify(responseData) : responseData;
23871
- throw new Error(
23872
- [
23873
- `Failed to call Wix API: ${response.status} ${response.statusText}.`,
23874
- requestId ? `request id: ${requestId}` : "",
23875
- // Wix 404 for API does not exist is huge (generic 404 page) and loaded to the context
23876
- response.status === 404 && errorDetails.includes("<html") ? "Not found" : errorDetails
23877
- ].filter((str) => !!str).join("\n")
23878
- );
24163
+ const errorMessage = buildErrorMessage({
24164
+ status: response.status,
24165
+ statusText: response.statusText,
24166
+ requestId,
24167
+ responseData: response.data
24168
+ });
24169
+ throw new Error(errorMessage);
23879
24170
  }
24171
+ const responseData = typeof response.data === "string" ? safeParseJSON(response.data) : response.data;
23880
24172
  return responseData;
23881
24173
  };
23882
24174