@wix/mcp 1.0.82 → 1.0.83

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.
@@ -10561,10 +10561,15 @@ var require_src2 = __commonJS({
10561
10561
  var toolkit_entry_exports = {};
10562
10562
  __export(toolkit_entry_exports, {
10563
10563
  EXECUTE_FUNCTION_EXPRESSION_HINT: () => EXECUTE_FUNCTION_EXPRESSION_HINT,
10564
+ EXECUTE_GRAPHQL_TOOL_NAME: () => EXECUTE_GRAPHQL_TOOL_NAME,
10565
+ GRAPHQL_TOOL_NAMES: () => GRAPHQL_TOOL_NAMES,
10566
+ INSPECT_GRAPHQL_TOOL_NAME: () => INSPECT_GRAPHQL_TOOL_NAME,
10564
10567
  RECIPES_INDEX_URL: () => RECIPES_INDEX_URL,
10568
+ SEARCH_GRAPHQL_TOOL_NAME: () => SEARCH_GRAPHQL_TOOL_NAME,
10565
10569
  SYSTEM_REMINDER: () => SYSTEM_REMINDER,
10566
10570
  SYSTEM_REMINDER_GUIDELINES: () => SYSTEM_REMINDER_GUIDELINES,
10567
10571
  UNAUTHORIZED_ERROR_NAME: () => UNAUTHORIZED_ERROR_NAME,
10572
+ WIX_GRAPHQL_ENDPOINT: () => WIX_GRAPHQL_ENDPOINT,
10568
10573
  WixFetchError: () => WixFetchError,
10569
10574
  attachConsoleLogger: () => attachConsoleLogger,
10570
10575
  createWixToolkit: () => createWixToolkit,
@@ -18482,6 +18487,32 @@ function buildToolDescriptions(includeReadme, includeImageUploadGuidance = true)
18482
18487
 
18483
18488
  Call this when the user provides a specific template by \`metaSiteId\` or \`templateId\`. Use this only when the user gives a valid \`metaSiteId\` or \`templateId\` directly. To browse or choose a template first, call \`SearchSiteTemplates\`.
18484
18489
 
18490
+ `,
18491
+ SearchWixGraphQLOperations: dedent_default`
18492
+ Discover Wix GraphQL operations by intent (ranked keyword search over the root fields). Wix exposes ONE GraphQL schema over all Wix public APIs (Developer Preview) at POST https://www.wixapis.com/graphql/alpha: about 100 query roots and 580 mutation roots named <app><Service><Version><Verb/Entity>, e.g. \`storesProductsV3V3Products\`, \`crmContactsV4Contacts\`, \`crmContactsV4CreateContact\`, \`ecomOrdersV1SearchOrders\`.
18493
+
18494
+ GraphQL flow (3 steps, keep to it): SearchWixGraphQLOperations (find the operation) -> InspectWixGraphQLSchema (read its exact input and return types) -> ExecuteWixGraphQL (run it). Never write an operation or field name you did not see in one of these results.
18495
+
18496
+ When to prefer GraphQL over the REST tools:
18497
+ - Reading several related entities in ONE round-trip: related entities are resolved fields (product -> inventoryItems / collections, order -> fulfillments, booking -> contact), and independent root fields (products + contacts + orders) can share one request.
18498
+ - Picking exactly the fields you need, so responses stay small.
18499
+ - Answering "how many / list / show" questions: a query root plus \`pageInfo\` (\`hasNext\`, and \`total\` where the API provides it).
18500
+ Prefer the REST tools when a recipe or code example already gives you the exact REST call, for uploads/media, or when the GraphQL schema has no matching operation.
18501
+
18502
+ Conventions: query roots take \`queryInput\`; list roots (plural names) take \`queryInput: { query: { paging | cursorPaging, filter, sort } }\` and return \`{ items, pageInfo }\`; singular roots take the entity id. \`filter\`/\`sort\` are a JSON scalar in REST filter syntax (e.g. {"info.name.first": {"$eq": "Ada"}}) — pass them as variables. Mutations take \`input\`; a few read operations (search/list) are exposed as mutations, so search kind "all" unless you are sure.
18503
+ Results list \`kind name(arg: InputType): ReturnType\` plus a one-line description; pass the chosen name to InspectWixGraphQLSchema next.
18504
+ `,
18505
+ InspectWixGraphQLSchema: dedent_default`
18506
+ Read the exact Wix GraphQL schema for an operation and its types, as compact SDL with field descriptions. Pass \`operation\` (a root query/mutation name from SearchWixGraphQLOperations) to get its arguments, input type and return type expanded \`depth\` levels (default 2). Types that were referenced but not expanded are listed at the end — pass the ones you need in \`typeNames\` (optionally together with \`operation\`) instead of raising depth for everything.
18507
+ Use it before every ExecuteWixGraphQL call that introduces a new operation or new fields: read the INPUT type before writing a mutation or filter, and the RETURN type before writing the selection set. GraphQL rejects unknown fields and arguments, and every object-typed field needs its own selection set. \`JSON\` scalar fields (filter, sort, free-form data) accept any JSON — pass them as variables. Never guess a type or field name; if a validation error names a field, come back here.
18508
+ `,
18509
+ ExecuteWixGraphQL: dedent_default`
18510
+ Execute a GraphQL query or mutation against the Wix GraphQL API (POST https://www.wixapis.com/graphql/alpha) with the user's credentials. Authentication is injected — never add Authorization or site/account headers.
18511
+ Site targeting: site-level operations (anything that reads or writes inside a site: products, inventory, orders, contacts, bookings, CMS data, blog, members ...) require \`siteId\`; resolve it with GetSiteContext or ListWixSites first. Use \`scope: "account"\` only for account-level operations.
18512
+ Grounding: every root field, argument and selected field must come from SearchWixGraphQLOperations / InspectWixGraphQLSchema results in this conversation — never from memory. If the response says "Cannot query field" or "Unknown argument", re-inspect the schema and fix the name; do not retry with another guess.
18513
+ Compose: put independent reads in one document as several root fields, and use related-entity fields (e.g. \`inventoryItems\`, \`collections\`, \`fulfillments\`) instead of extra round-trips. Select only the fields you need; every object field needs a selection set. Variables: use them for \`JSON\` scalars (filter, sort) and plain scalars (String, Int, ID), declared in the document (e.g. \`query Q($f: JSON) { ... filter: $f ... }\`). Write mutation inputs and any object that contains an enum INLINE as GraphQL literals with enum values unquoted (e.g. \`input: { product: { name: "Mug", productType: PHYSICAL } }\`) — this endpoint fails with 503 when an enum value arrives inside an object-typed variable. For lists page with \`cursorPaging\` or \`paging\` exactly as the input type declares (never the other one), and request \`pageInfo { hasNext total }\`; \`total\` is only populated with offset \`paging\`, so for a cursor-paged list count by walking pages or use a count operation.
18514
+ Results: each root field fails independently — \`errors[].path\` names the failing field and \`errors[].extensions.message\` the cause (e.g. PERMISSION_DENIED); \`data\` still holds the fields that succeeded. Mutations return the created/updated entity — read the IDs from it and do not re-query to verify. Large results are truncated: narrow the selection or page size instead of re-running.
18515
+ Set \`hasMutations: true\` for any document containing a mutation root field.
18485
18516
  `,
18486
18517
  CreateWixBusinessGuide: dedent_default`
18487
18518
  Provides comprehensive documentation for creating a new Wix business (site, app, etc.).
@@ -18601,7 +18632,8 @@ function mergeConfig(base, overrides) {
18601
18632
  dynamicContextEnabled: overrides.dynamicContextEnabled ?? base.dynamicContextEnabled,
18602
18633
  partnerContextEnabled: overrides.partnerContextEnabled ?? base.partnerContextEnabled,
18603
18634
  usePlatformizedSearch: overrides.usePlatformizedSearch ?? base.usePlatformizedSearch,
18604
- skillsPrOverrideEnabled: overrides.skillsPrOverrideEnabled ?? base.skillsPrOverrideEnabled
18635
+ skillsPrOverrideEnabled: overrides.skillsPrOverrideEnabled ?? base.skillsPrOverrideEnabled,
18636
+ graphqlEnabled: overrides.graphqlEnabled ?? base.graphqlEnabled
18605
18637
  };
18606
18638
  }
18607
18639
  var defaultConfig = {
@@ -19207,6 +19239,27 @@ var paramDescriptions = {
19207
19239
  mimeType: 'MIME type of the image (e.g. "image/jpeg", "image/png", "image/webp"). Required when imageBase64 does not include a data URL prefix.',
19208
19240
  displayName: "Optional display name for the file in Media Manager. If not provided, uses the original filename."
19209
19241
  },
19242
+ SearchWixGraphQLOperations: {
19243
+ query: 'Free-text intent or entity, e.g. "products with inventory", "create contact", "orders", "blog posts", "booking services". Operation names encode app + service + version + verb/entity (e.g. storesProductsV3V3Products, crmContactsV4CreateContact), so a noun plus a verb (query/get/create/update/delete) ranks best. You may also pass an exact operation name.',
19244
+ kind: 'Restrict to "query" (reads), "mutation" (writes \u2014 note a few reads such as search/list calls are exposed as mutations), or "all" (default).',
19245
+ maxResults: "Maximum number of operations to return (default 10, max 50).",
19246
+ reason: "One sentence describing the original user request and why you are looking for a GraphQL operation."
19247
+ },
19248
+ InspectWixGraphQLSchema: {
19249
+ operation: 'Exact root query or mutation name from SearchWixGraphQLOperations (e.g. "crmContactsV4Contacts"). Returns its arguments, input type and return type as compact SDL, expanded `depth` levels.',
19250
+ typeNames: 'Type names to expand, e.g. ones listed as "Not expanded" in a previous result, or a nested input/object/enum type you need before writing the request. Can be combined with `operation`.',
19251
+ depth: "How many levels of referenced types to expand (1-4, default 2). Level 1 is the given types, level 2 the types their fields reference, and so on. Keep it small and expand specific types with typeNames instead of dumping everything.",
19252
+ reason: "One sentence describing the original user request and why you need this part of the GraphQL schema."
19253
+ },
19254
+ ExecuteWixGraphQL: {
19255
+ query: "The GraphQL document (a query or a mutation). Every root field, argument and selected field MUST come from SearchWixGraphQLOperations / InspectWixGraphQLSchema results in this conversation, never from memory. Declare variables for filters, sort and large inputs, e.g. `query Q($f: JSON) { crmContactsV4Contacts(queryInput: { query: { filter: $f, paging: { limit: 50 } } }) { items { id } pageInfo { hasNext } } }`. Object-typed fields need a selection set. You can put several independent root fields in one document.",
19256
+ variables: 'Variables object for the document, as a JSON object (not a string). Use it for JSON-scalar filters/sort (REST filter syntax, e.g. {"info.name.first": {"$eq": "Ada"}}) and plain scalars. Do NOT pass object inputs that contain enum values (product types, statuses, registration types ...) through variables \u2014 write those inline in the document with the enum unquoted; the endpoint returns 503 otherwise.',
19257
+ operationName: "Operation to run when the document defines more than one named operation.",
19258
+ siteId: "The Wix site to run against. Required for site-level operations (anything reading or writing inside a site \u2014 products, orders, contacts, bookings, CMS, blog, members ...). Resolve it with GetSiteContext or ListWixSites; never pass a guessed value.",
19259
+ scope: '"site" (default when siteId is given) runs with a site-scoped credential; "account" runs account-level operations (sites, account settings) and ignores siteId.',
19260
+ hasMutations: "Whether this document creates, updates, deletes or otherwise mutates Wix data. True for any mutation root field (in any operation of the document) even when the intent is inspection; false only for pure queries. This flag alone decides whether a transient server error may be retried, so never mark a document that writes as false.",
19261
+ reason: "One sentence explaining the original user request and why you are running this GraphQL operation to complete it."
19262
+ },
19210
19263
  RunWixCliCommand: {
19211
19264
  appPath: "The full path to the Wix CLI app to run the command on.",
19212
19265
  extensionType: "The type of extension to generate. You MUST provide this for commands that generate extensions.",
@@ -21196,6 +21249,761 @@ function truncateResponse(content, maxChars = DEFAULT_MAX_CHARS) {
21196
21249
  Response was ~${estimatedTokens.toLocaleString()} tokens (limit: ${limitTokens.toLocaleString()}). Refine your code to return less data.`;
21197
21250
  }
21198
21251
 
21252
+ // src/graphql/constants.ts
21253
+ var WIX_GRAPHQL_ENDPOINT = "https://www.wixapis.com/graphql/alpha";
21254
+ var SEARCH_GRAPHQL_TOOL_NAME = "SearchWixGraphQLOperations";
21255
+ var INSPECT_GRAPHQL_TOOL_NAME = "InspectWixGraphQLSchema";
21256
+ var EXECUTE_GRAPHQL_TOOL_NAME = "ExecuteWixGraphQL";
21257
+ var GRAPHQL_TOOL_NAMES = [
21258
+ SEARCH_GRAPHQL_TOOL_NAME,
21259
+ INSPECT_GRAPHQL_TOOL_NAME,
21260
+ EXECUTE_GRAPHQL_TOOL_NAME
21261
+ ];
21262
+
21263
+ // src/graphql/introspection.ts
21264
+ var TYPE_REF_FRAGMENT = `
21265
+ fragment TR on __Type { kind name ofType { kind name ofType { kind name ofType { kind name } } } }`;
21266
+ var ROOT_OPERATIONS_QUERY = `{
21267
+ __schema {
21268
+ queryType { fields { name description args { name type { ...TR } } type { ...TR } } }
21269
+ mutationType { fields { name description args { name type { ...TR } } type { ...TR } } }
21270
+ }
21271
+ }${TYPE_REF_FRAGMENT}`;
21272
+ var TYPE_DETAILS_FRAGMENT = `
21273
+ fragment TD on __Type {
21274
+ kind name description
21275
+ fields { name description type { ...TR } args { name type { ...TR } } }
21276
+ inputFields { name description type { ...TR } defaultValue }
21277
+ enumValues { name description }
21278
+ possibleTypes { name }
21279
+ }`;
21280
+ var ROOT_CACHE_TTL_MS = 6 * 60 * 60 * 1e3;
21281
+ var rootCache;
21282
+ var typeCache = /* @__PURE__ */ new Map();
21283
+ var RETRY_DELAYS_MS = [800, 2e3, 4e3];
21284
+ var sleep = (ms) => new Promise((r) => setTimeout(r, ms));
21285
+ async function fetchWithRetry(fetchImpl, url, init, delays = RETRY_DELAYS_MS) {
21286
+ let attempt = 0;
21287
+ for (; ; ) {
21288
+ const resp = await fetchImpl(url, init);
21289
+ if (resp.status < 500 || attempt >= delays.length) return resp;
21290
+ await sleep(delays[attempt++]);
21291
+ }
21292
+ }
21293
+ async function postIntrospection(query, options) {
21294
+ const fetchImpl = options.fetchImpl ?? fetch;
21295
+ const endpoint = options.endpoint ?? WIX_GRAPHQL_ENDPOINT;
21296
+ const resp = await fetchWithRetry(
21297
+ fetchImpl,
21298
+ endpoint,
21299
+ {
21300
+ method: "POST",
21301
+ headers: {
21302
+ "Content-Type": "application/json",
21303
+ Accept: "application/json"
21304
+ },
21305
+ body: JSON.stringify({ query })
21306
+ },
21307
+ options.retryDelaysMs
21308
+ );
21309
+ const text = await resp.text();
21310
+ if (!resp.ok) {
21311
+ const body = /^\s*<(!doctype|html)/i.test(text) ? "(HTML error page \u2014 the endpoint is temporarily unavailable; try again in a moment)" : text.slice(0, 500);
21312
+ throw new Error(
21313
+ `GraphQL introspection failed (${resp.status} ${resp.statusText}): ${body}`
21314
+ );
21315
+ }
21316
+ const json = JSON.parse(text);
21317
+ if (json.errors?.length && !json.data) {
21318
+ throw new Error(
21319
+ `GraphQL introspection returned errors: ${JSON.stringify(json.errors).slice(0, 500)}`
21320
+ );
21321
+ }
21322
+ return json.data;
21323
+ }
21324
+ function getRootOperations(options = {}) {
21325
+ const now = Date.now();
21326
+ if (rootCache && now - rootCache.fetchedAt < ROOT_CACHE_TTL_MS) {
21327
+ return rootCache.promise;
21328
+ }
21329
+ const promise = postIntrospection(ROOT_OPERATIONS_QUERY, options).then(
21330
+ (data) => {
21331
+ const toOps = (fields, kind) => (fields ?? []).map((f) => ({
21332
+ kind,
21333
+ name: f.name,
21334
+ description: f.description ?? "",
21335
+ args: f.args ?? [],
21336
+ type: f.type
21337
+ }));
21338
+ return [
21339
+ ...toOps(data?.__schema?.queryType?.fields, "query"),
21340
+ ...toOps(data?.__schema?.mutationType?.fields, "mutation")
21341
+ ];
21342
+ }
21343
+ );
21344
+ promise.catch(() => {
21345
+ if (rootCache?.promise === promise) rootCache = void 0;
21346
+ });
21347
+ rootCache = { promise, fetchedAt: now };
21348
+ return promise;
21349
+ }
21350
+ var GRAPHQL_NAME = /^[_A-Za-z][_0-9A-Za-z]*$/;
21351
+ var TYPE_BATCH_SIZE = 10;
21352
+ async function getTypes(names, options = {}) {
21353
+ const unique = [...new Set(names)].filter((n) => GRAPHQL_NAME.test(n));
21354
+ const missing = unique.filter((n) => !typeCache.has(n));
21355
+ for (let start = 0; start < missing.length; start += TYPE_BATCH_SIZE) {
21356
+ const chunk = missing.slice(start, start + TYPE_BATCH_SIZE);
21357
+ const selections = chunk.map((n, i) => `t${i}: __type(name: "${n}") { ...TD }`).join("\n");
21358
+ const query = `{
21359
+ ${selections}
21360
+ }${TYPE_DETAILS_FRAGMENT}${TYPE_REF_FRAGMENT}`;
21361
+ const batch = postIntrospection(query, options);
21362
+ chunk.forEach((n, i) => {
21363
+ const p = batch.then(
21364
+ (data) => data?.[`t${i}`] ?? null
21365
+ );
21366
+ p.catch(() => {
21367
+ if (typeCache.get(n) === p) typeCache.delete(n);
21368
+ });
21369
+ typeCache.set(n, p);
21370
+ });
21371
+ await batch.catch(() => void 0);
21372
+ }
21373
+ const result = /* @__PURE__ */ new Map();
21374
+ await Promise.all(
21375
+ unique.map(async (n) => {
21376
+ result.set(n, await typeCache.get(n));
21377
+ })
21378
+ );
21379
+ return result;
21380
+ }
21381
+ function renderTypeRef(ref) {
21382
+ if (!ref) return "Unknown";
21383
+ if (ref.kind === "NON_NULL") return `${renderTypeRef(ref.ofType)}!`;
21384
+ if (ref.kind === "LIST") return `[${renderTypeRef(ref.ofType)}]`;
21385
+ return ref.name ?? "Unknown";
21386
+ }
21387
+ function namedType(ref) {
21388
+ let cur = ref;
21389
+ while (cur && (cur.kind === "NON_NULL" || cur.kind === "LIST")) {
21390
+ cur = cur.ofType ?? null;
21391
+ }
21392
+ return cur?.name ?? null;
21393
+ }
21394
+ var BUILTIN_SCALARS = /* @__PURE__ */ new Set([
21395
+ "String",
21396
+ "Int",
21397
+ "Float",
21398
+ "Boolean",
21399
+ "ID",
21400
+ "JSON"
21401
+ ]);
21402
+ function isBuiltinScalar(name) {
21403
+ return !!name && BUILTIN_SCALARS.has(name);
21404
+ }
21405
+ function oneLine(text, max) {
21406
+ if (!text) return "";
21407
+ const flat = text.replace(/\s+/g, " ").trim();
21408
+ return flat.length > max ? `${flat.slice(0, max - 1)}\u2026` : flat;
21409
+ }
21410
+ function renderField(field, isInput) {
21411
+ const args = !isInput && field.args?.length ? `(${field.args.map((a) => `${a.name}: ${renderTypeRef(a.type)}`).join(", ")})` : "";
21412
+ const def = isInput && field.defaultValue != null ? ` = ${field.defaultValue}` : "";
21413
+ const comment = field.description ? ` # ${oneLine(field.description, 140)}` : "";
21414
+ return ` ${field.name}${args}: ${renderTypeRef(field.type)}${def}${comment}`;
21415
+ }
21416
+ function renderType(type) {
21417
+ const references = /* @__PURE__ */ new Set();
21418
+ const collect = (ref) => {
21419
+ const n = namedType(ref);
21420
+ if (n && !isBuiltinScalar(n) && n !== type.name) references.add(n);
21421
+ };
21422
+ const header = type.description ? `# ${oneLine(type.description, 200)}
21423
+ ` : "";
21424
+ let body;
21425
+ switch (type.kind) {
21426
+ case "ENUM":
21427
+ body = `enum ${type.name} {
21428
+ ${(type.enumValues ?? []).map(
21429
+ (v) => ` ${v.name}${v.description ? ` # ${oneLine(v.description, 100)}` : ""}`
21430
+ ).join("\n")}
21431
+ }`;
21432
+ break;
21433
+ case "INPUT_OBJECT":
21434
+ (type.inputFields ?? []).forEach((f) => collect(f.type));
21435
+ body = `input ${type.name} {
21436
+ ${(type.inputFields ?? []).map((f) => renderField(f, true)).join("\n")}
21437
+ }`;
21438
+ break;
21439
+ case "UNION":
21440
+ (type.possibleTypes ?? []).forEach((p) => references.add(p.name));
21441
+ body = `union ${type.name} = ${(type.possibleTypes ?? []).map((p) => p.name).join(" | ")}`;
21442
+ break;
21443
+ case "SCALAR":
21444
+ body = `scalar ${type.name}`;
21445
+ break;
21446
+ default: {
21447
+ (type.fields ?? []).forEach((f) => {
21448
+ collect(f.type);
21449
+ f.args?.forEach((a) => collect(a.type));
21450
+ });
21451
+ const keyword = type.kind === "INTERFACE" ? "interface" : "type";
21452
+ body = `${keyword} ${type.name} {
21453
+ ${(type.fields ?? []).map((f) => renderField(f, false)).join("\n")}
21454
+ }`;
21455
+ }
21456
+ }
21457
+ return { text: header + body, references: [...references] };
21458
+ }
21459
+ function renderOperationSignature(op) {
21460
+ const args = op.args.map((a) => `${a.name}: ${renderTypeRef(a.type)}`).join(", ");
21461
+ return `${op.kind === "query" ? "Query" : "Mutation"}.${op.name}(${args}): ${renderTypeRef(op.type)}`;
21462
+ }
21463
+ async function expandTypes(rootTypeNames, options = {}) {
21464
+ const depth = Math.max(1, Math.min(options.depth ?? 2, 5));
21465
+ const maxTypes = options.maxTypes ?? 40;
21466
+ const rendered = [];
21467
+ const unknown = [];
21468
+ const seen = /* @__PURE__ */ new Set();
21469
+ let frontier = [...new Set(rootTypeNames)].filter((n) => !isBuiltinScalar(n));
21470
+ let level = 1;
21471
+ let overflow = [];
21472
+ while (frontier.length > 0 && level <= depth) {
21473
+ const room = maxTypes - seen.size;
21474
+ if (room <= 0) {
21475
+ overflow = frontier;
21476
+ break;
21477
+ }
21478
+ const batch = frontier.slice(0, room);
21479
+ overflow = frontier.slice(room);
21480
+ batch.forEach((n) => seen.add(n));
21481
+ const types = await getTypes(batch, options);
21482
+ const next = /* @__PURE__ */ new Set();
21483
+ for (const name of batch) {
21484
+ const type = types.get(name);
21485
+ if (!type) {
21486
+ unknown.push(name);
21487
+ continue;
21488
+ }
21489
+ const { text, references } = renderType(type);
21490
+ rendered.push(text);
21491
+ references.forEach((r) => {
21492
+ if (!seen.has(r)) next.add(r);
21493
+ });
21494
+ }
21495
+ frontier = [...next];
21496
+ level++;
21497
+ }
21498
+ const unexpanded = [.../* @__PURE__ */ new Set([...overflow, ...frontier])].filter(
21499
+ (n) => !seen.has(n) && !isBuiltinScalar(n)
21500
+ );
21501
+ return { rendered, unexpanded, unknown };
21502
+ }
21503
+
21504
+ // src/graphql/search.ts
21505
+ function tokenize(text) {
21506
+ return text.replace(/([a-z0-9])([A-Z])/g, "$1 $2").replace(/([A-Z]+)([A-Z][a-z])/g, "$1 $2").replace(/([a-zA-Z])([0-9])/g, "$1 $2").replace(/([0-9])([a-zA-Z])/g, "$1 $2").toLowerCase().split(/[^a-z0-9]+/).filter((t) => t.length > 0);
21507
+ }
21508
+ var STOP_WORDS = /* @__PURE__ */ new Set([
21509
+ "a",
21510
+ "an",
21511
+ "the",
21512
+ "of",
21513
+ "for",
21514
+ "to",
21515
+ "in",
21516
+ "on",
21517
+ "with",
21518
+ "and",
21519
+ "or",
21520
+ "by",
21521
+ "all",
21522
+ "my",
21523
+ "me",
21524
+ "i",
21525
+ "from",
21526
+ "is",
21527
+ "are",
21528
+ "be",
21529
+ "it",
21530
+ "this",
21531
+ "that",
21532
+ "wix",
21533
+ "api",
21534
+ "graphql"
21535
+ ]);
21536
+ function stem(token) {
21537
+ if (token.length > 4 && token.endsWith("ies"))
21538
+ return `${token.slice(0, -3)}y`;
21539
+ if (token.length > 3 && token.endsWith("es") && !token.endsWith("ses"))
21540
+ return token.slice(0, -1);
21541
+ if (token.length > 3 && token.endsWith("s") && !token.endsWith("ss"))
21542
+ return token.slice(0, -1);
21543
+ return token;
21544
+ }
21545
+ var VERB_SYNONYMS = {
21546
+ list: ["query", "list", "search"],
21547
+ find: ["query", "search", "get"],
21548
+ fetch: ["get", "query"],
21549
+ read: ["get", "query"],
21550
+ show: ["get", "query"],
21551
+ count: ["count", "query"],
21552
+ add: ["create", "add"],
21553
+ new: ["create"],
21554
+ insert: ["create"],
21555
+ edit: ["update"],
21556
+ change: ["update"],
21557
+ modify: ["update"],
21558
+ set: ["update"],
21559
+ remove: ["delete", "remove"],
21560
+ destroy: ["delete"],
21561
+ cancel: ["cancel", "delete"],
21562
+ customer: ["contact", "member"],
21563
+ client: ["contact", "member"],
21564
+ item: ["product", "item"],
21565
+ inventory: ["inventory", "stock"],
21566
+ stock: ["inventory", "stock"],
21567
+ post: ["post", "blog"],
21568
+ article: ["post", "blog"],
21569
+ appointment: ["booking", "session"],
21570
+ collection: ["collection", "category", "data"],
21571
+ cms: ["data", "collection"],
21572
+ store: ["stores", "store"]
21573
+ };
21574
+ function expandQueryTokens(tokens) {
21575
+ const out = /* @__PURE__ */ new Set();
21576
+ for (const raw of tokens) {
21577
+ if (STOP_WORDS.has(raw)) continue;
21578
+ const s = stem(raw);
21579
+ out.add(s);
21580
+ for (const syn of VERB_SYNONYMS[raw] ?? VERB_SYNONYMS[s] ?? []) {
21581
+ out.add(stem(syn));
21582
+ }
21583
+ }
21584
+ return out;
21585
+ }
21586
+ var READ_VERBS = /* @__PURE__ */ new Set([
21587
+ "list",
21588
+ "get",
21589
+ "query",
21590
+ "find",
21591
+ "fetch",
21592
+ "read",
21593
+ "show",
21594
+ "retrieve",
21595
+ "search",
21596
+ "count",
21597
+ "view",
21598
+ "see"
21599
+ ]);
21600
+ var WRITE_VERBS = /* @__PURE__ */ new Set([
21601
+ "create",
21602
+ "add",
21603
+ "new",
21604
+ "insert",
21605
+ "update",
21606
+ "edit",
21607
+ "change",
21608
+ "modify",
21609
+ "set",
21610
+ "delete",
21611
+ "remove",
21612
+ "destroy",
21613
+ "cancel",
21614
+ "bulk",
21615
+ "merge",
21616
+ "publish",
21617
+ "send"
21618
+ ]);
21619
+ var isVersionToken = (t) => t === "v" || /^\d+$/.test(t);
21620
+ function stripMarkdown(text) {
21621
+ return text.replace(/\[([^\]]+)\]\([^)]*\)/g, "$1").replace(/[`*_]/g, "");
21622
+ }
21623
+ function firstSentence(text, max = 220) {
21624
+ const flat = stripMarkdown(text).replace(/\s+/g, " ").trim();
21625
+ const cut = flat.search(/(?<=[.!?])\s/);
21626
+ const sentence = cut > 0 ? flat.slice(0, cut) : flat;
21627
+ return sentence.length > max ? `${sentence.slice(0, max - 1)}\u2026` : sentence;
21628
+ }
21629
+ var indexCache = /* @__PURE__ */ new WeakMap();
21630
+ function indexOperations(ops) {
21631
+ let indexed = indexCache.get(ops);
21632
+ if (!indexed) {
21633
+ indexed = ops.map((op) => ({
21634
+ op,
21635
+ nameTokens: new Set(tokenize(op.name).map(stem)),
21636
+ descTokens: new Set(tokenize(op.description.slice(0, 600)).map(stem))
21637
+ }));
21638
+ indexCache.set(ops, indexed);
21639
+ }
21640
+ return indexed;
21641
+ }
21642
+ function searchOperations(ops, query, options = {}) {
21643
+ const { kind = "all", maxResults = 10 } = options;
21644
+ const rawTokens = tokenize(query);
21645
+ const terms = expandQueryTokens(rawTokens);
21646
+ const originalTerms = new Set(
21647
+ rawTokens.filter((t) => !STOP_WORDS.has(t)).map(stem)
21648
+ );
21649
+ const exactName = query.trim();
21650
+ const hasWriteVerb = rawTokens.some((t) => WRITE_VERBS.has(t));
21651
+ const nounTokens = rawTokens.filter(
21652
+ (t) => !STOP_WORDS.has(t) && !READ_VERBS.has(t) && !WRITE_VERBS.has(t)
21653
+ );
21654
+ const pluralIntent = nounTokens.length > 0 && nounTokens.some((t) => stem(t) !== t);
21655
+ const readIntent = !hasWriteVerb;
21656
+ const matches = [];
21657
+ for (const { op, nameTokens, descTokens } of indexOperations(ops)) {
21658
+ if (kind !== "all" && op.kind !== kind) continue;
21659
+ let score = 0;
21660
+ let originalHits = 0;
21661
+ const matchedNameTokens = /* @__PURE__ */ new Set();
21662
+ for (const term of terms) {
21663
+ const isOriginal = originalTerms.has(term);
21664
+ if (op.kind === "query" && readIntent && READ_VERBS.has(term)) {
21665
+ score += isOriginal ? 4 : 2;
21666
+ if (isOriginal) originalHits++;
21667
+ if (nameTokens.has(term)) matchedNameTokens.add(term);
21668
+ continue;
21669
+ }
21670
+ if (nameTokens.has(term)) {
21671
+ matchedNameTokens.add(term);
21672
+ score += isOriginal ? 4 : 2;
21673
+ if (isOriginal) originalHits++;
21674
+ continue;
21675
+ }
21676
+ let prefixHit = false;
21677
+ for (const nt of nameTokens) {
21678
+ if (term.length >= 3 && (nt.startsWith(term) || term.startsWith(nt))) {
21679
+ prefixHit = true;
21680
+ matchedNameTokens.add(nt);
21681
+ break;
21682
+ }
21683
+ }
21684
+ if (prefixHit) {
21685
+ score += isOriginal ? 2 : 1;
21686
+ if (isOriginal) originalHits++;
21687
+ continue;
21688
+ }
21689
+ if (descTokens.has(term)) {
21690
+ score += 1;
21691
+ if (isOriginal) originalHits++;
21692
+ }
21693
+ }
21694
+ if (score <= 0 && op.name !== exactName) continue;
21695
+ if (op.name === exactName) score += 100;
21696
+ if (originalTerms.size > 0 && originalHits === originalTerms.size) {
21697
+ score += 3;
21698
+ }
21699
+ const lastToken = tokenize(op.name).filter((t) => !isVersionToken(t)).pop();
21700
+ if (lastToken && nounTokens.length > 0) {
21701
+ const pluralOp = stem(lastToken) !== lastToken;
21702
+ score += pluralOp === pluralIntent ? 0.5 : -0.5;
21703
+ }
21704
+ if (/DoNotCall/i.test(op.name)) score -= 2;
21705
+ for (const nt of nameTokens) {
21706
+ if (!isVersionToken(nt) && !matchedNameTokens.has(nt)) score -= 0.3;
21707
+ }
21708
+ if (readIntent && op.kind === "mutation" && [...nameTokens].some((t) => WRITE_VERBS.has(t))) {
21709
+ score -= 6;
21710
+ }
21711
+ if (op.kind === "query" && readIntent) score += 1;
21712
+ const version2 = op.name.match(/V(\d+)/);
21713
+ if (version2) score += Math.min(Number(version2[1]), 5) * 0.1;
21714
+ if (!op.description) score -= 0.5;
21715
+ score -= op.name.length / 200;
21716
+ if (score <= 0) continue;
21717
+ matches.push({
21718
+ operation: op.name,
21719
+ kind: op.kind,
21720
+ signature: `${op.name}(${op.args.map((a) => `${a.name}: ${renderTypeRef(a.type)}`).join(", ")}): ${renderTypeRef(op.type)}`,
21721
+ description: firstSentence(op.description),
21722
+ inputType: op.args[0] ? namedType(op.args[0].type) : null,
21723
+ returnType: namedType(op.type),
21724
+ score: Math.round(score * 100) / 100
21725
+ });
21726
+ }
21727
+ matches.sort(
21728
+ (a, b) => b.score - a.score || a.operation.localeCompare(b.operation)
21729
+ );
21730
+ return matches.slice(0, Math.max(1, Math.min(maxResults, 50)));
21731
+ }
21732
+
21733
+ // src/graphql/index.ts
21734
+ var textResult = (text) => ({
21735
+ content: [{ type: "text", text }]
21736
+ });
21737
+ var errorResult = (text) => ({
21738
+ isError: true,
21739
+ content: [{ type: "text", text }]
21740
+ });
21741
+ var SCHEMA_MAX_RESPONSE_CHARS = 48e3;
21742
+ function addGraphqlTools(server, options = {}) {
21743
+ const { authStrategy, disableTools = [], toolDescriptions } = options;
21744
+ const getDescription = (name) => toolDescriptions?.[name] ?? defaultToolDescriptions[name];
21745
+ if (!disableTools.includes(SEARCH_GRAPHQL_TOOL_NAME)) {
21746
+ addSearchGraphqlTool(
21747
+ server,
21748
+ getDescription(SEARCH_GRAPHQL_TOOL_NAME),
21749
+ options
21750
+ );
21751
+ }
21752
+ if (!disableTools.includes(INSPECT_GRAPHQL_TOOL_NAME)) {
21753
+ addInspectGraphqlTool(
21754
+ server,
21755
+ getDescription(INSPECT_GRAPHQL_TOOL_NAME),
21756
+ options
21757
+ );
21758
+ }
21759
+ if (authStrategy && !disableTools.includes(EXECUTE_GRAPHQL_TOOL_NAME)) {
21760
+ addExecuteGraphqlTool(
21761
+ server,
21762
+ getDescription(EXECUTE_GRAPHQL_TOOL_NAME),
21763
+ authStrategy,
21764
+ options
21765
+ );
21766
+ }
21767
+ }
21768
+ function introspectionOptions(options) {
21769
+ return {
21770
+ endpoint: options.endpoint,
21771
+ fetchImpl: options.fetchImpl,
21772
+ retryDelaysMs: options.retryDelaysMs
21773
+ };
21774
+ }
21775
+ function addSearchGraphqlTool(server, description, options) {
21776
+ const d = desc("SearchWixGraphQLOperations");
21777
+ server.tool(
21778
+ SEARCH_GRAPHQL_TOOL_NAME,
21779
+ description,
21780
+ {
21781
+ query: external_exports.string().describe(d.query),
21782
+ kind: external_exports.enum(["query", "mutation", "all"]).optional().describe(d.kind),
21783
+ maxResults: external_exports.number().int().min(1).max(50).optional().describe(d.maxResults),
21784
+ reason: external_exports.string().describe(d.reason)
21785
+ },
21786
+ { readOnlyHint: true, destructiveHint: false, openWorldHint: false },
21787
+ async ({ query, kind, maxResults, reason }) => {
21788
+ logger.log(
21789
+ `[${SEARCH_GRAPHQL_TOOL_NAME}] query="${query}" kind=${kind ?? "all"} reason="${reason}"`
21790
+ );
21791
+ try {
21792
+ const ops = await getRootOperations(introspectionOptions(options));
21793
+ const matches = searchOperations(ops, query, {
21794
+ kind: kind ?? "all",
21795
+ maxResults: maxResults ?? 10
21796
+ });
21797
+ if (matches.length === 0) {
21798
+ return textResult(
21799
+ `No GraphQL operations matched "${query}". Try other words for the entity (e.g. "contact" instead of "customer", "product" instead of "item") or the verb (query/get/create/update/delete), or search a single noun.`
21800
+ );
21801
+ }
21802
+ const lines = matches.map(
21803
+ (m, i) => `${i + 1}. ${m.kind} ${m.signature}
21804
+ ${m.description || "(no description)"}`
21805
+ );
21806
+ const text = [
21807
+ `Top ${matches.length} of ${ops.length} Wix GraphQL root operations for "${query}":`,
21808
+ "",
21809
+ ...lines,
21810
+ "",
21811
+ `Next: call ${INSPECT_GRAPHQL_TOOL_NAME} with \`operation\` set to the chosen name to read its exact input type and return type before writing the request.`
21812
+ ].join("\n");
21813
+ return textResult(text);
21814
+ } catch (err) {
21815
+ const message = err instanceof Error ? err.message : String(err);
21816
+ logger.log(`[${SEARCH_GRAPHQL_TOOL_NAME}] Error: ${message}`);
21817
+ return errorResult(`GraphQL schema search error: ${message}`);
21818
+ }
21819
+ }
21820
+ );
21821
+ }
21822
+ function addInspectGraphqlTool(server, description, options) {
21823
+ const d = desc("InspectWixGraphQLSchema");
21824
+ const maxChars = options.maxResponseSize ?? SCHEMA_MAX_RESPONSE_CHARS;
21825
+ server.tool(
21826
+ INSPECT_GRAPHQL_TOOL_NAME,
21827
+ description,
21828
+ {
21829
+ operation: external_exports.string().optional().describe(d.operation),
21830
+ typeNames: external_exports.array(external_exports.string()).optional().describe(d.typeNames),
21831
+ depth: external_exports.number().int().min(1).max(4).optional().describe(d.depth),
21832
+ reason: external_exports.string().describe(d.reason)
21833
+ },
21834
+ { readOnlyHint: true, destructiveHint: false, openWorldHint: false },
21835
+ async ({ operation, typeNames, depth, reason }) => {
21836
+ logger.log(
21837
+ `[${INSPECT_GRAPHQL_TOOL_NAME}] operation=${operation ?? "-"} typeNames=${JSON.stringify(typeNames ?? [])} depth=${depth ?? 2} reason="${reason}"`
21838
+ );
21839
+ if (!operation && !(typeNames && typeNames.length > 0)) {
21840
+ return errorResult(
21841
+ "Pass `operation` (a root query/mutation name from SearchWixGraphQLOperations) and/or `typeNames` (type names to expand)."
21842
+ );
21843
+ }
21844
+ try {
21845
+ const io = introspectionOptions(options);
21846
+ const sections = [];
21847
+ const roots = [];
21848
+ if (operation) {
21849
+ const ops = await getRootOperations(io);
21850
+ const op = ops.find((o) => o.name === operation);
21851
+ if (!op) {
21852
+ const suggestions = searchOperations(ops, operation, {
21853
+ maxResults: 5
21854
+ });
21855
+ return errorResult(
21856
+ `No root operation named "${operation}". ${suggestions.length ? `Did you mean: ${suggestions.map((s) => `${s.kind} ${s.operation}`).join(", ")}? Use SearchWixGraphQLOperations to discover the exact name.` : "Use SearchWixGraphQLOperations to discover the exact name."}`
21857
+ );
21858
+ }
21859
+ sections.push(
21860
+ `# ${renderOperationSignature(op)}`,
21861
+ op.description ? op.description.trim().split("\n").map((l) => `# ${l}`).join("\n") : "# (no description)"
21862
+ );
21863
+ op.args.forEach((a) => {
21864
+ const n = namedType(a.type);
21865
+ if (n) roots.push(n);
21866
+ });
21867
+ const ret = namedType(op.type);
21868
+ if (ret) roots.push(ret);
21869
+ }
21870
+ if (typeNames?.length) roots.push(...typeNames);
21871
+ const { rendered, unexpanded, unknown } = await expandTypes(roots, {
21872
+ ...io,
21873
+ depth: depth ?? 2
21874
+ });
21875
+ sections.push(...rendered);
21876
+ if (unknown.length) {
21877
+ sections.push(
21878
+ `# Unknown type names (not in the schema): ${unknown.join(", ")}`
21879
+ );
21880
+ }
21881
+ if (unexpanded.length) {
21882
+ sections.push(
21883
+ `# Not expanded (pass any of these in \`typeNames\` to read them): ${unexpanded.join(", ")}`
21884
+ );
21885
+ }
21886
+ sections.push(
21887
+ "# Notes: `JSON` scalar fields (filter, sort, free-form data) take any JSON \u2014 pass them as variables. Every object-typed field in a selection needs its own { ... } selection set. Only fields listed above exist. Paging: use exactly the paging style the input type declares \u2014 `paging` (offset) or `cursorPaging` (cursor) \u2014 never the other one. `pageInfo.total` is only populated with offset paging; with cursor paging, count by walking pages (`pageInfo.hasNext` + cursor) or use a dedicated count operation if one exists."
21888
+ );
21889
+ return textResult(truncateResponse(sections.join("\n\n"), maxChars));
21890
+ } catch (err) {
21891
+ const message = err instanceof Error ? err.message : String(err);
21892
+ logger.log(`[${INSPECT_GRAPHQL_TOOL_NAME}] Error: ${message}`);
21893
+ return errorResult(`GraphQL schema inspection error: ${message}`);
21894
+ }
21895
+ }
21896
+ );
21897
+ }
21898
+ function addExecuteGraphqlTool(server, description, authStrategy, options) {
21899
+ const d = desc("ExecuteWixGraphQL");
21900
+ const endpoint = options.endpoint ?? WIX_GRAPHQL_ENDPOINT;
21901
+ const fetchImpl = options.fetchImpl ?? fetch;
21902
+ server.tool(
21903
+ EXECUTE_GRAPHQL_TOOL_NAME,
21904
+ description,
21905
+ {
21906
+ query: external_exports.string().describe(d.query),
21907
+ variables: external_exports.record(external_exports.unknown()).optional().describe(d.variables),
21908
+ operationName: external_exports.string().optional().describe(d.operationName),
21909
+ siteId: external_exports.string().optional().describe(d.siteId),
21910
+ scope: external_exports.enum(["site", "account"]).optional().describe(d.scope),
21911
+ hasMutations: external_exports.boolean().describe(d.hasMutations),
21912
+ reason: external_exports.string().describe(d.reason)
21913
+ },
21914
+ { readOnlyHint: false, destructiveHint: true, openWorldHint: false },
21915
+ async ({ query, variables, operationName, siteId, scope, hasMutations, reason }, extra) => {
21916
+ const effectiveScope = scope ?? (siteId ? "site" : "account");
21917
+ logger.log(
21918
+ `[${EXECUTE_GRAPHQL_TOOL_NAME}] scope=${effectiveScope} siteId=${siteId ?? "none"} hasMutations=${hasMutations} operationName=${operationName ?? "-"} reason="${reason}"`
21919
+ );
21920
+ if (effectiveScope === "site" && !siteId) {
21921
+ return errorResult(
21922
+ 'A `siteId` is required for site-level GraphQL operations (anything that reads or writes inside a site). Resolve it with GetSiteContext or ListWixSites, or set scope: "account" for account-level operations.'
21923
+ );
21924
+ }
21925
+ if (!query.trim()) {
21926
+ return errorResult("`query` must be a non-empty GraphQL document.");
21927
+ }
21928
+ const authHeaders = effectiveScope === "site" ? await authStrategy.getSiteAuthHeaders(siteId) : await authStrategy.getAccountAuthHeaders();
21929
+ try {
21930
+ const init = {
21931
+ method: "POST",
21932
+ headers: {
21933
+ "Content-Type": "application/json",
21934
+ Accept: "application/json",
21935
+ ...authHeaders
21936
+ },
21937
+ body: JSON.stringify({
21938
+ query,
21939
+ ...variables ? { variables } : {},
21940
+ ...operationName ? { operationName } : {}
21941
+ })
21942
+ };
21943
+ const resp = hasMutations ? await fetchImpl(endpoint, init) : await fetchWithRetry(
21944
+ fetchImpl,
21945
+ endpoint,
21946
+ init,
21947
+ options.retryDelaysMs
21948
+ );
21949
+ const requestId = resp.headers?.get("x-wix-request-id") ?? void 0;
21950
+ extra?.setToolBiParams?.({ siteId, requestId });
21951
+ const text = await resp.text();
21952
+ if (!resp.ok) {
21953
+ await authStrategy.enforceValidWixToken?.({
21954
+ status: resp.status,
21955
+ response: { status: resp.status }
21956
+ });
21957
+ const body2 = /^\s*<(!doctype|html)/i.test(text) ? "(HTML error page)" : text.slice(0, 2e3);
21958
+ const hasObjectVariables = !!variables && Object.values(variables).some(
21959
+ (v) => v !== null && typeof v === "object"
21960
+ );
21961
+ const hint = resp.status >= 500 ? hasObjectVariables ? ` The Wix GraphQL endpoint (Developer Preview) returns 503 when an object-typed variable carries an enum value. Rewrite the document with the input INLINE as a GraphQL literal (enum values unquoted, e.g. productType: PHYSICAL), keep variables only for JSON scalars and plain scalars, and retry once. If it still fails and REST tools (ExecuteWixAPI / CallWixSiteAPI) are available, use the equivalent REST method.` : ` The Wix GraphQL endpoint (Developer Preview) failed for this operation. Do not retry the same document more than once. If REST tools (ExecuteWixAPI / CallWixSiteAPI) are available, complete the task through the equivalent REST method instead; otherwise report the failure with the request id.` : "";
21962
+ return errorResult(
21963
+ `Wix GraphQL request failed: ${resp.status} ${resp.statusText}.${requestId ? ` request id: ${requestId}.` : ""}${hint}
21964
+ ${body2}`
21965
+ );
21966
+ }
21967
+ let json;
21968
+ try {
21969
+ json = JSON.parse(text);
21970
+ } catch {
21971
+ return errorResult(
21972
+ `Wix GraphQL returned a non-JSON body:
21973
+ ${text.slice(0, 2e3)}`
21974
+ );
21975
+ }
21976
+ const hasData = json.data != null && Object.values(json.data).some((v) => v !== null && v !== void 0);
21977
+ const errors = json.errors ?? [];
21978
+ if (!hasData && errors.length > 0) {
21979
+ const permissionDenied = errors.some(
21980
+ (e) => e.extensions?.message === "PERMISSION_DENIED"
21981
+ );
21982
+ return errorResult(
21983
+ [
21984
+ `Wix GraphQL returned errors and no data${requestId ? ` (request id: ${requestId})` : ""}:`,
21985
+ JSON.stringify(errors, null, 2).slice(0, 4e3),
21986
+ permissionDenied ? "PERMISSION_DENIED usually means the operation is site-level and was called without the right `siteId`, the app behind it is not installed on the site, or the credential lacks that permission scope." : 'Validation errors ("Cannot query field ...", "Unknown argument ...") mean a name was guessed \u2014 re-read the exact fields with InspectWixGraphQLSchema and retry.'
21987
+ ].join("\n")
21988
+ );
21989
+ }
21990
+ const body = { data: json.data };
21991
+ if (errors.length > 0) {
21992
+ body.errors = errors;
21993
+ body.note = "Partial result: some root fields failed (see errors[].path). Fields present in data succeeded.";
21994
+ }
21995
+ return textResult(truncateResponse(body, options.maxResponseSize));
21996
+ } catch (err) {
21997
+ rethrowIfUnauthorized(err);
21998
+ await authStrategy.enforceValidWixToken?.(err);
21999
+ const message = err instanceof Error ? err.message : String(err);
22000
+ logger.log(`[${EXECUTE_GRAPHQL_TOOL_NAME}] Error: ${message}`);
22001
+ return errorResult(`Wix GraphQL execution error: ${message}`);
22002
+ }
22003
+ }
22004
+ );
22005
+ }
22006
+
21199
22007
  // src/code-mode/validation.ts
21200
22008
  var EXECUTE_FUNCTION_EXPRESSION_HINT = 'ExecuteWixAPI code must be a function expression, not a script body. Pass code like: async () => { const response = await wix.request({ scope: "site", method: "GET", url: "https://www.wixapis.com/..." }); return response.data; }. Do not write top-level const/await/return outside the function and do not invoke the function yourself.';
21201
22009
  function validateExecuteCode(code) {
@@ -21764,6 +22572,20 @@ function createWixToolkit(options) {
21764
22572
  maxResponseSize
21765
22573
  });
21766
22574
  }
22575
+ const requestedGraphqlTools = GRAPHQL_TOOL_NAMES.filter(
22576
+ (name) => requestedTools.has(name)
22577
+ );
22578
+ if (requestedGraphqlTools.length > 0) {
22579
+ addGraphqlTools(server, {
22580
+ authStrategy,
22581
+ disableTools: [
22582
+ ...disableTools ?? [],
22583
+ ...GRAPHQL_TOOL_NAMES.filter((n) => !requestedTools.has(n))
22584
+ ],
22585
+ toolDescriptions: effectiveToolDescriptions,
22586
+ maxResponseSize
22587
+ });
22588
+ }
21767
22589
  } else {
21768
22590
  addApiCallTool(
21769
22591
  server,
@@ -21946,10 +22768,15 @@ function createWixToolkit(options) {
21946
22768
  // Annotate the CommonJS export names for ESM import in node:
21947
22769
  0 && (module.exports = {
21948
22770
  EXECUTE_FUNCTION_EXPRESSION_HINT,
22771
+ EXECUTE_GRAPHQL_TOOL_NAME,
22772
+ GRAPHQL_TOOL_NAMES,
22773
+ INSPECT_GRAPHQL_TOOL_NAME,
21949
22774
  RECIPES_INDEX_URL,
22775
+ SEARCH_GRAPHQL_TOOL_NAME,
21950
22776
  SYSTEM_REMINDER,
21951
22777
  SYSTEM_REMINDER_GUIDELINES,
21952
22778
  UNAUTHORIZED_ERROR_NAME,
22779
+ WIX_GRAPHQL_ENDPOINT,
21953
22780
  WixFetchError,
21954
22781
  attachConsoleLogger,
21955
22782
  createWixToolkit,