@wix/mcp 1.0.81 → 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.
- package/README.md +3 -1
- package/build/bin-standalone.js +847 -4
- package/build/cjs/index.cjs +900 -20
- package/build/cjs/toolkit.cjs +844 -4
- package/build/dts/bin.d.ts +1 -1
- package/build/dts/bin.js +13 -1
- package/build/dts/config/default-config.d.ts +1 -0
- package/build/dts/config/default-config.js +33 -2
- package/build/dts/config/param-descriptions.d.ts +21 -0
- package/build/dts/config/param-descriptions.js +21 -0
- package/build/dts/graphql/constants.d.ts +8 -0
- package/build/dts/graphql/constants.js +11 -0
- package/build/dts/graphql/index.d.ts +30 -0
- package/build/dts/graphql/index.js +259 -0
- package/build/dts/graphql/introspection.d.ts +106 -0
- package/build/dts/graphql/introspection.js +282 -0
- package/build/dts/graphql/search.d.ts +25 -0
- package/build/dts/graphql/search.js +277 -0
- package/build/dts/import-claude-design-tool/index.js +2 -2
- package/build/dts/index.d.ts +2 -1
- package/build/dts/index.js +3 -1
- package/build/dts/site-widget-tools/constants.d.ts +12 -5
- package/build/dts/site-widget-tools/constants.js +20 -11
- package/build/dts/site-widget-tools/site-builder-tool/index.js +1 -1
- package/build/dts/site-widget-tools/site-creation-tool/index.js +3 -2
- package/build/dts/site-widget-tools/suggested-domain-tool/index.js +25 -5
- package/build/dts/toolkit-entry.d.cts +12 -0
- package/build/dts/toolkit-entry.d.ts +12 -0
- package/build/dts/toolkit-entry.js +4 -0
- package/build/dts/toolkit.js +14 -0
- package/build/dts/wix-mcp-server.d.ts +2 -0
- package/build/dts/wix-mcp-server.js +5 -0
- package/build/esm/index.js +892 -20
- package/build/esm/toolkit.js +839 -4
- package/package.json +2 -2
package/build/esm/index.js
CHANGED
|
@@ -29818,6 +29818,11 @@ var WixMcpServer = class extends McpServer {
|
|
|
29818
29818
|
isMcpAppsInMcpEnabled() {
|
|
29819
29819
|
return this.mcpAppsInMcpEnabled;
|
|
29820
29820
|
}
|
|
29821
|
+
/** Microsoft 365 Copilot ("sydney" at runtime) or Copilot Cowork ("copilot"). */
|
|
29822
|
+
isMicrosoftCopilotClient() {
|
|
29823
|
+
const clientName = this.getClientName?.()?.toLowerCase() ?? "";
|
|
29824
|
+
return clientName.includes("sydney") || clientName.includes("copilot");
|
|
29825
|
+
}
|
|
29821
29826
|
shouldRenderMcpApps() {
|
|
29822
29827
|
const clientName = this.getClientName?.()?.toLowerCase();
|
|
29823
29828
|
const isOpenAi = clientName?.includes("openai") ?? false;
|
|
@@ -30942,6 +30947,8 @@ var SITE_CREATION_COPY = {
|
|
|
30942
30947
|
var SITE_GUIDANCE = dedent_default`
|
|
30943
30948
|
A new-site request has two things to settle: what the site is for, and how to build it. The how is AI generation vs. starting from a template, so naming templates, a template id or Wix Studio (Wix Studio is also the template side) already settles it.
|
|
30944
30949
|
|
|
30950
|
+
One case skips all of this: the user ALREADY HAS the finished site as files — hand-written HTML/CSS/JS, a zip, or the export of an AI builder. There is nothing to build, so don't offer AI or templates and don't call any site-creation tool. Send them to https://www.wix.com/headless/drop?utm_campaign=mcp — they drag the files in and get a live Wix-hosted site. Give that URL exactly as written, keeping the utm_campaign=mcp parameter.
|
|
30951
|
+
|
|
30945
30952
|
Settle what the site is for first: its purpose, topic, business type, audience, or main visitor action. Naming a method is not a description of the site, and neither is the business or industry on its own.
|
|
30946
30953
|
If you can't tell yet, ask the preferred question below and nothing else — one question, no creation-method question in the same reply, and no internal tool names.
|
|
30947
30954
|
Once the purpose is clear, unless the user already named a method, ${SITE_CREATION_COPY.unstatedMethod.nonWidget}. A method they named is settled — never re-open it. Never default to AI or to templates, and never ask the user to choose between Harmony and Wix Studio; infer that from their words.
|
|
@@ -31274,7 +31281,8 @@ function buildToolDescriptions(includeReadme, includeImageUploadGuidance = true)
|
|
|
31274
31281
|
After calling, you MUST speak the message provided in the tool result to the user as your reply — do not stay silent and do not replace it with a one-line pointer to the widget. Write out ALL of it, word for word: its opening line (the "Ready to set up your … site?" question INCLUDING "Choose your path in the widget above:"), BOTH of its option bullets, and its "Next up:" line, each on its own line and in that order. Do not summarize, shorten, drop any line, invent your own opener, rename the options, or add an intro or outro.
|
|
31275
31282
|
`,
|
|
31276
31283
|
"import-claude-design-from-url": dedent_default`
|
|
31277
|
-
Import a design into Wix
|
|
31284
|
+
Import a design created in Claude's design tool into Wix. Takes the signed claudeusercontent.com URL Claude Design produces for its self-contained HTML bundle (all images, fonts, and styles inlined); any other host is rejected. Creates a live Wix-hosted site and returns its URL.
|
|
31285
|
+
NOT for site files the user provides themselves (their own HTML/CSS/JS, a zip, another builder's export) — for those, don't call this tool: send the user to https://www.wix.com/headless/drop?utm_campaign=mcp, where they upload the files and get a live hosted site. Give that URL exactly as written, keeping the utm_campaign=mcp parameter.
|
|
31278
31286
|
`,
|
|
31279
31287
|
RunWixCliCommand: dedent_default`
|
|
31280
31288
|
Executes Wix CLI commands for Wix app development and management.
|
|
@@ -31671,10 +31679,37 @@ function buildToolDescriptions(includeReadme, includeImageUploadGuidance = true)
|
|
|
31671
31679
|
|
|
31672
31680
|
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\`.
|
|
31673
31681
|
|
|
31682
|
+
`,
|
|
31683
|
+
SearchWixGraphQLOperations: dedent_default`
|
|
31684
|
+
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\`.
|
|
31685
|
+
|
|
31686
|
+
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.
|
|
31687
|
+
|
|
31688
|
+
When to prefer GraphQL over the REST tools:
|
|
31689
|
+
- 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.
|
|
31690
|
+
- Picking exactly the fields you need, so responses stay small.
|
|
31691
|
+
- Answering "how many / list / show" questions: a query root plus \`pageInfo\` (\`hasNext\`, and \`total\` where the API provides it).
|
|
31692
|
+
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.
|
|
31693
|
+
|
|
31694
|
+
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.
|
|
31695
|
+
Results list \`kind name(arg: InputType): ReturnType\` plus a one-line description; pass the chosen name to InspectWixGraphQLSchema next.
|
|
31696
|
+
`,
|
|
31697
|
+
InspectWixGraphQLSchema: dedent_default`
|
|
31698
|
+
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.
|
|
31699
|
+
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.
|
|
31700
|
+
`,
|
|
31701
|
+
ExecuteWixGraphQL: dedent_default`
|
|
31702
|
+
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.
|
|
31703
|
+
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.
|
|
31704
|
+
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.
|
|
31705
|
+
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.
|
|
31706
|
+
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.
|
|
31707
|
+
Set \`hasMutations: true\` for any document containing a mutation root field.
|
|
31674
31708
|
`,
|
|
31675
31709
|
CreateWixBusinessGuide: dedent_default`
|
|
31676
31710
|
Provides comprehensive documentation for creating a new Wix business (site, app, etc.).
|
|
31677
31711
|
Call this ONLY when the user explicitly asks for a headless site, a Wix Classic Editor site, or manual/advanced account/API-based site creation — these don't need the site's purpose first. For normal site-creation ${SITE_CREATION_COPY.normalCreationRoute.nonWidget}; for a specific template id, call \`CreateSiteFromTemplate\`.
|
|
31712
|
+
Exception, even when the user says "headless": if they ALREADY HAVE the finished site as files (their own HTML/CSS/JS, a zip, an AI-builder export) and want those files hosted, don't call this tool — send them to https://www.wix.com/headless/drop?utm_campaign=mcp to upload the files and get a live hosted site (give that URL exactly, keeping the utm_campaign=mcp parameter). This guide's CLI flow is for BUILDING a headless frontend, not for hosting ready-made files.
|
|
31678
31713
|
|
|
31679
31714
|
## What This Tool Contains
|
|
31680
31715
|
|
|
@@ -31789,7 +31824,8 @@ function mergeConfig(base, overrides) {
|
|
|
31789
31824
|
dynamicContextEnabled: overrides.dynamicContextEnabled ?? base.dynamicContextEnabled,
|
|
31790
31825
|
partnerContextEnabled: overrides.partnerContextEnabled ?? base.partnerContextEnabled,
|
|
31791
31826
|
usePlatformizedSearch: overrides.usePlatformizedSearch ?? base.usePlatformizedSearch,
|
|
31792
|
-
skillsPrOverrideEnabled: overrides.skillsPrOverrideEnabled ?? base.skillsPrOverrideEnabled
|
|
31827
|
+
skillsPrOverrideEnabled: overrides.skillsPrOverrideEnabled ?? base.skillsPrOverrideEnabled,
|
|
31828
|
+
graphqlEnabled: overrides.graphqlEnabled ?? base.graphqlEnabled
|
|
31793
31829
|
};
|
|
31794
31830
|
}
|
|
31795
31831
|
var defaultConfig = {
|
|
@@ -32140,7 +32176,16 @@ var known_apps_default = {
|
|
|
32140
32176
|
"1480c568-5cbd-9392-5604-1148f5faffa0": "Promote SEO",
|
|
32141
32177
|
"ff5d6eb1-65e4-4f9a-8b14-64d34c12cc2e": "Wix Rentals"
|
|
32142
32178
|
};
|
|
32143
|
-
var
|
|
32179
|
+
var DYNAMIC_CONTEXT_PATH = "/_api/dynamic-context/v1/dynamic-context";
|
|
32180
|
+
var DYNAMIC_CONTEXT_URL = `https://dev.wix.com${DYNAMIC_CONTEXT_PATH}`;
|
|
32181
|
+
var isWixHost = (hostname2) => hostname2 === "wix.com" || hostname2.endsWith(".wix.com");
|
|
32182
|
+
var dynamicContextUrl = () => {
|
|
32183
|
+
if (typeof window === "undefined") {
|
|
32184
|
+
return DYNAMIC_CONTEXT_URL;
|
|
32185
|
+
}
|
|
32186
|
+
const hostname2 = window.location?.hostname;
|
|
32187
|
+
return typeof hostname2 === "string" && isWixHost(hostname2) ? DYNAMIC_CONTEXT_PATH : DYNAMIC_CONTEXT_URL;
|
|
32188
|
+
};
|
|
32144
32189
|
var COUNT_SITES_URL = "https://www.wixapis.com/site-list/v2/sites/count";
|
|
32145
32190
|
var MAX_SITES_FOR_DYNAMIC_CONTEXT = 10;
|
|
32146
32191
|
var DYNAMIC_CONTEXT_PETRI_OVERRIDE = "shouldReturnDynamicContextInMCP#B";
|
|
@@ -32192,7 +32237,7 @@ async function getDynamicContext(auth, httpClient6, filter, options) {
|
|
|
32192
32237
|
if (filter?.siteId) body.site_id = filter.siteId;
|
|
32193
32238
|
else if (filter?.siteName) body.site_name = filter.siteName;
|
|
32194
32239
|
const dynamicContextPromise = httpClient6.request({
|
|
32195
|
-
url:
|
|
32240
|
+
url: dynamicContextUrl(),
|
|
32196
32241
|
method: "POST",
|
|
32197
32242
|
headers: {
|
|
32198
32243
|
...accountHeaders,
|
|
@@ -32386,6 +32431,27 @@ var paramDescriptions = {
|
|
|
32386
32431
|
mimeType: 'MIME type of the image (e.g. "image/jpeg", "image/png", "image/webp"). Required when imageBase64 does not include a data URL prefix.',
|
|
32387
32432
|
displayName: "Optional display name for the file in Media Manager. If not provided, uses the original filename."
|
|
32388
32433
|
},
|
|
32434
|
+
SearchWixGraphQLOperations: {
|
|
32435
|
+
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.',
|
|
32436
|
+
kind: 'Restrict to "query" (reads), "mutation" (writes \u2014 note a few reads such as search/list calls are exposed as mutations), or "all" (default).',
|
|
32437
|
+
maxResults: "Maximum number of operations to return (default 10, max 50).",
|
|
32438
|
+
reason: "One sentence describing the original user request and why you are looking for a GraphQL operation."
|
|
32439
|
+
},
|
|
32440
|
+
InspectWixGraphQLSchema: {
|
|
32441
|
+
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.',
|
|
32442
|
+
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`.',
|
|
32443
|
+
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.",
|
|
32444
|
+
reason: "One sentence describing the original user request and why you need this part of the GraphQL schema."
|
|
32445
|
+
},
|
|
32446
|
+
ExecuteWixGraphQL: {
|
|
32447
|
+
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.",
|
|
32448
|
+
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.',
|
|
32449
|
+
operationName: "Operation to run when the document defines more than one named operation.",
|
|
32450
|
+
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.",
|
|
32451
|
+
scope: '"site" (default when siteId is given) runs with a site-scoped credential; "account" runs account-level operations (sites, account settings) and ignores siteId.',
|
|
32452
|
+
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.",
|
|
32453
|
+
reason: "One sentence explaining the original user request and why you are running this GraphQL operation to complete it."
|
|
32454
|
+
},
|
|
32389
32455
|
RunWixCliCommand: {
|
|
32390
32456
|
appPath: "The full path to the Wix CLI app to run the command on.",
|
|
32391
32457
|
extensionType: "The type of extension to generate. You MUST provide this for commands that generate extensions.",
|
|
@@ -34643,9 +34709,18 @@ var SITE_CREATION_CUSTOM_ACTIONS_GUIDANCE = `2\u20133 specific, high-value setup
|
|
|
34643
34709
|
* Events / Weddings / Real Estate: "add event schedules, display listings, and manage RSVP forms"
|
|
34644
34710
|
* General / Unspecified: "${SITE_CREATION_DEFAULT_ACTIONS}"
|
|
34645
34711
|
If none of these patterns fit the site, infer 2\u20133 actions that suit what that kind of business would manage on its site.`;
|
|
34646
|
-
function buildSiteCreationSelectorMessage(siteType, customActions) {
|
|
34712
|
+
function buildSiteCreationSelectorMessage(siteType, customActions, { plain = false } = {}) {
|
|
34647
34713
|
const type = (siteType ?? "").trim() || "new";
|
|
34648
34714
|
const actions = (customActions ?? "").trim() || SITE_CREATION_DEFAULT_ACTIONS;
|
|
34715
|
+
const body = `Ready to set up your ${type} site? Choose your path in the widget above:
|
|
34716
|
+
|
|
34717
|
+
* **Build with AI** for a custom, tailor-made layout
|
|
34718
|
+
* **Pick a template** to start with a pre-designed layout
|
|
34719
|
+
|
|
34720
|
+
**Next up:** Once your site is created, you can customize it in Wix or ask me to ${actions}\u2014right here in the chat!`;
|
|
34721
|
+
if (plain) {
|
|
34722
|
+
return body;
|
|
34723
|
+
}
|
|
34649
34724
|
return `You are the assistant replying to the user \u2014 say this message out loud in chat (do NOT stay silent, and do NOT just point at the widget). Your reply is only complete if it includes ALL of the following, word for word, each on its own line and in this order:
|
|
34650
34725
|
1. "Ready to set up your ${type} site? Choose your path in the widget above:" \u2014 keep the "Choose your path in the widget above:" part.
|
|
34651
34726
|
2. "* **Build with AI** for a custom, tailor-made layout"
|
|
@@ -34654,12 +34729,7 @@ function buildSiteCreationSelectorMessage(siteType, customActions) {
|
|
|
34654
34729
|
|
|
34655
34730
|
Copy those four lines as written; do not summarize, shorten, reorder, or reword any of them. Here is the full message to send:
|
|
34656
34731
|
|
|
34657
|
-
|
|
34658
|
-
|
|
34659
|
-
* **Build with AI** for a custom, tailor-made layout
|
|
34660
|
-
* **Pick a template** to start with a pre-designed layout
|
|
34661
|
-
|
|
34662
|
-
**Next up:** Once your site is created, you can customize it in Wix or ask me to ${actions}\u2014right here in the chat!`;
|
|
34732
|
+
${body}`;
|
|
34663
34733
|
}
|
|
34664
34734
|
var OPENAI_WIDGET_MIME_TYPE = "text/html+skybridge";
|
|
34665
34735
|
var SITE_WIDGET_MCP_CSP = {
|
|
@@ -41614,7 +41684,7 @@ function addCreateSiteWidgetTool(server, authStrategy, options) {
|
|
|
41614
41684
|
`The prompt to build the site. If not provided, the user will be asked to provide a prompt.`
|
|
41615
41685
|
),
|
|
41616
41686
|
suggestedSiteName: external_exports.string().optional().describe(
|
|
41617
|
-
"
|
|
41687
|
+
"You must provide this on every call, including updates to an existing job, in English. A short name for the site: the business name the user gave, or one you derive from the site prompt."
|
|
41618
41688
|
)
|
|
41619
41689
|
},
|
|
41620
41690
|
_meta: toolDefinitionMeta,
|
|
@@ -41771,6 +41841,11 @@ async function buildHarmonySite({
|
|
|
41771
41841
|
|
|
41772
41842
|
// src/site-widget-tools/suggested-domain-tool/index.ts
|
|
41773
41843
|
var WIX_APIS_BASE_URL3 = "https://www.wixapis.com";
|
|
41844
|
+
var DEFAULT_SITE_NAME = /^my site(\s+\d+)?$/i;
|
|
41845
|
+
var NON_LATIN_LETTER = /(?![\p{Script=Latin}])\p{L}/u;
|
|
41846
|
+
function isSearchableSiteName(siteName) {
|
|
41847
|
+
return !DEFAULT_SITE_NAME.test(siteName.trim()) && !NON_LATIN_LETTER.test(siteName);
|
|
41848
|
+
}
|
|
41774
41849
|
async function fetchSiteDisplayName(siteAuthorization, siteId) {
|
|
41775
41850
|
const response = await fetch(
|
|
41776
41851
|
`${WIX_APIS_BASE_URL3}/site-properties/v4/properties`,
|
|
@@ -41795,7 +41870,15 @@ function addSuggestedDomainTool(server, authStrategy) {
|
|
|
41795
41870
|
GET_SUGGESTED_DOMAINS_TOOL_NAME,
|
|
41796
41871
|
{
|
|
41797
41872
|
title: "Get Suggested Domains",
|
|
41798
|
-
description:
|
|
41873
|
+
description: dedent_default`
|
|
41874
|
+
Suggests available domain names for a business, brand, or Wix site.
|
|
41875
|
+
|
|
41876
|
+
Call this when the user asks for domain name ideas, wants to know which domains are available, or wants a domain for a new or existing site.
|
|
41877
|
+
|
|
41878
|
+
Provide either a free-text \`query\` (the user's own words, e.g. "pancakes business", "modern yoga studio") OR a \`siteId\` to base the suggestions on that site's name. At least one of them is required.
|
|
41879
|
+
|
|
41880
|
+
Present the returned domains to the user as a short list. This tool only suggests domains — it does not purchase or connect them.
|
|
41881
|
+
`,
|
|
41799
41882
|
inputSchema: {
|
|
41800
41883
|
query: zod_default.string().optional().describe(
|
|
41801
41884
|
"Free-text keywords, business idea, or brand concept to base suggestions on. Use the user's own words."
|
|
@@ -41815,10 +41898,11 @@ function addSuggestedDomainTool(server, authStrategy) {
|
|
|
41815
41898
|
},
|
|
41816
41899
|
_meta: {
|
|
41817
41900
|
securitySchemes: [{ type: "oauth2", scopes: ["offline_access"] }],
|
|
41818
|
-
|
|
41901
|
+
// Model-visible so hosts (e.g. Microsoft 365 Copilot) can call it directly and show it
|
|
41902
|
+
// in their debug info; 'app' keeps it callable from the site-builder widget.
|
|
41903
|
+
ui: { visibility: ["app", "model"] },
|
|
41819
41904
|
"openai/toolInvocation/invoking": "Fetching suggested domains",
|
|
41820
|
-
"openai/toolInvocation/invoked": "Suggested domains retrieved"
|
|
41821
|
-
"openai/visibility": "private"
|
|
41905
|
+
"openai/toolInvocation/invoked": "Suggested domains retrieved"
|
|
41822
41906
|
}
|
|
41823
41907
|
},
|
|
41824
41908
|
async (args, { panorama }) => {
|
|
@@ -41866,7 +41950,9 @@ function addSuggestedDomainTool(server, authStrategy) {
|
|
|
41866
41950
|
structuredContent: { domains: [] }
|
|
41867
41951
|
};
|
|
41868
41952
|
}
|
|
41869
|
-
resolvedQuery
|
|
41953
|
+
if (isSearchableSiteName(siteName) || !resolvedQuery) {
|
|
41954
|
+
resolvedQuery = siteName;
|
|
41955
|
+
}
|
|
41870
41956
|
} catch (error2) {
|
|
41871
41957
|
panorama.logger().error(
|
|
41872
41958
|
`[getSuggestedDomains] Error fetching site name for siteId: ${siteId}`,
|
|
@@ -42322,7 +42408,8 @@ function addWixSiteCreationTool(server, _authStrategy, options) {
|
|
|
42322
42408
|
};
|
|
42323
42409
|
const message = buildSiteCreationSelectorMessage(
|
|
42324
42410
|
args.query,
|
|
42325
|
-
args.customActions
|
|
42411
|
+
args.customActions,
|
|
42412
|
+
{ plain: server.isMicrosoftCopilotClient() }
|
|
42326
42413
|
);
|
|
42327
42414
|
return withJsonContent({
|
|
42328
42415
|
content: [
|
|
@@ -45178,10 +45265,14 @@ function addImportClaudeDesignTool(server, authStrategy, options) {
|
|
|
45178
45265
|
try {
|
|
45179
45266
|
designUrl = new URL(args.url);
|
|
45180
45267
|
} catch {
|
|
45181
|
-
return errorResult(
|
|
45268
|
+
return errorResult(
|
|
45269
|
+
"Invalid design URL \u2014 this tool only accepts the claudeusercontent.com URL produced by Claude Design. For site files the user provided themselves, do not retry: send the user to https://www.wix.com/headless/drop?utm_campaign=mcp to upload them and get a live hosted site."
|
|
45270
|
+
);
|
|
45182
45271
|
}
|
|
45183
45272
|
if (designUrl.protocol !== "https:" || !designUrl.hostname.endsWith(CLAUDE_USER_CONTENT_HOST_SUFFIX)) {
|
|
45184
|
-
return errorResult(
|
|
45273
|
+
return errorResult(
|
|
45274
|
+
"Invalid design URL \u2014 this tool only accepts the claudeusercontent.com URL produced by Claude Design. For site files the user provided themselves, do not retry: send the user to https://www.wix.com/headless/drop?utm_campaign=mcp to upload them and get a live hosted site."
|
|
45275
|
+
);
|
|
45185
45276
|
}
|
|
45186
45277
|
const accountHeaders = await authStrategy.getAccountAuthHeaders();
|
|
45187
45278
|
const wixstroOptions = { baseUrl: wixstroBaseUrl, accountHeaders };
|
|
@@ -45280,6 +45371,765 @@ function truncateResponse(content, maxChars = DEFAULT_MAX_CHARS) {
|
|
|
45280
45371
|
Response was ~${estimatedTokens.toLocaleString()} tokens (limit: ${limitTokens.toLocaleString()}). Refine your code to return less data.`;
|
|
45281
45372
|
}
|
|
45282
45373
|
|
|
45374
|
+
// src/graphql/constants.ts
|
|
45375
|
+
var WIX_GRAPHQL_ENDPOINT = "https://www.wixapis.com/graphql/alpha";
|
|
45376
|
+
var SEARCH_GRAPHQL_TOOL_NAME = "SearchWixGraphQLOperations";
|
|
45377
|
+
var INSPECT_GRAPHQL_TOOL_NAME = "InspectWixGraphQLSchema";
|
|
45378
|
+
var EXECUTE_GRAPHQL_TOOL_NAME = "ExecuteWixGraphQL";
|
|
45379
|
+
var GRAPHQL_TOOL_NAMES = [
|
|
45380
|
+
SEARCH_GRAPHQL_TOOL_NAME,
|
|
45381
|
+
INSPECT_GRAPHQL_TOOL_NAME,
|
|
45382
|
+
EXECUTE_GRAPHQL_TOOL_NAME
|
|
45383
|
+
];
|
|
45384
|
+
|
|
45385
|
+
// src/graphql/introspection.ts
|
|
45386
|
+
var TYPE_REF_FRAGMENT = `
|
|
45387
|
+
fragment TR on __Type { kind name ofType { kind name ofType { kind name ofType { kind name } } } }`;
|
|
45388
|
+
var ROOT_OPERATIONS_QUERY = `{
|
|
45389
|
+
__schema {
|
|
45390
|
+
queryType { fields { name description args { name type { ...TR } } type { ...TR } } }
|
|
45391
|
+
mutationType { fields { name description args { name type { ...TR } } type { ...TR } } }
|
|
45392
|
+
}
|
|
45393
|
+
}${TYPE_REF_FRAGMENT}`;
|
|
45394
|
+
var TYPE_DETAILS_FRAGMENT = `
|
|
45395
|
+
fragment TD on __Type {
|
|
45396
|
+
kind name description
|
|
45397
|
+
fields { name description type { ...TR } args { name type { ...TR } } }
|
|
45398
|
+
inputFields { name description type { ...TR } defaultValue }
|
|
45399
|
+
enumValues { name description }
|
|
45400
|
+
possibleTypes { name }
|
|
45401
|
+
}`;
|
|
45402
|
+
var ROOT_CACHE_TTL_MS = 6 * 60 * 60 * 1e3;
|
|
45403
|
+
var rootCache;
|
|
45404
|
+
var typeCache = /* @__PURE__ */ new Map();
|
|
45405
|
+
function resetGraphqlSchemaCache() {
|
|
45406
|
+
rootCache = void 0;
|
|
45407
|
+
typeCache.clear();
|
|
45408
|
+
}
|
|
45409
|
+
var RETRY_DELAYS_MS = [800, 2e3, 4e3];
|
|
45410
|
+
var sleep = (ms) => new Promise((r) => setTimeout(r, ms));
|
|
45411
|
+
async function fetchWithRetry(fetchImpl, url, init, delays = RETRY_DELAYS_MS) {
|
|
45412
|
+
let attempt = 0;
|
|
45413
|
+
for (; ; ) {
|
|
45414
|
+
const resp = await fetchImpl(url, init);
|
|
45415
|
+
if (resp.status < 500 || attempt >= delays.length) return resp;
|
|
45416
|
+
await sleep(delays[attempt++]);
|
|
45417
|
+
}
|
|
45418
|
+
}
|
|
45419
|
+
async function postIntrospection(query, options) {
|
|
45420
|
+
const fetchImpl = options.fetchImpl ?? fetch;
|
|
45421
|
+
const endpoint = options.endpoint ?? WIX_GRAPHQL_ENDPOINT;
|
|
45422
|
+
const resp = await fetchWithRetry(
|
|
45423
|
+
fetchImpl,
|
|
45424
|
+
endpoint,
|
|
45425
|
+
{
|
|
45426
|
+
method: "POST",
|
|
45427
|
+
headers: {
|
|
45428
|
+
"Content-Type": "application/json",
|
|
45429
|
+
Accept: "application/json"
|
|
45430
|
+
},
|
|
45431
|
+
body: JSON.stringify({ query })
|
|
45432
|
+
},
|
|
45433
|
+
options.retryDelaysMs
|
|
45434
|
+
);
|
|
45435
|
+
const text = await resp.text();
|
|
45436
|
+
if (!resp.ok) {
|
|
45437
|
+
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);
|
|
45438
|
+
throw new Error(
|
|
45439
|
+
`GraphQL introspection failed (${resp.status} ${resp.statusText}): ${body}`
|
|
45440
|
+
);
|
|
45441
|
+
}
|
|
45442
|
+
const json = JSON.parse(text);
|
|
45443
|
+
if (json.errors?.length && !json.data) {
|
|
45444
|
+
throw new Error(
|
|
45445
|
+
`GraphQL introspection returned errors: ${JSON.stringify(json.errors).slice(0, 500)}`
|
|
45446
|
+
);
|
|
45447
|
+
}
|
|
45448
|
+
return json.data;
|
|
45449
|
+
}
|
|
45450
|
+
function getRootOperations(options = {}) {
|
|
45451
|
+
const now = Date.now();
|
|
45452
|
+
if (rootCache && now - rootCache.fetchedAt < ROOT_CACHE_TTL_MS) {
|
|
45453
|
+
return rootCache.promise;
|
|
45454
|
+
}
|
|
45455
|
+
const promise = postIntrospection(ROOT_OPERATIONS_QUERY, options).then(
|
|
45456
|
+
(data) => {
|
|
45457
|
+
const toOps = (fields, kind) => (fields ?? []).map((f2) => ({
|
|
45458
|
+
kind,
|
|
45459
|
+
name: f2.name,
|
|
45460
|
+
description: f2.description ?? "",
|
|
45461
|
+
args: f2.args ?? [],
|
|
45462
|
+
type: f2.type
|
|
45463
|
+
}));
|
|
45464
|
+
return [
|
|
45465
|
+
...toOps(data?.__schema?.queryType?.fields, "query"),
|
|
45466
|
+
...toOps(data?.__schema?.mutationType?.fields, "mutation")
|
|
45467
|
+
];
|
|
45468
|
+
}
|
|
45469
|
+
);
|
|
45470
|
+
promise.catch(() => {
|
|
45471
|
+
if (rootCache?.promise === promise) rootCache = void 0;
|
|
45472
|
+
});
|
|
45473
|
+
rootCache = { promise, fetchedAt: now };
|
|
45474
|
+
return promise;
|
|
45475
|
+
}
|
|
45476
|
+
var GRAPHQL_NAME = /^[_A-Za-z][_0-9A-Za-z]*$/;
|
|
45477
|
+
var TYPE_BATCH_SIZE = 10;
|
|
45478
|
+
async function getTypes(names, options = {}) {
|
|
45479
|
+
const unique = [...new Set(names)].filter((n) => GRAPHQL_NAME.test(n));
|
|
45480
|
+
const missing = unique.filter((n) => !typeCache.has(n));
|
|
45481
|
+
for (let start = 0; start < missing.length; start += TYPE_BATCH_SIZE) {
|
|
45482
|
+
const chunk = missing.slice(start, start + TYPE_BATCH_SIZE);
|
|
45483
|
+
const selections = chunk.map((n, i) => `t${i}: __type(name: "${n}") { ...TD }`).join("\n");
|
|
45484
|
+
const query = `{
|
|
45485
|
+
${selections}
|
|
45486
|
+
}${TYPE_DETAILS_FRAGMENT}${TYPE_REF_FRAGMENT}`;
|
|
45487
|
+
const batch = postIntrospection(query, options);
|
|
45488
|
+
chunk.forEach((n, i) => {
|
|
45489
|
+
const p2 = batch.then(
|
|
45490
|
+
(data) => data?.[`t${i}`] ?? null
|
|
45491
|
+
);
|
|
45492
|
+
p2.catch(() => {
|
|
45493
|
+
if (typeCache.get(n) === p2) typeCache.delete(n);
|
|
45494
|
+
});
|
|
45495
|
+
typeCache.set(n, p2);
|
|
45496
|
+
});
|
|
45497
|
+
await batch.catch(() => void 0);
|
|
45498
|
+
}
|
|
45499
|
+
const result = /* @__PURE__ */ new Map();
|
|
45500
|
+
await Promise.all(
|
|
45501
|
+
unique.map(async (n) => {
|
|
45502
|
+
result.set(n, await typeCache.get(n));
|
|
45503
|
+
})
|
|
45504
|
+
);
|
|
45505
|
+
return result;
|
|
45506
|
+
}
|
|
45507
|
+
function renderTypeRef(ref) {
|
|
45508
|
+
if (!ref) return "Unknown";
|
|
45509
|
+
if (ref.kind === "NON_NULL") return `${renderTypeRef(ref.ofType)}!`;
|
|
45510
|
+
if (ref.kind === "LIST") return `[${renderTypeRef(ref.ofType)}]`;
|
|
45511
|
+
return ref.name ?? "Unknown";
|
|
45512
|
+
}
|
|
45513
|
+
function namedType(ref) {
|
|
45514
|
+
let cur = ref;
|
|
45515
|
+
while (cur && (cur.kind === "NON_NULL" || cur.kind === "LIST")) {
|
|
45516
|
+
cur = cur.ofType ?? null;
|
|
45517
|
+
}
|
|
45518
|
+
return cur?.name ?? null;
|
|
45519
|
+
}
|
|
45520
|
+
var BUILTIN_SCALARS = /* @__PURE__ */ new Set([
|
|
45521
|
+
"String",
|
|
45522
|
+
"Int",
|
|
45523
|
+
"Float",
|
|
45524
|
+
"Boolean",
|
|
45525
|
+
"ID",
|
|
45526
|
+
"JSON"
|
|
45527
|
+
]);
|
|
45528
|
+
function isBuiltinScalar(name) {
|
|
45529
|
+
return !!name && BUILTIN_SCALARS.has(name);
|
|
45530
|
+
}
|
|
45531
|
+
function oneLine(text, max) {
|
|
45532
|
+
if (!text) return "";
|
|
45533
|
+
const flat = text.replace(/\s+/g, " ").trim();
|
|
45534
|
+
return flat.length > max ? `${flat.slice(0, max - 1)}\u2026` : flat;
|
|
45535
|
+
}
|
|
45536
|
+
function renderField(field, isInput) {
|
|
45537
|
+
const args = !isInput && field.args?.length ? `(${field.args.map((a2) => `${a2.name}: ${renderTypeRef(a2.type)}`).join(", ")})` : "";
|
|
45538
|
+
const def = isInput && field.defaultValue != null ? ` = ${field.defaultValue}` : "";
|
|
45539
|
+
const comment = field.description ? ` # ${oneLine(field.description, 140)}` : "";
|
|
45540
|
+
return ` ${field.name}${args}: ${renderTypeRef(field.type)}${def}${comment}`;
|
|
45541
|
+
}
|
|
45542
|
+
function renderType(type) {
|
|
45543
|
+
const references = /* @__PURE__ */ new Set();
|
|
45544
|
+
const collect = (ref) => {
|
|
45545
|
+
const n = namedType(ref);
|
|
45546
|
+
if (n && !isBuiltinScalar(n) && n !== type.name) references.add(n);
|
|
45547
|
+
};
|
|
45548
|
+
const header = type.description ? `# ${oneLine(type.description, 200)}
|
|
45549
|
+
` : "";
|
|
45550
|
+
let body;
|
|
45551
|
+
switch (type.kind) {
|
|
45552
|
+
case "ENUM":
|
|
45553
|
+
body = `enum ${type.name} {
|
|
45554
|
+
${(type.enumValues ?? []).map(
|
|
45555
|
+
(v) => ` ${v.name}${v.description ? ` # ${oneLine(v.description, 100)}` : ""}`
|
|
45556
|
+
).join("\n")}
|
|
45557
|
+
}`;
|
|
45558
|
+
break;
|
|
45559
|
+
case "INPUT_OBJECT":
|
|
45560
|
+
(type.inputFields ?? []).forEach((f2) => collect(f2.type));
|
|
45561
|
+
body = `input ${type.name} {
|
|
45562
|
+
${(type.inputFields ?? []).map((f2) => renderField(f2, true)).join("\n")}
|
|
45563
|
+
}`;
|
|
45564
|
+
break;
|
|
45565
|
+
case "UNION":
|
|
45566
|
+
(type.possibleTypes ?? []).forEach((p2) => references.add(p2.name));
|
|
45567
|
+
body = `union ${type.name} = ${(type.possibleTypes ?? []).map((p2) => p2.name).join(" | ")}`;
|
|
45568
|
+
break;
|
|
45569
|
+
case "SCALAR":
|
|
45570
|
+
body = `scalar ${type.name}`;
|
|
45571
|
+
break;
|
|
45572
|
+
default: {
|
|
45573
|
+
(type.fields ?? []).forEach((f2) => {
|
|
45574
|
+
collect(f2.type);
|
|
45575
|
+
f2.args?.forEach((a2) => collect(a2.type));
|
|
45576
|
+
});
|
|
45577
|
+
const keyword = type.kind === "INTERFACE" ? "interface" : "type";
|
|
45578
|
+
body = `${keyword} ${type.name} {
|
|
45579
|
+
${(type.fields ?? []).map((f2) => renderField(f2, false)).join("\n")}
|
|
45580
|
+
}`;
|
|
45581
|
+
}
|
|
45582
|
+
}
|
|
45583
|
+
return { text: header + body, references: [...references] };
|
|
45584
|
+
}
|
|
45585
|
+
function renderOperationSignature(op) {
|
|
45586
|
+
const args = op.args.map((a2) => `${a2.name}: ${renderTypeRef(a2.type)}`).join(", ");
|
|
45587
|
+
return `${op.kind === "query" ? "Query" : "Mutation"}.${op.name}(${args}): ${renderTypeRef(op.type)}`;
|
|
45588
|
+
}
|
|
45589
|
+
async function expandTypes(rootTypeNames, options = {}) {
|
|
45590
|
+
const depth = Math.max(1, Math.min(options.depth ?? 2, 5));
|
|
45591
|
+
const maxTypes = options.maxTypes ?? 40;
|
|
45592
|
+
const rendered = [];
|
|
45593
|
+
const unknown2 = [];
|
|
45594
|
+
const seen = /* @__PURE__ */ new Set();
|
|
45595
|
+
let frontier = [...new Set(rootTypeNames)].filter((n) => !isBuiltinScalar(n));
|
|
45596
|
+
let level = 1;
|
|
45597
|
+
let overflow = [];
|
|
45598
|
+
while (frontier.length > 0 && level <= depth) {
|
|
45599
|
+
const room = maxTypes - seen.size;
|
|
45600
|
+
if (room <= 0) {
|
|
45601
|
+
overflow = frontier;
|
|
45602
|
+
break;
|
|
45603
|
+
}
|
|
45604
|
+
const batch = frontier.slice(0, room);
|
|
45605
|
+
overflow = frontier.slice(room);
|
|
45606
|
+
batch.forEach((n) => seen.add(n));
|
|
45607
|
+
const types = await getTypes(batch, options);
|
|
45608
|
+
const next = /* @__PURE__ */ new Set();
|
|
45609
|
+
for (const name of batch) {
|
|
45610
|
+
const type = types.get(name);
|
|
45611
|
+
if (!type) {
|
|
45612
|
+
unknown2.push(name);
|
|
45613
|
+
continue;
|
|
45614
|
+
}
|
|
45615
|
+
const { text, references } = renderType(type);
|
|
45616
|
+
rendered.push(text);
|
|
45617
|
+
references.forEach((r) => {
|
|
45618
|
+
if (!seen.has(r)) next.add(r);
|
|
45619
|
+
});
|
|
45620
|
+
}
|
|
45621
|
+
frontier = [...next];
|
|
45622
|
+
level++;
|
|
45623
|
+
}
|
|
45624
|
+
const unexpanded = [.../* @__PURE__ */ new Set([...overflow, ...frontier])].filter(
|
|
45625
|
+
(n) => !seen.has(n) && !isBuiltinScalar(n)
|
|
45626
|
+
);
|
|
45627
|
+
return { rendered, unexpanded, unknown: unknown2 };
|
|
45628
|
+
}
|
|
45629
|
+
|
|
45630
|
+
// src/graphql/search.ts
|
|
45631
|
+
function tokenize(text) {
|
|
45632
|
+
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);
|
|
45633
|
+
}
|
|
45634
|
+
var STOP_WORDS = /* @__PURE__ */ new Set([
|
|
45635
|
+
"a",
|
|
45636
|
+
"an",
|
|
45637
|
+
"the",
|
|
45638
|
+
"of",
|
|
45639
|
+
"for",
|
|
45640
|
+
"to",
|
|
45641
|
+
"in",
|
|
45642
|
+
"on",
|
|
45643
|
+
"with",
|
|
45644
|
+
"and",
|
|
45645
|
+
"or",
|
|
45646
|
+
"by",
|
|
45647
|
+
"all",
|
|
45648
|
+
"my",
|
|
45649
|
+
"me",
|
|
45650
|
+
"i",
|
|
45651
|
+
"from",
|
|
45652
|
+
"is",
|
|
45653
|
+
"are",
|
|
45654
|
+
"be",
|
|
45655
|
+
"it",
|
|
45656
|
+
"this",
|
|
45657
|
+
"that",
|
|
45658
|
+
"wix",
|
|
45659
|
+
"api",
|
|
45660
|
+
"graphql"
|
|
45661
|
+
]);
|
|
45662
|
+
function stem(token) {
|
|
45663
|
+
if (token.length > 4 && token.endsWith("ies"))
|
|
45664
|
+
return `${token.slice(0, -3)}y`;
|
|
45665
|
+
if (token.length > 3 && token.endsWith("es") && !token.endsWith("ses"))
|
|
45666
|
+
return token.slice(0, -1);
|
|
45667
|
+
if (token.length > 3 && token.endsWith("s") && !token.endsWith("ss"))
|
|
45668
|
+
return token.slice(0, -1);
|
|
45669
|
+
return token;
|
|
45670
|
+
}
|
|
45671
|
+
var VERB_SYNONYMS = {
|
|
45672
|
+
list: ["query", "list", "search"],
|
|
45673
|
+
find: ["query", "search", "get"],
|
|
45674
|
+
fetch: ["get", "query"],
|
|
45675
|
+
read: ["get", "query"],
|
|
45676
|
+
show: ["get", "query"],
|
|
45677
|
+
count: ["count", "query"],
|
|
45678
|
+
add: ["create", "add"],
|
|
45679
|
+
new: ["create"],
|
|
45680
|
+
insert: ["create"],
|
|
45681
|
+
edit: ["update"],
|
|
45682
|
+
change: ["update"],
|
|
45683
|
+
modify: ["update"],
|
|
45684
|
+
set: ["update"],
|
|
45685
|
+
remove: ["delete", "remove"],
|
|
45686
|
+
destroy: ["delete"],
|
|
45687
|
+
cancel: ["cancel", "delete"],
|
|
45688
|
+
customer: ["contact", "member"],
|
|
45689
|
+
client: ["contact", "member"],
|
|
45690
|
+
item: ["product", "item"],
|
|
45691
|
+
inventory: ["inventory", "stock"],
|
|
45692
|
+
stock: ["inventory", "stock"],
|
|
45693
|
+
post: ["post", "blog"],
|
|
45694
|
+
article: ["post", "blog"],
|
|
45695
|
+
appointment: ["booking", "session"],
|
|
45696
|
+
collection: ["collection", "category", "data"],
|
|
45697
|
+
cms: ["data", "collection"],
|
|
45698
|
+
store: ["stores", "store"]
|
|
45699
|
+
};
|
|
45700
|
+
function expandQueryTokens(tokens) {
|
|
45701
|
+
const out = /* @__PURE__ */ new Set();
|
|
45702
|
+
for (const raw of tokens) {
|
|
45703
|
+
if (STOP_WORDS.has(raw)) continue;
|
|
45704
|
+
const s2 = stem(raw);
|
|
45705
|
+
out.add(s2);
|
|
45706
|
+
for (const syn of VERB_SYNONYMS[raw] ?? VERB_SYNONYMS[s2] ?? []) {
|
|
45707
|
+
out.add(stem(syn));
|
|
45708
|
+
}
|
|
45709
|
+
}
|
|
45710
|
+
return out;
|
|
45711
|
+
}
|
|
45712
|
+
var READ_VERBS = /* @__PURE__ */ new Set([
|
|
45713
|
+
"list",
|
|
45714
|
+
"get",
|
|
45715
|
+
"query",
|
|
45716
|
+
"find",
|
|
45717
|
+
"fetch",
|
|
45718
|
+
"read",
|
|
45719
|
+
"show",
|
|
45720
|
+
"retrieve",
|
|
45721
|
+
"search",
|
|
45722
|
+
"count",
|
|
45723
|
+
"view",
|
|
45724
|
+
"see"
|
|
45725
|
+
]);
|
|
45726
|
+
var WRITE_VERBS = /* @__PURE__ */ new Set([
|
|
45727
|
+
"create",
|
|
45728
|
+
"add",
|
|
45729
|
+
"new",
|
|
45730
|
+
"insert",
|
|
45731
|
+
"update",
|
|
45732
|
+
"edit",
|
|
45733
|
+
"change",
|
|
45734
|
+
"modify",
|
|
45735
|
+
"set",
|
|
45736
|
+
"delete",
|
|
45737
|
+
"remove",
|
|
45738
|
+
"destroy",
|
|
45739
|
+
"cancel",
|
|
45740
|
+
"bulk",
|
|
45741
|
+
"merge",
|
|
45742
|
+
"publish",
|
|
45743
|
+
"send"
|
|
45744
|
+
]);
|
|
45745
|
+
var isVersionToken = (t) => t === "v" || /^\d+$/.test(t);
|
|
45746
|
+
function stripMarkdown(text) {
|
|
45747
|
+
return text.replace(/\[([^\]]+)\]\([^)]*\)/g, "$1").replace(/[`*_]/g, "");
|
|
45748
|
+
}
|
|
45749
|
+
function firstSentence(text, max = 220) {
|
|
45750
|
+
const flat = stripMarkdown(text).replace(/\s+/g, " ").trim();
|
|
45751
|
+
const cut = flat.search(/(?<=[.!?])\s/);
|
|
45752
|
+
const sentence = cut > 0 ? flat.slice(0, cut) : flat;
|
|
45753
|
+
return sentence.length > max ? `${sentence.slice(0, max - 1)}\u2026` : sentence;
|
|
45754
|
+
}
|
|
45755
|
+
var indexCache = /* @__PURE__ */ new WeakMap();
|
|
45756
|
+
function indexOperations(ops) {
|
|
45757
|
+
let indexed = indexCache.get(ops);
|
|
45758
|
+
if (!indexed) {
|
|
45759
|
+
indexed = ops.map((op) => ({
|
|
45760
|
+
op,
|
|
45761
|
+
nameTokens: new Set(tokenize(op.name).map(stem)),
|
|
45762
|
+
descTokens: new Set(tokenize(op.description.slice(0, 600)).map(stem))
|
|
45763
|
+
}));
|
|
45764
|
+
indexCache.set(ops, indexed);
|
|
45765
|
+
}
|
|
45766
|
+
return indexed;
|
|
45767
|
+
}
|
|
45768
|
+
function searchOperations(ops, query, options = {}) {
|
|
45769
|
+
const { kind = "all", maxResults = 10 } = options;
|
|
45770
|
+
const rawTokens = tokenize(query);
|
|
45771
|
+
const terms = expandQueryTokens(rawTokens);
|
|
45772
|
+
const originalTerms = new Set(
|
|
45773
|
+
rawTokens.filter((t) => !STOP_WORDS.has(t)).map(stem)
|
|
45774
|
+
);
|
|
45775
|
+
const exactName = query.trim();
|
|
45776
|
+
const hasWriteVerb = rawTokens.some((t) => WRITE_VERBS.has(t));
|
|
45777
|
+
const nounTokens = rawTokens.filter(
|
|
45778
|
+
(t) => !STOP_WORDS.has(t) && !READ_VERBS.has(t) && !WRITE_VERBS.has(t)
|
|
45779
|
+
);
|
|
45780
|
+
const pluralIntent = nounTokens.length > 0 && nounTokens.some((t) => stem(t) !== t);
|
|
45781
|
+
const readIntent = !hasWriteVerb;
|
|
45782
|
+
const matches = [];
|
|
45783
|
+
for (const { op, nameTokens, descTokens } of indexOperations(ops)) {
|
|
45784
|
+
if (kind !== "all" && op.kind !== kind) continue;
|
|
45785
|
+
let score = 0;
|
|
45786
|
+
let originalHits = 0;
|
|
45787
|
+
const matchedNameTokens = /* @__PURE__ */ new Set();
|
|
45788
|
+
for (const term of terms) {
|
|
45789
|
+
const isOriginal = originalTerms.has(term);
|
|
45790
|
+
if (op.kind === "query" && readIntent && READ_VERBS.has(term)) {
|
|
45791
|
+
score += isOriginal ? 4 : 2;
|
|
45792
|
+
if (isOriginal) originalHits++;
|
|
45793
|
+
if (nameTokens.has(term)) matchedNameTokens.add(term);
|
|
45794
|
+
continue;
|
|
45795
|
+
}
|
|
45796
|
+
if (nameTokens.has(term)) {
|
|
45797
|
+
matchedNameTokens.add(term);
|
|
45798
|
+
score += isOriginal ? 4 : 2;
|
|
45799
|
+
if (isOriginal) originalHits++;
|
|
45800
|
+
continue;
|
|
45801
|
+
}
|
|
45802
|
+
let prefixHit = false;
|
|
45803
|
+
for (const nt2 of nameTokens) {
|
|
45804
|
+
if (term.length >= 3 && (nt2.startsWith(term) || term.startsWith(nt2))) {
|
|
45805
|
+
prefixHit = true;
|
|
45806
|
+
matchedNameTokens.add(nt2);
|
|
45807
|
+
break;
|
|
45808
|
+
}
|
|
45809
|
+
}
|
|
45810
|
+
if (prefixHit) {
|
|
45811
|
+
score += isOriginal ? 2 : 1;
|
|
45812
|
+
if (isOriginal) originalHits++;
|
|
45813
|
+
continue;
|
|
45814
|
+
}
|
|
45815
|
+
if (descTokens.has(term)) {
|
|
45816
|
+
score += 1;
|
|
45817
|
+
if (isOriginal) originalHits++;
|
|
45818
|
+
}
|
|
45819
|
+
}
|
|
45820
|
+
if (score <= 0 && op.name !== exactName) continue;
|
|
45821
|
+
if (op.name === exactName) score += 100;
|
|
45822
|
+
if (originalTerms.size > 0 && originalHits === originalTerms.size) {
|
|
45823
|
+
score += 3;
|
|
45824
|
+
}
|
|
45825
|
+
const lastToken = tokenize(op.name).filter((t) => !isVersionToken(t)).pop();
|
|
45826
|
+
if (lastToken && nounTokens.length > 0) {
|
|
45827
|
+
const pluralOp = stem(lastToken) !== lastToken;
|
|
45828
|
+
score += pluralOp === pluralIntent ? 0.5 : -0.5;
|
|
45829
|
+
}
|
|
45830
|
+
if (/DoNotCall/i.test(op.name)) score -= 2;
|
|
45831
|
+
for (const nt2 of nameTokens) {
|
|
45832
|
+
if (!isVersionToken(nt2) && !matchedNameTokens.has(nt2)) score -= 0.3;
|
|
45833
|
+
}
|
|
45834
|
+
if (readIntent && op.kind === "mutation" && [...nameTokens].some((t) => WRITE_VERBS.has(t))) {
|
|
45835
|
+
score -= 6;
|
|
45836
|
+
}
|
|
45837
|
+
if (op.kind === "query" && readIntent) score += 1;
|
|
45838
|
+
const version2 = op.name.match(/V(\d+)/);
|
|
45839
|
+
if (version2) score += Math.min(Number(version2[1]), 5) * 0.1;
|
|
45840
|
+
if (!op.description) score -= 0.5;
|
|
45841
|
+
score -= op.name.length / 200;
|
|
45842
|
+
if (score <= 0) continue;
|
|
45843
|
+
matches.push({
|
|
45844
|
+
operation: op.name,
|
|
45845
|
+
kind: op.kind,
|
|
45846
|
+
signature: `${op.name}(${op.args.map((a2) => `${a2.name}: ${renderTypeRef(a2.type)}`).join(", ")}): ${renderTypeRef(op.type)}`,
|
|
45847
|
+
description: firstSentence(op.description),
|
|
45848
|
+
inputType: op.args[0] ? namedType(op.args[0].type) : null,
|
|
45849
|
+
returnType: namedType(op.type),
|
|
45850
|
+
score: Math.round(score * 100) / 100
|
|
45851
|
+
});
|
|
45852
|
+
}
|
|
45853
|
+
matches.sort(
|
|
45854
|
+
(a2, b2) => b2.score - a2.score || a2.operation.localeCompare(b2.operation)
|
|
45855
|
+
);
|
|
45856
|
+
return matches.slice(0, Math.max(1, Math.min(maxResults, 50)));
|
|
45857
|
+
}
|
|
45858
|
+
|
|
45859
|
+
// src/graphql/index.ts
|
|
45860
|
+
var textResult = (text) => ({
|
|
45861
|
+
content: [{ type: "text", text }]
|
|
45862
|
+
});
|
|
45863
|
+
var errorResult2 = (text) => ({
|
|
45864
|
+
isError: true,
|
|
45865
|
+
content: [{ type: "text", text }]
|
|
45866
|
+
});
|
|
45867
|
+
var SCHEMA_MAX_RESPONSE_CHARS = 48e3;
|
|
45868
|
+
function addGraphqlTools(server, options = {}) {
|
|
45869
|
+
const { authStrategy, disableTools = [], toolDescriptions } = options;
|
|
45870
|
+
const getDescription = (name) => toolDescriptions?.[name] ?? defaultToolDescriptions[name];
|
|
45871
|
+
if (!disableTools.includes(SEARCH_GRAPHQL_TOOL_NAME)) {
|
|
45872
|
+
addSearchGraphqlTool(
|
|
45873
|
+
server,
|
|
45874
|
+
getDescription(SEARCH_GRAPHQL_TOOL_NAME),
|
|
45875
|
+
options
|
|
45876
|
+
);
|
|
45877
|
+
}
|
|
45878
|
+
if (!disableTools.includes(INSPECT_GRAPHQL_TOOL_NAME)) {
|
|
45879
|
+
addInspectGraphqlTool(
|
|
45880
|
+
server,
|
|
45881
|
+
getDescription(INSPECT_GRAPHQL_TOOL_NAME),
|
|
45882
|
+
options
|
|
45883
|
+
);
|
|
45884
|
+
}
|
|
45885
|
+
if (authStrategy && !disableTools.includes(EXECUTE_GRAPHQL_TOOL_NAME)) {
|
|
45886
|
+
addExecuteGraphqlTool(
|
|
45887
|
+
server,
|
|
45888
|
+
getDescription(EXECUTE_GRAPHQL_TOOL_NAME),
|
|
45889
|
+
authStrategy,
|
|
45890
|
+
options
|
|
45891
|
+
);
|
|
45892
|
+
}
|
|
45893
|
+
}
|
|
45894
|
+
function introspectionOptions(options) {
|
|
45895
|
+
return {
|
|
45896
|
+
endpoint: options.endpoint,
|
|
45897
|
+
fetchImpl: options.fetchImpl,
|
|
45898
|
+
retryDelaysMs: options.retryDelaysMs
|
|
45899
|
+
};
|
|
45900
|
+
}
|
|
45901
|
+
function addSearchGraphqlTool(server, description, options) {
|
|
45902
|
+
const d2 = desc("SearchWixGraphQLOperations");
|
|
45903
|
+
server.tool(
|
|
45904
|
+
SEARCH_GRAPHQL_TOOL_NAME,
|
|
45905
|
+
description,
|
|
45906
|
+
{
|
|
45907
|
+
query: external_exports.string().describe(d2.query),
|
|
45908
|
+
kind: external_exports.enum(["query", "mutation", "all"]).optional().describe(d2.kind),
|
|
45909
|
+
maxResults: external_exports.number().int().min(1).max(50).optional().describe(d2.maxResults),
|
|
45910
|
+
reason: external_exports.string().describe(d2.reason)
|
|
45911
|
+
},
|
|
45912
|
+
{ readOnlyHint: true, destructiveHint: false, openWorldHint: false },
|
|
45913
|
+
async ({ query, kind, maxResults, reason }) => {
|
|
45914
|
+
logger2.log(
|
|
45915
|
+
`[${SEARCH_GRAPHQL_TOOL_NAME}] query="${query}" kind=${kind ?? "all"} reason="${reason}"`
|
|
45916
|
+
);
|
|
45917
|
+
try {
|
|
45918
|
+
const ops = await getRootOperations(introspectionOptions(options));
|
|
45919
|
+
const matches = searchOperations(ops, query, {
|
|
45920
|
+
kind: kind ?? "all",
|
|
45921
|
+
maxResults: maxResults ?? 10
|
|
45922
|
+
});
|
|
45923
|
+
if (matches.length === 0) {
|
|
45924
|
+
return textResult(
|
|
45925
|
+
`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.`
|
|
45926
|
+
);
|
|
45927
|
+
}
|
|
45928
|
+
const lines = matches.map(
|
|
45929
|
+
(m2, i) => `${i + 1}. ${m2.kind} ${m2.signature}
|
|
45930
|
+
${m2.description || "(no description)"}`
|
|
45931
|
+
);
|
|
45932
|
+
const text = [
|
|
45933
|
+
`Top ${matches.length} of ${ops.length} Wix GraphQL root operations for "${query}":`,
|
|
45934
|
+
"",
|
|
45935
|
+
...lines,
|
|
45936
|
+
"",
|
|
45937
|
+
`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.`
|
|
45938
|
+
].join("\n");
|
|
45939
|
+
return textResult(text);
|
|
45940
|
+
} catch (err) {
|
|
45941
|
+
const message = err instanceof Error ? err.message : String(err);
|
|
45942
|
+
logger2.log(`[${SEARCH_GRAPHQL_TOOL_NAME}] Error: ${message}`);
|
|
45943
|
+
return errorResult2(`GraphQL schema search error: ${message}`);
|
|
45944
|
+
}
|
|
45945
|
+
}
|
|
45946
|
+
);
|
|
45947
|
+
}
|
|
45948
|
+
function addInspectGraphqlTool(server, description, options) {
|
|
45949
|
+
const d2 = desc("InspectWixGraphQLSchema");
|
|
45950
|
+
const maxChars = options.maxResponseSize ?? SCHEMA_MAX_RESPONSE_CHARS;
|
|
45951
|
+
server.tool(
|
|
45952
|
+
INSPECT_GRAPHQL_TOOL_NAME,
|
|
45953
|
+
description,
|
|
45954
|
+
{
|
|
45955
|
+
operation: external_exports.string().optional().describe(d2.operation),
|
|
45956
|
+
typeNames: external_exports.array(external_exports.string()).optional().describe(d2.typeNames),
|
|
45957
|
+
depth: external_exports.number().int().min(1).max(4).optional().describe(d2.depth),
|
|
45958
|
+
reason: external_exports.string().describe(d2.reason)
|
|
45959
|
+
},
|
|
45960
|
+
{ readOnlyHint: true, destructiveHint: false, openWorldHint: false },
|
|
45961
|
+
async ({ operation, typeNames, depth, reason }) => {
|
|
45962
|
+
logger2.log(
|
|
45963
|
+
`[${INSPECT_GRAPHQL_TOOL_NAME}] operation=${operation ?? "-"} typeNames=${JSON.stringify(typeNames ?? [])} depth=${depth ?? 2} reason="${reason}"`
|
|
45964
|
+
);
|
|
45965
|
+
if (!operation && !(typeNames && typeNames.length > 0)) {
|
|
45966
|
+
return errorResult2(
|
|
45967
|
+
"Pass `operation` (a root query/mutation name from SearchWixGraphQLOperations) and/or `typeNames` (type names to expand)."
|
|
45968
|
+
);
|
|
45969
|
+
}
|
|
45970
|
+
try {
|
|
45971
|
+
const io2 = introspectionOptions(options);
|
|
45972
|
+
const sections = [];
|
|
45973
|
+
const roots = [];
|
|
45974
|
+
if (operation) {
|
|
45975
|
+
const ops = await getRootOperations(io2);
|
|
45976
|
+
const op = ops.find((o) => o.name === operation);
|
|
45977
|
+
if (!op) {
|
|
45978
|
+
const suggestions = searchOperations(ops, operation, {
|
|
45979
|
+
maxResults: 5
|
|
45980
|
+
});
|
|
45981
|
+
return errorResult2(
|
|
45982
|
+
`No root operation named "${operation}". ${suggestions.length ? `Did you mean: ${suggestions.map((s2) => `${s2.kind} ${s2.operation}`).join(", ")}? Use SearchWixGraphQLOperations to discover the exact name.` : "Use SearchWixGraphQLOperations to discover the exact name."}`
|
|
45983
|
+
);
|
|
45984
|
+
}
|
|
45985
|
+
sections.push(
|
|
45986
|
+
`# ${renderOperationSignature(op)}`,
|
|
45987
|
+
op.description ? op.description.trim().split("\n").map((l) => `# ${l}`).join("\n") : "# (no description)"
|
|
45988
|
+
);
|
|
45989
|
+
op.args.forEach((a2) => {
|
|
45990
|
+
const n = namedType(a2.type);
|
|
45991
|
+
if (n) roots.push(n);
|
|
45992
|
+
});
|
|
45993
|
+
const ret = namedType(op.type);
|
|
45994
|
+
if (ret) roots.push(ret);
|
|
45995
|
+
}
|
|
45996
|
+
if (typeNames?.length) roots.push(...typeNames);
|
|
45997
|
+
const { rendered, unexpanded, unknown: unknown2 } = await expandTypes(roots, {
|
|
45998
|
+
...io2,
|
|
45999
|
+
depth: depth ?? 2
|
|
46000
|
+
});
|
|
46001
|
+
sections.push(...rendered);
|
|
46002
|
+
if (unknown2.length) {
|
|
46003
|
+
sections.push(
|
|
46004
|
+
`# Unknown type names (not in the schema): ${unknown2.join(", ")}`
|
|
46005
|
+
);
|
|
46006
|
+
}
|
|
46007
|
+
if (unexpanded.length) {
|
|
46008
|
+
sections.push(
|
|
46009
|
+
`# Not expanded (pass any of these in \`typeNames\` to read them): ${unexpanded.join(", ")}`
|
|
46010
|
+
);
|
|
46011
|
+
}
|
|
46012
|
+
sections.push(
|
|
46013
|
+
"# 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."
|
|
46014
|
+
);
|
|
46015
|
+
return textResult(truncateResponse(sections.join("\n\n"), maxChars));
|
|
46016
|
+
} catch (err) {
|
|
46017
|
+
const message = err instanceof Error ? err.message : String(err);
|
|
46018
|
+
logger2.log(`[${INSPECT_GRAPHQL_TOOL_NAME}] Error: ${message}`);
|
|
46019
|
+
return errorResult2(`GraphQL schema inspection error: ${message}`);
|
|
46020
|
+
}
|
|
46021
|
+
}
|
|
46022
|
+
);
|
|
46023
|
+
}
|
|
46024
|
+
function addExecuteGraphqlTool(server, description, authStrategy, options) {
|
|
46025
|
+
const d2 = desc("ExecuteWixGraphQL");
|
|
46026
|
+
const endpoint = options.endpoint ?? WIX_GRAPHQL_ENDPOINT;
|
|
46027
|
+
const fetchImpl = options.fetchImpl ?? fetch;
|
|
46028
|
+
server.tool(
|
|
46029
|
+
EXECUTE_GRAPHQL_TOOL_NAME,
|
|
46030
|
+
description,
|
|
46031
|
+
{
|
|
46032
|
+
query: external_exports.string().describe(d2.query),
|
|
46033
|
+
variables: external_exports.record(external_exports.unknown()).optional().describe(d2.variables),
|
|
46034
|
+
operationName: external_exports.string().optional().describe(d2.operationName),
|
|
46035
|
+
siteId: external_exports.string().optional().describe(d2.siteId),
|
|
46036
|
+
scope: external_exports.enum(["site", "account"]).optional().describe(d2.scope),
|
|
46037
|
+
hasMutations: external_exports.boolean().describe(d2.hasMutations),
|
|
46038
|
+
reason: external_exports.string().describe(d2.reason)
|
|
46039
|
+
},
|
|
46040
|
+
{ readOnlyHint: false, destructiveHint: true, openWorldHint: false },
|
|
46041
|
+
async ({ query, variables, operationName, siteId, scope, hasMutations, reason }, extra) => {
|
|
46042
|
+
const effectiveScope = scope ?? (siteId ? "site" : "account");
|
|
46043
|
+
logger2.log(
|
|
46044
|
+
`[${EXECUTE_GRAPHQL_TOOL_NAME}] scope=${effectiveScope} siteId=${siteId ?? "none"} hasMutations=${hasMutations} operationName=${operationName ?? "-"} reason="${reason}"`
|
|
46045
|
+
);
|
|
46046
|
+
if (effectiveScope === "site" && !siteId) {
|
|
46047
|
+
return errorResult2(
|
|
46048
|
+
'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.'
|
|
46049
|
+
);
|
|
46050
|
+
}
|
|
46051
|
+
if (!query.trim()) {
|
|
46052
|
+
return errorResult2("`query` must be a non-empty GraphQL document.");
|
|
46053
|
+
}
|
|
46054
|
+
const authHeaders = effectiveScope === "site" ? await authStrategy.getSiteAuthHeaders(siteId) : await authStrategy.getAccountAuthHeaders();
|
|
46055
|
+
try {
|
|
46056
|
+
const init = {
|
|
46057
|
+
method: "POST",
|
|
46058
|
+
headers: {
|
|
46059
|
+
"Content-Type": "application/json",
|
|
46060
|
+
Accept: "application/json",
|
|
46061
|
+
...authHeaders
|
|
46062
|
+
},
|
|
46063
|
+
body: JSON.stringify({
|
|
46064
|
+
query,
|
|
46065
|
+
...variables ? { variables } : {},
|
|
46066
|
+
...operationName ? { operationName } : {}
|
|
46067
|
+
})
|
|
46068
|
+
};
|
|
46069
|
+
const resp = hasMutations ? await fetchImpl(endpoint, init) : await fetchWithRetry(
|
|
46070
|
+
fetchImpl,
|
|
46071
|
+
endpoint,
|
|
46072
|
+
init,
|
|
46073
|
+
options.retryDelaysMs
|
|
46074
|
+
);
|
|
46075
|
+
const requestId = resp.headers?.get("x-wix-request-id") ?? void 0;
|
|
46076
|
+
extra?.setToolBiParams?.({ siteId, requestId });
|
|
46077
|
+
const text = await resp.text();
|
|
46078
|
+
if (!resp.ok) {
|
|
46079
|
+
await authStrategy.enforceValidWixToken?.({
|
|
46080
|
+
status: resp.status,
|
|
46081
|
+
response: { status: resp.status }
|
|
46082
|
+
});
|
|
46083
|
+
const body2 = /^\s*<(!doctype|html)/i.test(text) ? "(HTML error page)" : text.slice(0, 2e3);
|
|
46084
|
+
const hasObjectVariables = !!variables && Object.values(variables).some(
|
|
46085
|
+
(v) => v !== null && typeof v === "object"
|
|
46086
|
+
);
|
|
46087
|
+
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.` : "";
|
|
46088
|
+
return errorResult2(
|
|
46089
|
+
`Wix GraphQL request failed: ${resp.status} ${resp.statusText}.${requestId ? ` request id: ${requestId}.` : ""}${hint}
|
|
46090
|
+
${body2}`
|
|
46091
|
+
);
|
|
46092
|
+
}
|
|
46093
|
+
let json;
|
|
46094
|
+
try {
|
|
46095
|
+
json = JSON.parse(text);
|
|
46096
|
+
} catch {
|
|
46097
|
+
return errorResult2(
|
|
46098
|
+
`Wix GraphQL returned a non-JSON body:
|
|
46099
|
+
${text.slice(0, 2e3)}`
|
|
46100
|
+
);
|
|
46101
|
+
}
|
|
46102
|
+
const hasData = json.data != null && Object.values(json.data).some((v) => v !== null && v !== void 0);
|
|
46103
|
+
const errors = json.errors ?? [];
|
|
46104
|
+
if (!hasData && errors.length > 0) {
|
|
46105
|
+
const permissionDenied = errors.some(
|
|
46106
|
+
(e) => e.extensions?.message === "PERMISSION_DENIED"
|
|
46107
|
+
);
|
|
46108
|
+
return errorResult2(
|
|
46109
|
+
[
|
|
46110
|
+
`Wix GraphQL returned errors and no data${requestId ? ` (request id: ${requestId})` : ""}:`,
|
|
46111
|
+
JSON.stringify(errors, null, 2).slice(0, 4e3),
|
|
46112
|
+
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.'
|
|
46113
|
+
].join("\n")
|
|
46114
|
+
);
|
|
46115
|
+
}
|
|
46116
|
+
const body = { data: json.data };
|
|
46117
|
+
if (errors.length > 0) {
|
|
46118
|
+
body.errors = errors;
|
|
46119
|
+
body.note = "Partial result: some root fields failed (see errors[].path). Fields present in data succeeded.";
|
|
46120
|
+
}
|
|
46121
|
+
return textResult(truncateResponse(body, options.maxResponseSize));
|
|
46122
|
+
} catch (err) {
|
|
46123
|
+
rethrowIfUnauthorized(err);
|
|
46124
|
+
await authStrategy.enforceValidWixToken?.(err);
|
|
46125
|
+
const message = err instanceof Error ? err.message : String(err);
|
|
46126
|
+
logger2.log(`[${EXECUTE_GRAPHQL_TOOL_NAME}] Error: ${message}`);
|
|
46127
|
+
return errorResult2(`Wix GraphQL execution error: ${message}`);
|
|
46128
|
+
}
|
|
46129
|
+
}
|
|
46130
|
+
);
|
|
46131
|
+
}
|
|
46132
|
+
|
|
45283
46133
|
// src/code-mode/validation.ts
|
|
45284
46134
|
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.';
|
|
45285
46135
|
function validateExecuteCode(code) {
|
|
@@ -45765,6 +46615,20 @@ function createWixToolkit(options) {
|
|
|
45765
46615
|
maxResponseSize
|
|
45766
46616
|
});
|
|
45767
46617
|
}
|
|
46618
|
+
const requestedGraphqlTools = GRAPHQL_TOOL_NAMES.filter(
|
|
46619
|
+
(name) => requestedTools.has(name)
|
|
46620
|
+
);
|
|
46621
|
+
if (requestedGraphqlTools.length > 0) {
|
|
46622
|
+
addGraphqlTools(server, {
|
|
46623
|
+
authStrategy,
|
|
46624
|
+
disableTools: [
|
|
46625
|
+
...disableTools ?? [],
|
|
46626
|
+
...GRAPHQL_TOOL_NAMES.filter((n) => !requestedTools.has(n))
|
|
46627
|
+
],
|
|
46628
|
+
toolDescriptions: effectiveToolDescriptions,
|
|
46629
|
+
maxResponseSize
|
|
46630
|
+
});
|
|
46631
|
+
}
|
|
45768
46632
|
} else {
|
|
45769
46633
|
addApiCallTool(
|
|
45770
46634
|
server,
|
|
@@ -45950,13 +46814,17 @@ export {
|
|
|
45950
46814
|
DEFAULT_OPENAI_SECURITY_SCHEMES,
|
|
45951
46815
|
EDIT_SITE_TOOL_NAME,
|
|
45952
46816
|
EXECUTE_FUNCTION_EXPRESSION_HINT,
|
|
46817
|
+
EXECUTE_GRAPHQL_TOOL_NAME,
|
|
45953
46818
|
GET_SUGGESTED_DOMAINS_TOOL_NAME,
|
|
46819
|
+
GRAPHQL_TOOL_NAMES,
|
|
45954
46820
|
IMPORT_CLAUDE_DESIGN_TOOL_NAME,
|
|
46821
|
+
INSPECT_GRAPHQL_TOOL_NAME,
|
|
45955
46822
|
MENU_CONTENT_THRESHOLD,
|
|
45956
46823
|
OPENAI_WIDGET_MIME_TYPE,
|
|
45957
46824
|
OPEN_AI_SITE_WIDGET_CSP,
|
|
45958
46825
|
PULL_SITE_JOB_TOOL_NAME,
|
|
45959
46826
|
RECIPES_INDEX_URL,
|
|
46827
|
+
SEARCH_GRAPHQL_TOOL_NAME,
|
|
45960
46828
|
SEARCH_SITE_TEMPLATES_TOOL_NAME,
|
|
45961
46829
|
SITE_BUILDER_TOOL_NAME,
|
|
45962
46830
|
SITE_CREATION_COPY,
|
|
@@ -45969,6 +46837,7 @@ export {
|
|
|
45969
46837
|
VALID_DOCS_TOOLS,
|
|
45970
46838
|
WIXEL_ICON_PNG_URL,
|
|
45971
46839
|
WIXEL_ICON_SVG_URL,
|
|
46840
|
+
WIX_GRAPHQL_ENDPOINT,
|
|
45972
46841
|
WIX_SITE_CREATION_TOOL_NAME,
|
|
45973
46842
|
WixFetchError,
|
|
45974
46843
|
WixMcpServer,
|
|
@@ -45985,6 +46854,7 @@ export {
|
|
|
45985
46854
|
addGetWixelAssetTool,
|
|
45986
46855
|
addGetWixelJobStatusTool,
|
|
45987
46856
|
addGetWixelProjectAssetsTool,
|
|
46857
|
+
addGraphqlTools,
|
|
45988
46858
|
addImportClaudeDesignTool,
|
|
45989
46859
|
addListWixelEventsTool,
|
|
45990
46860
|
addMarkWixelJobAsFulfilledTool,
|
|
@@ -45994,6 +46864,7 @@ export {
|
|
|
45994
46864
|
addSendWixelMessageTool,
|
|
45995
46865
|
addSiteCreationWidgetTools,
|
|
45996
46866
|
addStartWixelSessionTool,
|
|
46867
|
+
addSuggestedDomainTool,
|
|
45997
46868
|
addSupportTool,
|
|
45998
46869
|
addWixSiteCreationTool,
|
|
45999
46870
|
addWixelSessionTools,
|
|
@@ -46018,6 +46889,7 @@ export {
|
|
|
46018
46889
|
mergeConfig,
|
|
46019
46890
|
normalizeMenuContent,
|
|
46020
46891
|
parseDirectChildren,
|
|
46892
|
+
resetGraphqlSchemaCache,
|
|
46021
46893
|
rethrowIfUnauthorized,
|
|
46022
46894
|
summarizeLargeMenu,
|
|
46023
46895
|
toWidget,
|