@wix/mcp 1.0.79 → 1.0.81
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 +1 -1
- package/build/bin-standalone.js +94 -36
- package/build/cjs/index.cjs +449 -459
- package/build/cjs/toolkit.cjs +112 -44
- package/build/dts/account-tools/get-profile-tool.d.ts +5 -0
- package/build/dts/account-tools/get-profile-tool.js +49 -0
- package/build/dts/api-call/index.js +41 -3
- package/build/dts/code-mode/index.js +8 -2
- package/build/dts/config/api-request-rules.d.ts +11 -0
- package/build/dts/config/api-request-rules.js +11 -0
- package/build/dts/config/default-config.d.ts +2 -2
- package/build/dts/config/default-config.js +19 -9
- package/build/dts/config/param-descriptions.d.ts +1 -1
- package/build/dts/config/param-descriptions.js +5 -3
- package/build/dts/docs/docs.js +6 -6
- package/build/dts/index.d.ts +1 -0
- package/build/dts/index.js +1 -0
- package/build/dts/infra/tool-bi.d.ts +1 -1
- package/build/dts/infra/tool-bi.js +3 -2
- package/build/dts/toolkit-entry.d.cts +3 -1
- package/build/dts/toolkit-entry.d.ts +3 -1
- package/build/dts/toolkit.d.ts +2 -0
- package/build/dts/toolkit.js +18 -21
- package/build/dts/wix-mcp-server.d.ts +2 -0
- package/build/dts/wix-mcp-server.js +4 -1
- package/build/dts/wixel/api.d.ts +0 -60
- package/build/dts/wixel/api.js +1 -50
- package/build/dts/wixel/constants.d.ts +0 -1
- package/build/dts/wixel/constants.js +0 -1
- package/build/dts/wixel/index.d.ts +0 -3
- package/build/dts/wixel/index.js +0 -9
- package/build/esm/index.js +367 -401
- package/build/esm/toolkit.js +112 -44
- package/package.json +4 -3
- package/build/dts/wixel/open-headless-wixel-project-tool.d.ts +0 -6
- package/build/dts/wixel/open-headless-wixel-project-tool.js +0 -84
- package/build/dts/wixel/pull-headless-wixel-job-tool.d.ts +0 -6
- package/build/dts/wixel/pull-headless-wixel-job-tool.js +0 -61
- package/build/dts/wixel/update-headless-wixel-job-tool.d.ts +0 -6
- package/build/dts/wixel/update-headless-wixel-job-tool.js +0 -106
package/README.md
CHANGED
|
@@ -122,7 +122,7 @@ Set logging output:
|
|
|
122
122
|
- `VELO`: Velo Documentation (`SearchWixVeloDocumentation`)
|
|
123
123
|
- `BUSINESS_SOLUTIONS`: Business solutions recipes (`WixBusinessFlowsDocumentation`)
|
|
124
124
|
- `CLI`: Wix CLI Documentation (`SearchWixCLIDocumentation`)
|
|
125
|
-
- `OVERVIEW`: Wix
|
|
125
|
+
- `OVERVIEW`: Wix Development Documentation (`SearchDevelopmentDocumentation`)
|
|
126
126
|
|
|
127
127
|
**Experimental Tools:**
|
|
128
128
|
|
package/build/bin-standalone.js
CHANGED
|
@@ -71550,6 +71550,9 @@ function rethrowIfUnauthorized(error2) {
|
|
|
71550
71550
|
}
|
|
71551
71551
|
}
|
|
71552
71552
|
|
|
71553
|
+
// src/config/api-request-rules.ts
|
|
71554
|
+
var ARRAY_QUERY_PARAMS_RULE = "Repeat array query params once per value: `?fieldsets=URL&fieldsets=RICH_CONTENT`. Do NOT comma-join values (`fieldsets=URL,RICH_CONTENT`), do NOT leave a trailing comma, and do NOT use a value the method schema does not list, even if a sibling method accepts it (draft posts have no `SEO` fieldset).";
|
|
71555
|
+
|
|
71553
71556
|
// src/config/default-config.ts
|
|
71554
71557
|
var AGENT_GOAL = dedent_default`
|
|
71555
71558
|
You are an agent that helps the user manage their Wix site.
|
|
@@ -71560,7 +71563,7 @@ var DISCOVERY_FLOWS = [
|
|
|
71560
71563
|
"- METHOD CODE EXAMPLE BASED: BrowseWixRESTDocsMenu() or SearchWixRESTDocumentation() -> find relevant method -> read method article using ReadFullDocsArticle() to get method code examples -> call API using CallWixSiteAPI() based on the method code examples",
|
|
71561
71564
|
"- FULL SCHEMA BASED: BrowseWixRESTDocsMenu() or SearchWixRESTDocumentation() -> find relevant method -> read method article using ReadFullDocsArticle() -> no method code examples found -> inspect the method schema using SearchWixAPISpec or ReadFullDocsMethodSchema -> call API using CallWixSiteAPI() based on the schema"
|
|
71562
71565
|
];
|
|
71563
|
-
function buildSystemReminderGuidelines(includeReadme) {
|
|
71566
|
+
function buildSystemReminderGuidelines(includeReadme, includeImageUploadGuidance) {
|
|
71564
71567
|
const exception = includeReadme ? "**Exception:** " : "";
|
|
71565
71568
|
const lines = [];
|
|
71566
71569
|
if (includeReadme) {
|
|
@@ -71572,9 +71575,13 @@ function buildSystemReminderGuidelines(includeReadme) {
|
|
|
71572
71575
|
);
|
|
71573
71576
|
}
|
|
71574
71577
|
lines.push(
|
|
71575
|
-
`${exception}If the user asks to list, show, or find their Wix sites, ${includeReadme ? "skip WixREADME and " : ""}call ListWixSites directly
|
|
71576
|
-
`${exception}If the user wants to upload local or attached image files to a Wix site, skip ${includeReadme ? "WixREADME and " : ""}all docs/schema/API flows \u2014 call UploadImageToWixSite directly. Do NOT use ExecuteWixAPI, SearchWixAPISpec, or any Media Manager REST API for image uploads.`
|
|
71578
|
+
`${exception}If the user asks to list, show, or find their Wix sites, ${includeReadme ? "skip WixREADME and " : ""}call ListWixSites directly.`
|
|
71577
71579
|
);
|
|
71580
|
+
if (includeImageUploadGuidance) {
|
|
71581
|
+
lines.push(
|
|
71582
|
+
`${exception}If the user wants to upload local or attached image files to a Wix site, skip ${includeReadme ? "WixREADME and " : ""}all docs/schema/API flows \u2014 call UploadImageToWixSite directly. Do NOT use ExecuteWixAPI, SearchWixAPISpec, or any Media Manager REST API for image uploads.`
|
|
71583
|
+
);
|
|
71584
|
+
}
|
|
71578
71585
|
if (includeReadme) {
|
|
71579
71586
|
lines.push(
|
|
71580
71587
|
"If the WixREADME tool is not available to you, you should use the other flows as described without using the WixREADME tool until the task is completed."
|
|
@@ -71601,9 +71608,15 @@ function buildSystemReminderFlows(includeReadme) {
|
|
|
71601
71608
|
lines.push(...DISCOVERY_FLOWS);
|
|
71602
71609
|
return lines.join("\n");
|
|
71603
71610
|
}
|
|
71604
|
-
var SYSTEM_REMINDER_GUIDELINES = buildSystemReminderGuidelines(
|
|
71605
|
-
|
|
71606
|
-
|
|
71611
|
+
var SYSTEM_REMINDER_GUIDELINES = buildSystemReminderGuidelines(
|
|
71612
|
+
true,
|
|
71613
|
+
true
|
|
71614
|
+
);
|
|
71615
|
+
function buildSystemReminder(includeReadme, includeImageUploadGuidance = true) {
|
|
71616
|
+
const guidelines = buildSystemReminderGuidelines(
|
|
71617
|
+
includeReadme,
|
|
71618
|
+
includeImageUploadGuidance
|
|
71619
|
+
);
|
|
71607
71620
|
const flows = buildSystemReminderFlows(includeReadme);
|
|
71608
71621
|
return dedent_default`
|
|
71609
71622
|
<agent-mandatory-instructions>
|
|
@@ -71661,11 +71674,13 @@ var EXECUTE_WIX_API_INTRO = dedent_default`
|
|
|
71661
71674
|
CODE CONTRACT:
|
|
71662
71675
|
- Pass an async function expression: \`async function() { ... }\` or \`async () => { ... }\`. Put every declaration, \`await\`, and \`return\` inside it, and do not invoke it yourself.
|
|
71663
71676
|
- Use only \`wix.request({ method, url, body })\` and in-memory JavaScript. Node.js modules, filesystem access, and downloadable-file creation are unavailable.
|
|
71677
|
+
- Do not minify the code. Put each object property on its own line, with spaces after colons and commas, and declare deep literals (request bodies, filters, patch lists) as a named \`const\` before use so each \`wix.request({ ... })\` argument stays short.
|
|
71664
71678
|
|
|
71665
71679
|
CONFIRM API CONTRACTS:
|
|
71666
71680
|
- Do not rely on memory for endpoints, methods, bodies, response paths, filters, enum values, or auth scope. Confirm every method from conversation-provided details, a complete matching docs example, or the schema/docs tools before executing.
|
|
71667
71681
|
- Prefer \`method.publicUrl\` from SearchWixAPISpec; never use \`method.servers[0]\`. Pass all supporting documentation URLs through \`sourceDocUrls\`.
|
|
71668
71682
|
- A response field is not automatically filterable or sortable. Use only capabilities declared for that exact query/search method. If an unsupported filter is unavoidable, fetch a bounded result set and filter it in code.
|
|
71683
|
+
- ${ARRAY_QUERY_PARAMS_RULE}
|
|
71669
71684
|
- Read-only probes may inspect state or resolve IDs. Never use speculative create/update/delete calls to discover request or response shapes, and never repeat a successful mutation merely to obtain more response data.
|
|
71670
71685
|
`;
|
|
71671
71686
|
var EXECUTE_WIX_API_OUTPUT_AND_ERRORS = dedent_default`
|
|
@@ -71681,6 +71696,7 @@ var ACCOUNT_SITE_EXECUTE_SCOPE = dedent_default`
|
|
|
71681
71696
|
SCOPE AND SITE TARGETING:
|
|
71682
71697
|
- Set \`scope: "site"\` for site-level APIs and \`scope: "account"\` for account-level APIs. Account-level acts on the account itself, or on sites as objects within it; anything that reads or writes inside a site is site-level.
|
|
71683
71698
|
- If \`scope\` is omitted it defaults to site when either the ExecuteWixAPI call or \`wix.request\` provides a \`siteId\`; otherwise it defaults to account.
|
|
71699
|
+
- Site-level calls need a site ID; there is no implicit current site. Before any \`scope: "site"\` call, pass the site's ID as the ExecuteWixAPI \`siteId\` parameter or per request. \`scope: "site"\` without a \`siteId\` fails.
|
|
71684
71700
|
- \`scope: "account"\` ignores any \`siteId\` you pass, so a site-level endpoint called that way fails.
|
|
71685
71701
|
- Authentication is injected automatically; never set Authorization, wix-site-id, or wix-account-id headers.
|
|
71686
71702
|
- For one named site, prefer GetSiteContext. If it is unavailable, resolve the exact site and perform the action in the same invocation.
|
|
@@ -71814,8 +71830,11 @@ var executeWixApiDescription = dedent_default`
|
|
|
71814
71830
|
|
|
71815
71831
|
${EXECUTE_WIX_API_MULTI_SITE_EXAMPLE}
|
|
71816
71832
|
`;
|
|
71817
|
-
function buildToolDescriptions(includeReadme) {
|
|
71818
|
-
const reminder = buildSystemReminder(
|
|
71833
|
+
function buildToolDescriptions(includeReadme, includeImageUploadGuidance = true) {
|
|
71834
|
+
const reminder = buildSystemReminder(
|
|
71835
|
+
includeReadme,
|
|
71836
|
+
includeImageUploadGuidance
|
|
71837
|
+
);
|
|
71819
71838
|
return {
|
|
71820
71839
|
WixREADME: dedent_default`
|
|
71821
71840
|
# Tool: WixREADME
|
|
@@ -71866,6 +71885,7 @@ function buildToolDescriptions(includeReadme) {
|
|
|
71866
71885
|
**Prefer this tool over CallWixSiteAPI for listing sites.** Call this tool directly — it already knows the correct API and handles everything needed. Only fall back to CallWixSiteAPI if the user needs advanced filtering or specific site details beyond what this tool provides.
|
|
71867
71886
|
${reminder}
|
|
71868
71887
|
`,
|
|
71888
|
+
get_profile: "Returns the authenticated user's email address",
|
|
71869
71889
|
GetSiteContext: dedent_default`
|
|
71870
71890
|
Fetches deep context for a specific Wix site and returns it as structured markdown.
|
|
71871
71891
|
|
|
@@ -71997,8 +72017,10 @@ function buildToolDescriptions(includeReadme) {
|
|
|
71997
72017
|
SearchBuildAppsDocumentation: dedent_default`
|
|
71998
72018
|
Searches the Wix Build Apps documentation.
|
|
71999
72019
|
`,
|
|
72000
|
-
|
|
72001
|
-
|
|
72020
|
+
SearchDevelopmentDocumentation: dedent_default`
|
|
72021
|
+
Broad Wix development documentation (platform concepts, developer guides, getting started). **Last resort — development tasks only.**
|
|
72022
|
+
Skip it entirely for general, business, support, or Wix-editor questions.
|
|
72023
|
+
Call it only after the specific search for your task returned nothing useful: \`SearchWixRESTDocumentation\` (REST), \`SearchWixSDKDocumentation\` (JS SDK), \`SearchWixCLIDocumentation\` (CLI), \`SearchBuildAppsDocumentation\` (apps), \`SearchWixHeadlessDocumentation\` (Headless), \`SearchWixWDSDocumentation\` (WDS). Never use it as a first search.
|
|
72002
72024
|
`,
|
|
72003
72025
|
SearchWixHeadlessDocumentation: dedent_default`
|
|
72004
72026
|
Searches the Wix Headless documentation.
|
|
@@ -72613,14 +72635,20 @@ function renderApps(apps, knownApps) {
|
|
|
72613
72635
|
}
|
|
72614
72636
|
function renderProperties(props) {
|
|
72615
72637
|
const sections = [];
|
|
72616
|
-
const
|
|
72617
|
-
if (props.language)
|
|
72618
|
-
if (props.locale?.country)
|
|
72619
|
-
|
|
72620
|
-
if (props.
|
|
72621
|
-
if (
|
|
72622
|
-
|
|
72623
|
-
|
|
72638
|
+
const regionalFormat = [];
|
|
72639
|
+
if (props.language) regionalFormat.push(`- Language: **${props.language}**`);
|
|
72640
|
+
if (props.locale?.country)
|
|
72641
|
+
regionalFormat.push(`- Locale region: **${props.locale.country}**`);
|
|
72642
|
+
if (props.timeZone) regionalFormat.push(`- Timezone: **${props.timeZone}**`);
|
|
72643
|
+
if (props.paymentCurrency)
|
|
72644
|
+
regionalFormat.push(`- Currency: **${props.paymentCurrency}**`);
|
|
72645
|
+
if (regionalFormat.length) {
|
|
72646
|
+
sections.push(`**Regional Format**
|
|
72647
|
+
${regionalFormat.join("\n")}`);
|
|
72648
|
+
}
|
|
72649
|
+
if (props.address?.country) {
|
|
72650
|
+
sections.push(`**Location**
|
|
72651
|
+
- Country: **${props.address.country}**`);
|
|
72624
72652
|
}
|
|
72625
72653
|
const contact = [];
|
|
72626
72654
|
if (props.email) contact.push(`- Email: **${props.email}**`);
|
|
@@ -72767,6 +72795,7 @@ var known_apps_default = {
|
|
|
72767
72795
|
"225dd912-7dea-4738-8688-4b8c6955ffc2": "Wix Forms",
|
|
72768
72796
|
"d80111c5-a0f4-47a8-b63a-65b54d774a27": "Wix Gift Cards",
|
|
72769
72797
|
"148c2287-c669-d849-d153-463c7486a694": "Wix Groups",
|
|
72798
|
+
"14bca956-e09f-f4d6-14d7-466cb3f09103": "Wix Hotels",
|
|
72770
72799
|
"13ee94c1-b635-8505-3391-97919052c16f": "Wix Invoices",
|
|
72771
72800
|
"14cc59bc-f0b7-15b8-e1c7-89ce41d0e0c9": "Wix Members Area",
|
|
72772
72801
|
"14d84998-ae09-1abf-c6fc-3f3cace5bf19": "Wix Multilingual",
|
|
@@ -72801,8 +72830,8 @@ async function getDynamicContext(auth, httpClient, filter, options) {
|
|
|
72801
72830
|
partnerContextEnabled: options,
|
|
72802
72831
|
includeAccountContext: options
|
|
72803
72832
|
} : options;
|
|
72804
|
-
const includePartnerContext = contextOptions?.partnerContextEnabled ??
|
|
72805
|
-
const includeAccountContext = contextOptions?.includeAccountContext ??
|
|
72833
|
+
const includePartnerContext = contextOptions?.partnerContextEnabled ?? true;
|
|
72834
|
+
const includeAccountContext = contextOptions?.includeAccountContext ?? true;
|
|
72806
72835
|
try {
|
|
72807
72836
|
const accountHeaders = await auth.getAccountAuthHeaders();
|
|
72808
72837
|
const noFilter = !filter?.siteId && !filter?.siteName;
|
|
@@ -72916,7 +72945,8 @@ var paramDescriptions = {
|
|
|
72916
72945
|
"The url of the api to call - ALWAYS get the API url from the Wix REST docs or from the conversation context, the URL MUST BE ABSOLUTE URL",
|
|
72917
72946
|
'NEVER guess the API url, ALWAYS get it from the conversation context, i.e from the user prompt or from the "WixREADME" tool or from the "SearchWixRESTDocumentation" tool or from the "BrowseWixRESTDocsMenu" tool or from the "ReadFullDocsArticle" tool',
|
|
72918
72947
|
`Allowed API urls are: ${ALLOWED_HOSTNAMES.join(", ")}`,
|
|
72919
|
-
`Docs urls like https://dev.wix.com/docs/... are not API urls, if you want to read the docs, use the "ReadFullDocsArticle" tool
|
|
72948
|
+
`Docs urls like https://dev.wix.com/docs/... are not API urls, if you want to read the docs, use the "ReadFullDocsArticle" tool`,
|
|
72949
|
+
ARRAY_QUERY_PARAMS_RULE
|
|
72920
72950
|
].join("\n"),
|
|
72921
72951
|
method: "The HTTP method to use for the API call (e.g. GET, POST, PUT, DELETE)",
|
|
72922
72952
|
body: 'The request body as a JSON object or array with all the required fields and values, including nested objects. Pass the actual value (object or array), NOT a JSON string. YOU MUST NEVER MAKE UP A BODY - the body should be based on the conversation context, i.e from the user prompt OR got into the conversation context by the "ReadFullDocsArticle" tool OR by the "SearchWixAPISpec" tool OR by the "ReadFullDocsMethodSchema" tool - i.e based on the API docs, a relevant recipe you read (preferably), a code example you found in the docs, a schema you read etc.. YOU MUST NEVER ASSUME YOU KNOW WHAT THE BODY SCHEMA IS WITHOUT CONCRETE EXAMPLES OR SCHEMA DEFINITIONS FROM THE CONVERSATION CONTEXT. Prefer reading relevant recipes if you have them in context for understand the body schema for API calls.',
|
|
@@ -72989,8 +73019,8 @@ var paramDescriptions = {
|
|
|
72989
73019
|
searchTerm: "The search term to search for in the Build Apps Documentation",
|
|
72990
73020
|
maxResults: "The maximum number of results to return, default is 10, max is 15"
|
|
72991
73021
|
},
|
|
72992
|
-
|
|
72993
|
-
searchTerm: "The search term
|
|
73022
|
+
SearchDevelopmentDocumentation: {
|
|
73023
|
+
searchTerm: "The development-related search term. Use only after a more specific docs search (REST/SDK/CLI/Build Apps/Headless/WDS) came back empty.",
|
|
72994
73024
|
maxResults: "The maximum number of results to return, default is 10, max is 15"
|
|
72995
73025
|
},
|
|
72996
73026
|
SearchWixHeadlessDocumentation: {
|
|
@@ -73797,15 +73827,15 @@ var addDocsTools = (server2, allowedTools = [
|
|
|
73797
73827
|
}
|
|
73798
73828
|
);
|
|
73799
73829
|
}
|
|
73800
|
-
if (allowedTools.includes("OVERVIEW") && !disableTools?.includes("
|
|
73830
|
+
if (allowedTools.includes("OVERVIEW") && !disableTools?.includes("SearchDevelopmentDocumentation")) {
|
|
73801
73831
|
server2.tool(
|
|
73802
|
-
"
|
|
73832
|
+
"SearchDevelopmentDocumentation",
|
|
73803
73833
|
getDescription(
|
|
73804
|
-
"
|
|
73805
|
-
defaultToolDescriptions.
|
|
73834
|
+
"SearchDevelopmentDocumentation",
|
|
73835
|
+
defaultToolDescriptions.SearchDevelopmentDocumentation ?? ""
|
|
73806
73836
|
),
|
|
73807
73837
|
(() => {
|
|
73808
|
-
const d = desc("
|
|
73838
|
+
const d = desc("SearchDevelopmentDocumentation");
|
|
73809
73839
|
return {
|
|
73810
73840
|
searchTerm: external_exports.string().describe(d.searchTerm),
|
|
73811
73841
|
maxResults: external_exports.number().describe(d.maxResults).min(1).max(15).optional().default(15)
|
|
@@ -73835,8 +73865,8 @@ var addDocsTools = (server2, allowedTools = [
|
|
|
73835
73865
|
panorama.errorMonitor().reportError(error2);
|
|
73836
73866
|
captureException(error2, {
|
|
73837
73867
|
tags: {
|
|
73838
|
-
componentId: "
|
|
73839
|
-
toolName: "
|
|
73868
|
+
componentId: "SearchDevelopmentDocumentation",
|
|
73869
|
+
toolName: "SearchDevelopmentDocumentation"
|
|
73840
73870
|
}
|
|
73841
73871
|
});
|
|
73842
73872
|
logger2.error(
|
|
@@ -85251,7 +85281,7 @@ function extractText(result) {
|
|
|
85251
85281
|
return result.content.filter((content) => content.type === "text" && content.text != null).map((content) => content.text).join("\n");
|
|
85252
85282
|
}
|
|
85253
85283
|
var TOOL_RESULT_PREVIEW_MAX_CHARS = 4e3;
|
|
85254
|
-
function formatToolResultAdditionalFields(result) {
|
|
85284
|
+
function formatToolResultAdditionalFields(result, extras) {
|
|
85255
85285
|
const resultText = extractText(result);
|
|
85256
85286
|
const contentTypes = [
|
|
85257
85287
|
...new Set(
|
|
@@ -85267,7 +85297,8 @@ function formatToolResultAdditionalFields(result) {
|
|
|
85267
85297
|
resultPreview: resultText.slice(0, TOOL_RESULT_PREVIEW_MAX_CHARS),
|
|
85268
85298
|
resultTextLength: resultText.length,
|
|
85269
85299
|
resultPreviewTruncated: resultText.length > TOOL_RESULT_PREVIEW_MAX_CHARS,
|
|
85270
|
-
resultContentTypes: contentTypes
|
|
85300
|
+
resultContentTypes: contentTypes,
|
|
85301
|
+
...extras
|
|
85271
85302
|
});
|
|
85272
85303
|
}
|
|
85273
85304
|
function createToolBiEvent(params) {
|
|
@@ -85440,7 +85471,10 @@ var WixMcpServer = class extends McpServer {
|
|
|
85440
85471
|
if (!toolSucceeded) {
|
|
85441
85472
|
errorBody = extractText(cbResult);
|
|
85442
85473
|
} else {
|
|
85443
|
-
additionalFields = formatToolResultAdditionalFields(cbResult
|
|
85474
|
+
additionalFields = formatToolResultAdditionalFields(cbResult, {
|
|
85475
|
+
returnedRows: toolBiParams.returnedRows,
|
|
85476
|
+
originalLength: toolBiParams.originalLength
|
|
85477
|
+
});
|
|
85444
85478
|
}
|
|
85445
85479
|
if (toolSucceeded && !isDevEnvironment) {
|
|
85446
85480
|
panorama.transaction(toolName).finish({ toolInvocationId });
|
|
@@ -85968,6 +86002,19 @@ var MAX_ALLOWED_RESPONSE_CHARS = 2e6;
|
|
|
85968
86002
|
|
|
85969
86003
|
// src/api-call/index.ts
|
|
85970
86004
|
var DEFAULT_MAX_RESPONSE_SIZE = 5e4;
|
|
86005
|
+
function extractReturnedRows(responseData) {
|
|
86006
|
+
if (responseData === null || typeof responseData !== "object") {
|
|
86007
|
+
return void 0;
|
|
86008
|
+
}
|
|
86009
|
+
const data = responseData;
|
|
86010
|
+
const block = data.pagingMetadata ?? data.cursorPagingMetadata ?? data.pagingOffsetMetadata ?? data.metaData ?? data.metadata;
|
|
86011
|
+
const raw = block?.count;
|
|
86012
|
+
if (typeof raw !== "number" && (typeof raw !== "string" || raw.trim() === "")) {
|
|
86013
|
+
return void 0;
|
|
86014
|
+
}
|
|
86015
|
+
const count2 = Number(raw);
|
|
86016
|
+
return Number.isFinite(count2) ? count2 : void 0;
|
|
86017
|
+
}
|
|
85971
86018
|
function formatApiResponse(responseData, maxResponseSize = DEFAULT_MAX_RESPONSE_SIZE) {
|
|
85972
86019
|
if (typeof responseData === "string" && responseData.trim().startsWith("<!DOCTYPE")) {
|
|
85973
86020
|
return {
|
|
@@ -85975,13 +86022,15 @@ function formatApiResponse(responseData, maxResponseSize = DEFAULT_MAX_RESPONSE_
|
|
|
85975
86022
|
isError: true
|
|
85976
86023
|
};
|
|
85977
86024
|
}
|
|
86025
|
+
const returnedRows = extractReturnedRows(responseData);
|
|
85978
86026
|
let responseText = JSON.stringify(responseData);
|
|
86027
|
+
const originalLength = responseText.length;
|
|
85979
86028
|
const effectiveMax = Math.min(maxResponseSize, MAX_ALLOWED_RESPONSE_CHARS);
|
|
85980
86029
|
if (responseText.length > effectiveMax) {
|
|
85981
86030
|
responseText = responseText.slice(0, effectiveMax) + `
|
|
85982
86031
|
...[TRUNCATED - response was ${responseText.length} chars, showing first ${effectiveMax}]`;
|
|
85983
86032
|
}
|
|
85984
|
-
return { text: responseText, isError: false };
|
|
86033
|
+
return { text: responseText, isError: false, originalLength, returnedRows };
|
|
85985
86034
|
}
|
|
85986
86035
|
function addApiCallTool(server2, strategy, allowedTools = ["CallWixSiteAPI", "ListWixSites", "ManageWixSite"], disableTools = [], enableTools = [], toolDescriptions, toolHints, maxResponseSize) {
|
|
85987
86036
|
const effectiveAllowedTools = [
|
|
@@ -86044,9 +86093,14 @@ function addApiCallTool(server2, strategy, allowedTools = ["CallWixSiteAPI", "Li
|
|
|
86044
86093
|
data: method === "GET" ? void 0 : body
|
|
86045
86094
|
});
|
|
86046
86095
|
const requestId = response.headers?.["x-wix-request-id"];
|
|
86047
|
-
setToolBiParams({ requestId, siteId });
|
|
86048
86096
|
const responseData = await handleWixAPIResponse(response);
|
|
86049
86097
|
const formatted = formatApiResponse(responseData, maxResponseSize);
|
|
86098
|
+
setToolBiParams({
|
|
86099
|
+
requestId,
|
|
86100
|
+
siteId,
|
|
86101
|
+
returnedRows: formatted.returnedRows,
|
|
86102
|
+
originalLength: formatted.originalLength
|
|
86103
|
+
});
|
|
86050
86104
|
if (formatted.isError) {
|
|
86051
86105
|
return {
|
|
86052
86106
|
content: [
|
|
@@ -86185,7 +86239,7 @@ function addApiCallTool(server2, strategy, allowedTools = ["CallWixSiteAPI", "Li
|
|
|
86185
86239
|
destructiveHint: true,
|
|
86186
86240
|
openWorldHint: false
|
|
86187
86241
|
}),
|
|
86188
|
-
async ({ url, body, method, reason }, { httpClient }) => {
|
|
86242
|
+
async ({ url, body, method, reason }, { httpClient, setToolBiParams }) => {
|
|
86189
86243
|
logger2.log(
|
|
86190
86244
|
`Calling Wix Account level API: ${url}, reason="${reason}", body: ${JSON.stringify(body)}`
|
|
86191
86245
|
);
|
|
@@ -86214,6 +86268,10 @@ function addApiCallTool(server2, strategy, allowedTools = ["CallWixSiteAPI", "Li
|
|
|
86214
86268
|
});
|
|
86215
86269
|
const responseData = await handleWixAPIResponse(response);
|
|
86216
86270
|
const formatted = formatApiResponse(responseData, maxResponseSize);
|
|
86271
|
+
setToolBiParams({
|
|
86272
|
+
returnedRows: formatted.returnedRows,
|
|
86273
|
+
originalLength: formatted.originalLength
|
|
86274
|
+
});
|
|
86217
86275
|
if (formatted.isError) {
|
|
86218
86276
|
return {
|
|
86219
86277
|
content: [
|