@wix/ditto-codegen-public 1.0.55 → 1.0.57

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (2) hide show
  1. package/dist/out.js +1274 -113
  2. package/package.json +2 -2
package/dist/out.js CHANGED
@@ -77776,6 +77776,32 @@ var require_data = __commonJS({
77776
77776
  }
77777
77777
  });
77778
77778
 
77779
+ // dist/system-prompts/apiDocLoader.js
77780
+ var require_apiDocLoader = __commonJS({
77781
+ "dist/system-prompts/apiDocLoader.js"(exports2) {
77782
+ "use strict";
77783
+ Object.defineProperty(exports2, "__esModule", { value: true });
77784
+ exports2.loadApiDocumentation = loadApiDocumentation;
77785
+ var docLoader_1 = require_docLoader();
77786
+ var API_TO_DOC_MAPPING = {
77787
+ "stores.productsV3.updateProduct": "stores-productsV3-updateProduct-doc.txt",
77788
+ "stores.products.onProductCreated": "stores-productV3-onProductCreated-doc.txt",
77789
+ "data.items.onDataItemCreated": "data-items-onDataItemCreated.txt",
77790
+ "crm.contacts.onContactCreated": "crm-contacts-onContactCreated-doc.txt",
77791
+ "ecom.cart.onCartCreated": "ecom-cart-onCartCreated-doc.txt",
77792
+ "ecom.cart.onCartUpdated": "ecom-cart-onCartUpdated-doc.txt"
77793
+ };
77794
+ function loadApiDocumentation(apiNames) {
77795
+ const apiDocs = (0, docLoader_1.loadDocumentation)(apiNames, API_TO_DOC_MAPPING, docLoader_1.DocType.API);
77796
+ return apiDocs ? `
77797
+ <api_docs>
77798
+ ${apiDocs}
77799
+ </api_docs>
77800
+ ` : "";
77801
+ }
77802
+ }
77803
+ });
77804
+
77779
77805
  // dist/system-prompts/servicePlugin/servicePluginPrompt.js
77780
77806
  var require_servicePluginPrompt = __commonJS({
77781
77807
  "dist/system-prompts/servicePlugin/servicePluginPrompt.js"(exports2) {
@@ -77785,8 +77811,10 @@ var require_servicePluginPrompt = __commonJS({
77785
77811
  exports2.getServicePluginPrompt = getServicePluginPrompt;
77786
77812
  var servicePluginDocLoader_1 = require_servicePluginDocLoader();
77787
77813
  var data_1 = require_data();
77788
- function getServicePluginPrompt(spiNames = [], useData = false) {
77814
+ var apiDocLoader_1 = require_apiDocLoader();
77815
+ function getServicePluginPrompt(spiNames = [], useData = false, apiNames = []) {
77789
77816
  const servicePluginDocs = (0, servicePluginDocLoader_1.loadServicePluginDocumentation)(spiNames);
77817
+ const apiDocs = (0, apiDocLoader_1.loadApiDocumentation)(apiNames);
77790
77818
  return `
77791
77819
  <WIXCLI_SERVICE_PLUGIN_SYSTEM_PROMPT>
77792
77820
 
@@ -77899,7 +77927,7 @@ When integrating with external services:
77899
77927
  <available_service_plugins>
77900
77928
  ${servicePluginDocs}
77901
77929
  </available_service_plugins>
77902
-
77930
+ ${apiDocs}
77903
77931
  ${useData ? data_1.dataPrompt : ""}
77904
77932
  `;
77905
77933
  }
@@ -120290,27 +120318,6 @@ var require_index_node = __commonJS({
120290
120318
  }
120291
120319
  });
120292
120320
 
120293
- // dist/system-prompts/apiDocLoader.js
120294
- var require_apiDocLoader = __commonJS({
120295
- "dist/system-prompts/apiDocLoader.js"(exports2) {
120296
- "use strict";
120297
- Object.defineProperty(exports2, "__esModule", { value: true });
120298
- exports2.loadApiDocumentation = loadApiDocumentation;
120299
- var docLoader_1 = require_docLoader();
120300
- var API_TO_DOC_MAPPING = {
120301
- "stores.productsV3.updateProduct": "stores-productsV3-updateProduct-doc.txt",
120302
- "stores.products.onProductCreated": "stores-productV3-onProductCreated-doc.txt",
120303
- "data.items.onDataItemCreated": "data-items-onDataItemCreated.txt",
120304
- "crm.contacts.onContactCreated": "crm-contacts-onContactCreated-doc.txt",
120305
- "ecom.cart.onCartCreated": "ecom-cart-onCartCreated-doc.txt",
120306
- "ecom.cart.onCartUpdated": "ecom-cart-onCartUpdated-doc.txt"
120307
- };
120308
- function loadApiDocumentation(apiNames) {
120309
- return (0, docLoader_1.loadDocumentation)(apiNames, API_TO_DOC_MAPPING, docLoader_1.DocType.API);
120310
- }
120311
- }
120312
- });
120313
-
120314
120321
  // dist/agents/utils.js
120315
120322
  var require_utils14 = __commonJS({
120316
120323
  "dist/agents/utils.js"(exports2) {
@@ -120325,7 +120332,6 @@ var require_utils14 = __commonJS({
120325
120332
  var http_client_1 = require_index_node();
120326
120333
  var fs_1 = __importDefault2(require("fs"));
120327
120334
  var path_1 = __importDefault2(require("path"));
120328
- var apiDocLoader_1 = require_apiDocLoader();
120329
120335
  exports2.FileItemSchema = zod_1.z.object({
120330
120336
  operation: zod_1.z.enum(["insert", "update", "delete"]).describe("File operation: insert (new file), update (modify existing), delete (remove file)").default("insert"),
120331
120337
  path: zod_1.z.string().describe("Relative file path from project root").optional(),
@@ -120433,13 +120439,6 @@ ${JSON.stringify(planAndResources.apiSpec, null, 2)}`);
120433
120439
  contextSections.push(`
120434
120440
  ## EMBEDDED SCRIPT PARAMETERS
120435
120441
  ${JSON.stringify(planAndResources.embeddedScriptParameters, null, 2)}`);
120436
- }
120437
- if (extension.relatedApis?.length) {
120438
- const apiNames = (0, exports2.extractApiNames)(params.extension);
120439
- const apiDocs = (0, apiDocLoader_1.loadApiDocumentation)(apiNames);
120440
- contextSections.push(`
120441
- ## RELATED APIS
120442
- ${apiDocs}`);
120443
120442
  }
120444
120443
  const userMessage = `${primaryAction}:
120445
120444
  ${contextSections.join("\n")}`;
@@ -120747,15 +120746,16 @@ var require_SPIAgent = __commonJS({
120747
120746
  this.apiKey = apiKey;
120748
120747
  this.name = "SPIAgent";
120749
120748
  }
120750
- buildSystemPrompt(spiNames = [], useData = false) {
120751
- return (0, servicePluginPrompt_1.getServicePluginPrompt)(spiNames, useData);
120749
+ buildSystemPrompt(spiNames = [], useData = false, apiNames = []) {
120750
+ return (0, servicePluginPrompt_1.getServicePluginPrompt)(spiNames, useData, apiNames);
120752
120751
  }
120753
120752
  async generate(params) {
120754
120753
  const { extension, blueprint, planAndResources } = params;
120755
120754
  const examples = (0, load_examples_1.loadExamples)([load_examples_1.types.ServicePluginExtension]);
120756
120755
  const allSpiNames = extension.relatedSpis?.map((spi) => spi.name).filter((name) => !!name) || [];
120756
+ const apiNames = (0, utils_1.extractApiNames)(params.extension);
120757
120757
  const useData = Boolean(planAndResources?.createdCollections?.length);
120758
- const systemPrompt = `${this.buildSystemPrompt(allSpiNames, useData)}
120758
+ const systemPrompt = `${this.buildSystemPrompt(allSpiNames, useData, apiNames)}
120759
120759
  ${examples}
120760
120760
  `;
120761
120761
  console.log(`SPI Agent System Prompt length: ${systemPrompt.length} (is that what you expect?)`);
@@ -121273,7 +121273,7 @@ var require_planner = __commonJS({
121273
121273
  <WIXCLI_PLANNER_SYSTEM_PROMPT>
121274
121274
  ${(0, data_1.cmsPlannerPrompt)()}
121275
121275
 
121276
- ${hasBackendApiExtensions ? (0, apiSpec_1.apiSpecPrompt)() : "No backend API extensions in the blueprint, return an empty object: {}"}
121276
+ ${hasBackendApiExtensions ? (0, apiSpec_1.apiSpecPrompt)() : "No backend API extensions in the blueprint, don't return anything for apiSpec"}
121277
121277
 
121278
121278
  ${hasEmbeddedScriptExtensions ? (0, dynamicParameters_1.dynamicParametersPrompt)() : 'No embeddedScriptParameters needed, no embedded scripts in the blueprint, return an empty array: "embeddedScriptParameters": []'}
121279
121279
  </WIXCLI_PLANNER_SYSTEM_PROMPT>
@@ -123279,7 +123279,7 @@ var require_PlannerAgent = __commonJS({
123279
123279
  exports2.PlannerOutputSchema = zod_1.z.object({
123280
123280
  collections: zod_1.z.array(CMSAgent_1.CmsCollectionSchema).default([]).describe("CMS collections to be created for the app"),
123281
123281
  embeddedScriptParameters: zod_1.z.array(EmbeddedScriptSchema_1.EmbeddedScriptParametersSchema).default([]).describe("Dynamic parameters for embedded script extensions (empty array if no embedded scripts)"),
123282
- apiSpec: ApiSpecSchema_1.ApiSpecSchema.optional().describe("API specification for the app")
123282
+ apiSpec: ApiSpecSchema_1.ApiSpecSchema.optional().describe("API specification for the app, don't return anything if no backend API extensions")
123283
123283
  });
123284
123284
  var PlannerAgent = class {
123285
123285
  constructor(apiKey) {
@@ -125000,7 +125000,9 @@ var require_backendEventPrompt = __commonJS({
125000
125000
  "use strict";
125001
125001
  Object.defineProperty(exports2, "__esModule", { value: true });
125002
125002
  exports2.backendEventPrompt = void 0;
125003
- var backendEventPrompt = () => {
125003
+ var apiDocLoader_1 = require_apiDocLoader();
125004
+ var backendEventPrompt = (apiNames) => {
125005
+ const apiDocs = (0, apiDocLoader_1.loadApiDocumentation)(apiNames);
125004
125006
  return `<BACKEND_EVENT_PROMPT>
125005
125007
  <role>
125006
125008
  You are a Wix backend event handler generator. Create event extensions for Wix CLI apps using the JavaScript SDK. Events are triggered when specific conditions on the app or user's site are met.
@@ -125034,6 +125036,7 @@ You are a Wix backend event handler generator. Create event extensions for Wix C
125034
125036
  - Reference the corresponding SDK submodule category for event-specific information
125035
125037
  - Events run automatically when triggered - no manual invocation needed
125036
125038
  </implementation_guidelines>
125039
+ ${apiDocs}
125037
125040
  </BACKEND_EVENT_PROMPT>`;
125038
125041
  };
125039
125042
  exports2.backendEventPrompt = backendEventPrompt;
@@ -125093,13 +125096,14 @@ var require_BackendEventAgent = __commonJS({
125093
125096
  this.apiKey = apiKey;
125094
125097
  this.name = "BackendEventAgent";
125095
125098
  }
125096
- buildSystemPrompt() {
125097
- return (0, backendEventPrompt_1.backendEventPrompt)();
125099
+ buildSystemPrompt(apiNames = []) {
125100
+ return (0, backendEventPrompt_1.backendEventPrompt)(apiNames);
125098
125101
  }
125099
125102
  async generate(params) {
125100
125103
  const { blueprint } = params;
125101
125104
  const examples = (0, load_examples_1.default)([load_examples_1.types.BackendEvent]);
125102
- const systemPrompt = `${this.buildSystemPrompt()}
125105
+ const allApiNames = (0, utils_1.extractApiNames)(params.extension);
125106
+ const systemPrompt = `${this.buildSystemPrompt(allApiNames)}
125103
125107
  ${examples}
125104
125108
  `;
125105
125109
  const appName = blueprint?.appName ? `'${blueprint.appName}'` : "";
@@ -127101,6 +127105,7 @@ var require_dashboardPagePrompt = __commonJS({
127101
127105
  var data_1 = require_data3();
127102
127106
  var apiSpecPrompt_1 = require_apiSpecPrompt();
127103
127107
  var dynamicParameters_1 = require_dynamicParameters2();
127108
+ var apiDocLoader_1 = require_apiDocLoader();
127104
127109
  var wdsPackage_2 = require_wdsPackage();
127105
127110
  Object.defineProperty(exports2, "buildWdsSystemPrompt", { enumerable: true, get: function() {
127106
127111
  return wdsPackage_2.buildWdsSystemPrompt;
@@ -127130,8 +127135,9 @@ var require_dashboardPagePrompt = __commonJS({
127130
127135
  "ToggleSwitch",
127131
127136
  "InfoIcon"
127132
127137
  ];
127133
- var dashboardPagePrompt = async ({ useData, useApiSpec, useDynamicParameters }) => {
127138
+ var dashboardPagePrompt = async ({ useData, useApiSpec, useDynamicParameters, apiNames }) => {
127134
127139
  const wdsPrompt = await (0, wdsPackage_1.buildWdsSystemPrompt)(listOfWdsComponents);
127140
+ const apiDocs = (0, apiDocLoader_1.loadApiDocumentation)(apiNames);
127135
127141
  return `
127136
127142
  <WIXCLI_DASHBOARD_PAGE_SYSTEM_PROMPT>
127137
127143
 
@@ -127196,7 +127202,7 @@ You are tasked with generating a complete Wix CLI dashboard page implementation
127196
127202
  ${dashboardPackage_1.dashboardPackage}
127197
127203
  ${ecomPackage_1.ecomPackage}
127198
127204
  </api_references>
127199
-
127205
+ ${apiDocs}
127200
127206
  <wds_reference>
127201
127207
  ${wdsPrompt}
127202
127208
  </wds_reference>
@@ -127247,7 +127253,8 @@ var require_DashboardPageAgent = __commonJS({
127247
127253
  const useData = Boolean(planAndResources?.createdCollections?.length);
127248
127254
  const useApiSpec = Boolean(planAndResources?.apiSpec);
127249
127255
  const useDynamicParameters = Boolean(planAndResources?.embeddedScriptParameters?.length);
127250
- const systemPrompt = `${await this.buildSystemPrompt({ useData, useApiSpec, useDynamicParameters })}
127256
+ const apiNames = (0, utils_1.extractApiNames)(params.extension);
127257
+ const systemPrompt = `${await this.buildSystemPrompt({ useData, useApiSpec, useDynamicParameters, apiNames })}
127251
127258
  ${examples}
127252
127259
  `;
127253
127260
  console.log(`Dashboard Agent System Prompt length: ${systemPrompt.length} (is that what you expect?)`);
@@ -128154,90 +128161,1142 @@ export default withDashboard(CollectionPage);
128154
128161
  }
128155
128162
  });
128156
128163
 
128157
- // dist/system-prompts/embeddedScript/embededScript.js
128158
- var require_embededScript = __commonJS({
128159
- "dist/system-prompts/embeddedScript/embededScript.js"(exports2) {
128164
+ // dist/system-prompts/SDK/ecom/cart.js
128165
+ var require_cart = __commonJS({
128166
+ "dist/system-prompts/SDK/ecom/cart.js"(exports2) {
128160
128167
  "use strict";
128161
128168
  Object.defineProperty(exports2, "__esModule", { value: true });
128162
- exports2.embeddedScriptPrompt = void 0;
128163
- var embeddedScriptPrompt = (hasDynamicParameters) => {
128164
- return `
128165
- <WIXCLI_EMBEDDED_SCRIPT_SYSTEM_PROMPT>
128169
+ exports2.cartPrompt = void 0;
128170
+ var cartPrompt = () => `
128171
+ <ecom_cart_docs>
128166
128172
 
128167
- <role>
128168
- You are a senior Wix CLI App Developer Expert specialized in creating embedded scripts for Wix applications. You have deep knowledge of embedded script best practices, HTML/JavaScript injection patterns, and third-party integrations.
128173
+ <description>
128174
+ This is a comprehensive reference guide for the Wix Ecom Current Cart SDK.
128175
+ The cart is the first phase of a purchase, followed by checkout, then order.
128176
+ The current cart is the cart that is currently being used by the site visitor or logged-in member.
128177
+
128178
+ CRITICAL FOR EMBEDDED SCRIPTS:
128179
+ - Embedded scripts MUST use the @wix/ecom SDK directly - DO NOT create fetch() calls to arbitrary API endpoints
128180
+ - Import the currentCart module from '@wix/ecom' directly in your embedded script
128181
+ - NEVER create fetch() calls to /api/* endpoints for cart operations unless those endpoints are explicitly defined in the API spec
128182
+ - Use currentCart.getCurrentCart() and other cart methods directly in embedded script code
128183
+ </description>
128169
128184
 
128170
- You are tasked with generating a complete Wix CLI embedded script implementation based on the user's requirements.
128171
- </role>
128185
+ <introduction>
128186
+ # About the eCommerce Current Cart API
128172
128187
 
128173
- <embedded_script_extension_files_and_code>
128188
+ A cart holds information about purchased items, prices, discounts, site details, buyer IDs (contact and member/visitor) and more.
128189
+
128190
+ With the eCommerce Cart API you can:
128191
+ - Get the current cart
128192
+ - Add items to the current cart
128193
+ - Create a checkout from the current cart
128194
+ - Estimate the price totals for the current cart
128195
+ - Update the properties of the current cart
128196
+ - Update the quantity of line items in the current cart
128197
+ - Remove a coupon from the current cart
128198
+ - Remove line items from the current cart
128199
+ - Delete the current cart
128200
+
128201
+ You can also listen for events when a cart is created, updated, and deleted.
128202
+
128203
+ </introduction>
128204
+
128205
+ <type_signatures>
128206
+ # Method Signatures & Types
128207
+
128208
+ ## getCurrentCart()
128209
+ \`\`\`typescript
128210
+ function getCurrentCart(): Promise<Cart>
128211
+ \`\`\`
128212
+ **Returns:** Promise<Cart> - The current visitor's cart object
128213
+
128214
+ ## addToCurrentCart(options)
128215
+ \`\`\`typescript
128216
+ function addToCurrentCart(options: AddToCurrentCartOptions): Promise<AddToCartResponse>
128217
+
128218
+ interface AddToCurrentCartOptions {
128219
+ lineItems?: Array<{
128220
+ catalogReference: {
128221
+ appId: string; // Required
128222
+ catalogItemId: string; // Required
128223
+ options?: Record<string, any>;
128224
+ };
128225
+ quantity: number; // Required
128226
+ catalogOverrideFields?: object;
128227
+ extendedFields?: object;
128228
+ }>;
128229
+ customLineItems?: Array<CustomLineItem>;
128230
+ businessLocationId?: string;
128231
+ }
128232
+ \`\`\`
128233
+ **Returns:** Promise<{cart: Cart}> - Response containing the updated cart
128234
+
128235
+ ## createCheckoutFromCurrentCart(options)
128236
+ \`\`\`typescript
128237
+ function createCheckoutFromCurrentCart(options: CreateCheckoutFromCurrentCartOptions): Promise<CreateCheckoutResponse>
128238
+
128239
+ interface CreateCheckoutFromCurrentCartOptions {
128240
+ channelType: ChannelType; // Required: "WEB", "POS", "EBAY", etc.
128241
+ email?: string;
128242
+ shippingAddress?: Address;
128243
+ billingAddress?: Address;
128244
+ selectedShippingOption?: SelectedShippingOption;
128245
+ }
128246
+ \`\`\`
128247
+ **Returns:** Promise<{checkoutId: string}> - The created checkout ID
128248
+
128249
+ ## estimateCurrentCartTotals(options)
128250
+ \`\`\`typescript
128251
+ function estimateCurrentCartTotals(options?: EstimateCurrentCartTotalsOptions): Promise<EstimateTotalsResponse>
128252
+
128253
+ interface EstimateCurrentCartTotalsOptions {
128254
+ selectedShippingOption?: SelectedShippingOption;
128255
+ shippingAddress?: Address;
128256
+ billingAddress?: Address;
128257
+ calculateShipping?: boolean; // Default: true
128258
+ calculateTax?: boolean; // Default: true
128259
+ selectedMemberships?: SelectedMemberships;
128260
+ }
128261
+ \`\`\`
128262
+ **Returns:** Promise<EstimateTotalsResponse> - Price totals, shipping info, tax summary
128263
+
128264
+ ## updateCurrentCart(options)
128265
+ \`\`\`typescript
128266
+ function updateCurrentCart(options: UpdateCurrentCartOptions): Promise<Cart>
128267
+
128268
+ interface UpdateCurrentCartOptions {
128269
+ cartInfo?: {
128270
+ buyerNote?: string;
128271
+ buyerInfo?: BuyerInfo;
128272
+ contactInfo?: AddressWithContact;
128273
+ selectedShippingOption?: SelectedShippingOption;
128274
+ extendedFields?: ExtendedFields;
128275
+ businessLocationId?: string;
128276
+ overrideCheckoutUrl?: string;
128277
+ };
128278
+ lineItems?: Array<LineItem>;
128279
+ customLineItems?: Array<CustomLineItem>;
128280
+ couponCode?: string;
128281
+ }
128282
+ \`\`\`
128283
+ **Returns:** Promise<Cart> - The updated cart object
128284
+
128285
+ ## updateCurrentCartLineItemQuantity(lineItems)
128286
+ \`\`\`typescript
128287
+ function updateCurrentCartLineItemQuantity(lineItems: Array<LineItemQuantityUpdate>): Promise<UpdateLineItemsQuantityResponse>
128288
+
128289
+ interface LineItemQuantityUpdate {
128290
+ _id: string; // Required: Line item ID
128291
+ quantity: number; // Required: New quantity (min: 1)
128292
+ }
128293
+ \`\`\`
128294
+ **Returns:** Promise<{cart: Cart}> - Response containing the updated cart
128295
+
128296
+ ## removeCouponFromCurrentCart()
128297
+ \`\`\`typescript
128298
+ function removeCouponFromCurrentCart(): Promise<RemoveCouponResponse>
128299
+ \`\`\`
128300
+ **Returns:** Promise<{cart: Cart}> - Response containing the updated cart
128301
+
128302
+ ## removeLineItemsFromCurrentCart(lineItemIds)
128303
+ \`\`\`typescript
128304
+ function removeLineItemsFromCurrentCart(lineItemIds: Array<string>): Promise<RemoveLineItemsResponse>
128305
+ \`\`\`
128306
+ **Parameters:**
128307
+ - lineItemIds: Array<string> - Required. IDs of line items to remove
128308
+
128309
+ **Returns:** Promise<{cart: Cart}> - Response containing the updated cart
128310
+
128311
+ ## deleteCurrentCart()
128312
+ \`\`\`typescript
128313
+ function deleteCurrentCart(): Promise<void>
128314
+ \`\`\`
128315
+ **Returns:** Promise<void> - No return value
128316
+
128317
+ ## Event Handlers
128318
+
128319
+ ### onCartCreated(handler)
128320
+ \`\`\`typescript
128321
+ function onCartCreated(handler: (event: CartEvent) => void): void
128322
+
128323
+ interface CartEvent {
128324
+ entity: Cart;
128325
+ metadata: EventMetadata;
128326
+ }
128327
+ \`\`\`
128328
+
128329
+ ### onCartUpdated(handler)
128330
+ \`\`\`typescript
128331
+ function onCartUpdated(handler: (event: CartEvent) => void): void
128332
+ \`\`\`
128333
+
128334
+ ### onCartDeleted(handler)
128335
+ \`\`\`typescript
128336
+ function onCartDeleted(handler: (event: DeletedCartEvent) => void): void
128337
+
128338
+ interface DeletedCartEvent {
128339
+ metadata: {
128340
+ entityId: string;
128341
+ eventTime: string;
128342
+ };
128343
+ }
128344
+ \`\`\`
128345
+
128346
+ ## Common Types
128347
+
128348
+ ### Cart Object
128349
+ \`\`\`typescript
128350
+ interface Cart {
128351
+ _id: string;
128352
+ _createdDate: Date;
128353
+ _updatedDate: Date;
128354
+ lineItems: Array<LineItem>;
128355
+ buyerInfo?: BuyerInfo;
128356
+ currency: string;
128357
+ conversionCurrency: string;
128358
+ paymentCurrency: string;
128359
+ subtotal: MultiCurrencyPrice;
128360
+ appliedDiscounts?: Array<CartDiscount>;
128361
+ taxIncludedInPrices: boolean;
128362
+ weightUnit: "KG" | "LB";
128363
+ buyerLanguage: string;
128364
+ siteLanguage: string;
128365
+ checkoutId?: string;
128366
+ purchaseFlowId: string;
128367
+ // ... additional fields
128368
+ }
128369
+ \`\`\`
128370
+
128371
+ ### LineItem Object
128372
+ \`\`\`typescript
128373
+ interface LineItem {
128374
+ _id: string;
128375
+ quantity: number;
128376
+ catalogReference: {
128377
+ appId: string;
128378
+ catalogItemId: string;
128379
+ options?: Record<string, any>;
128380
+ };
128381
+ productName: {
128382
+ original: string;
128383
+ translated?: string;
128384
+ };
128385
+ price: MultiCurrencyPrice;
128386
+ fullPrice: MultiCurrencyPrice;
128387
+ priceBeforeDiscounts: MultiCurrencyPrice;
128388
+ lineItemPrice: MultiCurrencyPrice;
128389
+ image?: string;
128390
+ url?: string;
128391
+ availability?: ItemAvailabilityInfo;
128392
+ physicalProperties?: PhysicalProperties;
128393
+ itemType: ItemType;
128394
+ // ... additional fields
128395
+ }
128396
+ \`\`\`
128397
+
128398
+ ### Address Object
128399
+ \`\`\`typescript
128400
+ interface Address {
128401
+ addressLine1?: string;
128402
+ addressLine2?: string;
128403
+ city?: string;
128404
+ country?: string; // ISO-3166 alpha-2 format
128405
+ subdivision?: string; // ISO 3166-2 format
128406
+ postalCode?: string;
128407
+ streetAddress?: {
128408
+ name?: string;
128409
+ number?: string;
128410
+ };
128411
+ }
128412
+ \`\`\`
128413
+
128414
+ ### MultiCurrencyPrice Object
128415
+ \`\`\`typescript
128416
+ interface MultiCurrencyPrice {
128417
+ amount: string;
128418
+ convertedAmount: string;
128419
+ formattedAmount: string;
128420
+ formattedConvertedAmount: string;
128421
+ }
128422
+ \`\`\`
128423
+
128424
+ ### CartDiscount Object
128425
+ \`\`\`typescript
128426
+ interface CartDiscount {
128427
+ coupon?: {
128428
+ _id: string;
128429
+ code: string;
128430
+ };
128431
+ merchantDiscount?: {
128432
+ amount: MultiCurrencyPrice;
128433
+ };
128434
+ }
128435
+ \`\`\`
128436
+
128437
+ ### BuyerInfo Object
128438
+ \`\`\`typescript
128439
+ interface BuyerInfo {
128440
+ contactId?: string;
128441
+ email?: string;
128442
+ memberId?: string; // If buyer is a site member
128443
+ userId?: string; // If buyer is a Wix user
128444
+ visitorId?: string; // If buyer is not a site member
128445
+ }
128446
+ \`\`\`
128447
+
128448
+ **Getting User ID:**
128449
+ To get the user's ID, use \`getCurrentCart()\` and access the \`buyerInfo\` object. The user will have one of three ID types:
128450
+ - \`buyerInfo.memberId\` - Present when the buyer is a logged-in site member
128451
+ - \`buyerInfo.userId\` - Present when the buyer is a Wix user (cart owner)
128452
+ - \`buyerInfo.visitorId\` - Present when the buyer is an anonymous visitor (not logged in)
128453
+
128454
+ Example:
128455
+ \`\`\`javascript
128456
+ const cart = await currentCart.getCurrentCart();
128457
+ const userId = cart.buyerInfo?.memberId || cart.buyerInfo?.userId || cart.buyerInfo?.visitorId;
128458
+ \`\`\`
128459
+
128460
+ ### ItemAvailabilityInfo Object
128461
+ \`\`\`typescript
128462
+ interface ItemAvailabilityInfo {
128463
+ status: "AVAILABLE" | "NOT_AVAILABLE" | "NOT_FOUND" | "PARTIALLY_AVAILABLE";
128464
+ quantityAvailable?: number;
128465
+ }
128466
+ \`\`\`
128467
+
128468
+ ### PhysicalProperties Object
128469
+ \`\`\`typescript
128470
+ interface PhysicalProperties {
128471
+ sku?: string;
128472
+ shippable?: boolean;
128473
+ weight?: number; // Measurement unit matches weightUnit in cart
128474
+ }
128475
+ \`\`\`
128476
+
128477
+ ### ItemType Object
128478
+ \`\`\`typescript
128479
+ interface ItemType {
128480
+ preset?: "PHYSICAL" | "DIGITAL" | "GIFT_CARD" | "SERVICE" | "UNRECOGNISED";
128481
+ custom?: string; // Custom type when preset is not suitable
128482
+ }
128483
+ \`\`\`
128484
+
128485
+ ### ProductName Object
128486
+ \`\`\`typescript
128487
+ interface ProductName {
128488
+ original: string; // Required - in site's default language
128489
+ translated?: string; // Translated into buyer's language
128490
+ }
128491
+ \`\`\`
128492
+
128493
+ ### DescriptionLine Object
128494
+ \`\`\`typescript
128495
+ interface DescriptionLine {
128496
+ name: {
128497
+ original: string;
128498
+ translated?: string;
128499
+ };
128500
+ colorInfo?: {
128501
+ original: string;
128502
+ translated?: string;
128503
+ code: string; // HEX or RGB color code
128504
+ };
128505
+ plainText?: {
128506
+ original: string;
128507
+ translated?: string;
128508
+ };
128509
+ lineType?: string;
128510
+ }
128511
+ \`\`\`
128512
+
128513
+ ### SelectedShippingOption Object
128514
+ \`\`\`typescript
128515
+ interface SelectedShippingOption {
128516
+ carrierId?: string;
128517
+ code?: string; // e.g., "usps_std_overnight"
128518
+ }
128519
+ \`\`\`
128520
+
128521
+ ### AddressWithContact Object
128522
+ \`\`\`typescript
128523
+ interface AddressWithContact {
128524
+ address?: Address;
128525
+ contactDetails?: {
128526
+ firstName?: string;
128527
+ lastName?: string;
128528
+ phone?: string;
128529
+ company?: string;
128530
+ vatId?: {
128531
+ _id?: string;
128532
+ type?: "CPF" | "CNPJ" | "UNSPECIFIED"; // For Brazil only
128533
+ };
128534
+ };
128535
+ }
128536
+ \`\`\`
128537
+
128538
+ ### ExtendedFields Object
128539
+ \`\`\`typescript
128540
+ interface ExtendedFields {
128541
+ namespaces?: Record<string, any>; // App-specific extended field data
128542
+ }
128543
+ \`\`\`
128544
+
128545
+ ### CustomLineItem Object
128546
+ \`\`\`typescript
128547
+ interface CustomLineItem {
128548
+ _id?: string; // Auto-generated if not provided
128549
+ productName: ProductName; // Required
128550
+ price: string; // Required - number or decimal without symbols
128551
+ itemType: ItemType; // Required
128552
+ quantity?: number; // Min: 1, Max: 100000
128553
+ catalogReference?: CatalogReference;
128554
+ descriptionLines?: Array<DescriptionLine>;
128555
+ media?: string; // Image from Wix media manager
128556
+ url?: string;
128557
+ fullPrice?: string;
128558
+ quantityAvailable?: number;
128559
+ physicalProperties?: PhysicalProperties;
128560
+ deliveryProfileId?: string;
128561
+ taxGroupId?: string;
128562
+ membersOnly?: boolean;
128563
+ paymentOption?: PaymentOptionType;
128564
+ depositAmount?: string;
128565
+ // ... additional fields
128566
+ }
128567
+ \`\`\`
128568
+
128569
+ ### CatalogReference Object
128570
+ \`\`\`typescript
128571
+ interface CatalogReference {
128572
+ appId: string; // Required
128573
+ catalogItemId: string; // Required
128574
+ options?: Record<string, any>; // Additional item details
128575
+ }
128576
+ \`\`\`
128577
+
128578
+ ### PaymentOptionType
128579
+ \`\`\`typescript
128580
+ type PaymentOptionType =
128581
+ | "FULL_PAYMENT_ONLINE" // Entire payment during checkout
128582
+ | "FULL_PAYMENT_OFFLINE" // Payment after checkout (cash, check, etc.)
128583
+ | "MEMBERSHIP" // Charged to membership
128584
+ | "MEMBERSHIP_OFFLINE" // Membership, manually redeemed by admin
128585
+ | "DEPOSIT_ONLINE" // Partial payment upfront
128586
+ | "MEMBERSHIP_ONLINE_WITH_OFFLINE_REMAINDER"; // Membership + offline remainder
128587
+ \`\`\`
128588
+
128589
+ ### ChannelType
128590
+ \`\`\`typescript
128591
+ type ChannelType =
128592
+ | "WEB" // Web client
128593
+ | "POS" // Point of sale
128594
+ | "EBAY" // eBay shop
128595
+ | "AMAZON" // Amazon shop
128596
+ | "FACEBOOK" // Facebook shop
128597
+ | "WIX_APP_STORE" // Wix Owner app
128598
+ | "BACKOFFICE_MERCHANT" // Wix merchant backoffice
128599
+ | "OTHER_PLATFORM"; // Other platform
128600
+ \`\`\`
128601
+
128602
+ ### ModifierGroup Object
128603
+ \`\`\`typescript
128604
+ interface ModifierGroup {
128605
+ _id?: string;
128606
+ name?: {
128607
+ original: string;
128608
+ translated?: string;
128609
+ };
128610
+ modifiers?: Array<{
128611
+ _id?: string;
128612
+ label?: {
128613
+ original: string;
128614
+ translated?: string;
128615
+ };
128616
+ price?: MultiCurrencyPrice;
128617
+ quantity?: number;
128618
+ details?: {
128619
+ original: string;
128620
+ translated?: string;
128621
+ };
128622
+ }>;
128623
+ }
128624
+ \`\`\`
128625
+
128626
+ ### SelectedMembership Object
128627
+ \`\`\`typescript
128628
+ interface SelectedMembership {
128629
+ _id: string; // Required - Membership GUID
128630
+ appId: string; // Required - App GUID providing this payment option
128631
+ }
128632
+ \`\`\`
128633
+
128634
+ ### ServiceProperties Object
128635
+ \`\`\`typescript
128636
+ interface ServiceProperties {
128637
+ numberOfParticipants?: number; // Number of people (class size, hotel room, etc.)
128638
+ scheduledDate?: Date; // ISO-8601 format - when service is provided
128639
+ }
128640
+ \`\`\`
128641
+
128642
+ ### EstimateTotalsResponse Object
128643
+ \`\`\`typescript
128644
+ interface EstimateTotalsResponse {
128645
+ cart: Cart;
128646
+ calculatedLineItems: Array<{
128647
+ lineItemId: string;
128648
+ pricesBreakdown: LineItemPricesData;
128649
+ paymentOption?: PaymentOptionType;
128650
+ taxableAddress?: TaxableAddress;
128651
+ }>;
128652
+ priceSummary: PriceSummary;
128653
+ shippingInfo?: ShippingInformation;
128654
+ taxSummary?: TaxSummary;
128655
+ appliedDiscounts?: Array<AppliedDiscount>;
128656
+ additionalFees?: Array<AdditionalFee>;
128657
+ calculationErrors?: CalculationErrors;
128658
+ membershipOptions?: MembershipOptions;
128659
+ currency: string;
128660
+ weightUnit: "KG" | "LB";
128661
+ // ... additional fields
128662
+ }
128663
+ \`\`\`
128664
+
128665
+ ### PriceSummary Object
128666
+ \`\`\`typescript
128667
+ interface PriceSummary {
128668
+ subtotal: MultiCurrencyPrice;
128669
+ shipping?: MultiCurrencyPrice;
128670
+ tax?: MultiCurrencyPrice;
128671
+ discount?: MultiCurrencyPrice;
128672
+ total: MultiCurrencyPrice;
128673
+ additionalFees?: MultiCurrencyPrice;
128674
+ }
128675
+ \`\`\`
128676
+
128677
+ ### TaxSummary Object
128678
+ \`\`\`typescript
128679
+ interface TaxSummary {
128680
+ taxableAmount?: MultiCurrencyPrice;
128681
+ totalTax?: MultiCurrencyPrice;
128682
+ }
128683
+ \`\`\`
128684
+
128685
+ ### ShippingInformation Object
128686
+ \`\`\`typescript
128687
+ interface ShippingInformation {
128688
+ region?: {
128689
+ _id: string;
128690
+ name: string;
128691
+ };
128692
+ selectedCarrierServiceOption?: {
128693
+ carrierId: string;
128694
+ code: string;
128695
+ title: string;
128696
+ cost: {
128697
+ price: MultiCurrencyPrice;
128698
+ totalPriceBeforeTax: MultiCurrencyPrice;
128699
+ totalPriceAfterTax: MultiCurrencyPrice;
128700
+ taxDetails?: ItemTaxFullDetails;
128701
+ totalDiscount?: MultiCurrencyPrice;
128702
+ };
128703
+ logistics?: DeliveryLogistics;
128704
+ requestedShippingOption?: boolean;
128705
+ };
128706
+ carrierServiceOptions?: Array<CarrierServiceOption>;
128707
+ }
128708
+ \`\`\`
128709
+
128710
+ </type_signatures>
128711
+
128712
+ <methods>
128713
+
128714
+ ## getCurrentCart()
128715
+
128716
+ Retrieves the current site visitor's cart.
128717
+
128718
+ **Important Notes:**
128719
+ - This method requires visitor or member authentication.
128720
+
128721
+ **Import:**
128722
+ \`\`\`javascript
128723
+ import { currentCart } from '@wix/ecom';
128724
+ \`\`\`
128725
+
128726
+ **Example - General Usage:**
128727
+ \`\`\`javascript
128728
+ import { currentCart } from '@wix/ecom';
128729
+
128730
+ currentCart.getCurrentCart()
128731
+ .then((myCurrentCart) => {
128732
+ const cartId = myCurrentCart._id;
128733
+ const cartLineItems = myCurrentCart.lineItems;
128734
+ console.log('Success! Retrieved myCurrentCart:', myCurrentCart);
128735
+ return myCurrentCart;
128736
+ })
128737
+ .catch((error) => {
128738
+ console.error(error);
128739
+ });
128740
+ \`\`\`
128741
+
128742
+ ---
128743
+
128744
+ ## addToCurrentCart(options)
128745
+
128746
+ Adds catalog line items to the current site visitor's cart.
128747
+
128748
+ **Important Notes:**
128749
+ - When adding catalog line items, the \`lineItems.catalogReference.appId\` and \`lineItems.catalogReference.catalogItemId\` fields are required.
128750
+ - This method requires visitor or member authentication.
128751
+ - After a cart is updated, call Refresh Cart to update the cart's UI elements and trigger the Cart Updated event.
128752
+
128753
+ **Example - Add a Wix Stores product to the current cart:**
128754
+ \`\`\`javascript
128755
+ // Backend code - my-backend-file.web.js/ts
128756
+ import { Permissions, webMethod } from '@wix/web-methods';
128757
+ import { currentCart } from '@wix/ecom';
128758
+
128759
+ export const myAddToCurrentCartFunction = webMethod(Permissions.Anyone, async (options) => {
128760
+ try {
128761
+ const updatedCurrentCart = await currentCart.addToCurrentCart(options);
128762
+ console.log('Success! Updated current cart:', updatedCurrentCart);
128763
+ return updatedCurrentCart;
128764
+ } catch (error) {
128765
+ console.error(error);
128766
+ }
128767
+ });
128768
+
128769
+ // Page code
128770
+ import { ecom } from "@wix/site-ecom";
128771
+ import { myAddToCurrentCartFunction } from 'backend/my-backend-file.web';
128772
+
128773
+ const options = {
128774
+ "lineItems": [{
128775
+ "catalogReference": {
128776
+ "appId": "215238eb-22a5-4c36-9e7b-e7c08025e04e", // Wix Stores appId
128777
+ "catalogItemId": "1a2d7e83-4bef-31d5-09e1-3326ee271c09", // Wix Stores productId
128778
+ "options": {
128779
+ "variantId": "132b84e8-aab8-47a1-a1f6-2c47557b64a4" // Wix Stores variantId
128780
+ }
128781
+ },
128782
+ "quantity": 1
128783
+ }]
128784
+ };
128785
+
128786
+ const updatedCurrentCart = await myAddToCurrentCartFunction(options);
128787
+ await ecom.refreshCart();
128788
+ await ecom.navigateToCartPage();
128789
+ \`\`\`
128790
+
128791
+ ---
128792
+
128793
+ ## createCheckoutFromCurrentCart(options)
128794
+
128795
+ Creates a checkout from the current site visitor's cart. If a checkout was already created from the current cart, that checkout will be updated with any new information from the cart.
128796
+
128797
+ **Important Notes:**
128798
+ - \`channelType\` is a required field.
128799
+ - This method requires visitor or member authentication.
128800
+
128801
+ **Example:**
128802
+ \`\`\`javascript
128803
+ // Backend code - my-backend-file.web.js/ts
128804
+ import { Permissions, webMethod } from '@wix/web-methods';
128805
+ import { currentCart } from '@wix/ecom';
128806
+
128807
+ export const myCreateCheckoutFromCurrentCartFunction = webMethod(Permissions.Anyone, async (options) => {
128808
+ try {
128809
+ const checkoutId = await currentCart.createCheckoutFromCurrentCart(options);
128810
+ console.log('Success! Checkout created, checkoutId:', checkoutId);
128811
+ return checkoutId;
128812
+ } catch (error) {
128813
+ console.error(error);
128814
+ }
128815
+ });
128816
+
128817
+ // Page code
128818
+ import { myCreateCheckoutFromCurrentCartFunction } from 'backend/my-backend-file.web';
128819
+
128820
+ const options = {
128821
+ "channelType": "WEB", // required field
128822
+ "email": "janedoe@example.com",
128823
+ "shippingAddress": {
128824
+ "addressLine1": "235 West 23rd Street",
128825
+ "addressLine2": "3rd floor",
128826
+ "city": "New York",
128827
+ "country": "US",
128828
+ "postalCode": "10011",
128829
+ "streetAddress": {
128830
+ "name": "West 23rd Street",
128831
+ "number": "235"
128832
+ },
128833
+ "subdivision": "US-NY"
128834
+ }
128835
+ };
128836
+
128837
+ const checkoutId = await myCreateCheckoutFromCurrentCartFunction(options);
128838
+ \`\`\`
128839
+
128840
+ ---
128841
+
128842
+ ## estimateCurrentCartTotals(options)
128843
+
128844
+ Estimates the current cart's price totals (including tax), based on a selected carrier service, shipping address, and billing information.
128845
+
128846
+ **Important Notes:**
128847
+ - Not passing any properties will only estimate the cart items price totals, without considering shipping and billing information.
128848
+ - This method requires visitor or member authentication.
128849
+
128850
+ **Example:**
128851
+ \`\`\`javascript
128852
+ // Backend code - my-backend-file.web.js/ts
128853
+ import { Permissions, webMethod } from '@wix/web-methods';
128854
+ import { currentCart } from '@wix/ecom';
128855
+
128856
+ export const myEstimateCurrentCartTotalsFunction = webMethod(Permissions.Anyone, async (estimateOptions) => {
128857
+ try {
128858
+ const estimatedCartTotals = await currentCart.estimateCurrentCartTotals(estimateOptions);
128859
+ console.log('Success! Cart totals estimated:', estimatedCartTotals);
128860
+ return estimatedCartTotals;
128861
+ } catch (error) {
128862
+ console.error(error);
128863
+ }
128864
+ });
128865
+
128866
+ // Page code
128867
+ import { myEstimateCurrentCartTotalsFunction } from 'backend/my-backend-file.web';
128868
+
128869
+ const estimateOptions = {
128870
+ "selectedShippingOption": {
128871
+ "code": "standard_us_shipping"
128872
+ },
128873
+ "shippingAddress": {
128874
+ "addressLine1": "235 West 23rd Street",
128875
+ "addressLine2": "3rd floor",
128876
+ "city": "New York",
128877
+ "country": "US",
128878
+ "postalCode": "10011",
128879
+ "streetAddress": {
128880
+ "name": "West 23rd Street",
128881
+ "number": "235"
128882
+ },
128883
+ "subdivision": "US-NY"
128884
+ },
128885
+ "billingAddress": {
128886
+ "addressLine1": "235 West 23rd Street",
128887
+ "addressLine2": "3rd floor",
128888
+ "city": "New York",
128889
+ "country": "US",
128890
+ "postalCode": "10011",
128891
+ "streetAddress": {
128892
+ "name": "West 23rd Street",
128893
+ "number": "235"
128894
+ },
128895
+ "subdivision": "US-NY"
128896
+ }
128897
+ };
128898
+
128899
+ const estimatedCartTotals = await myEstimateCurrentCartTotalsFunction(estimateOptions);
128900
+ const formattedShippingPrice = estimatedCartTotals.priceSummary.shipping.formattedAmount;
128901
+ const estimatedCartTotal = estimatedCartTotals.priceSummary.total.formattedAmount;
128902
+ \`\`\`
128903
+
128904
+ ---
128905
+
128906
+ ## updateCurrentCart(options)
128907
+
128908
+ Updates the current site visitor's cart.
128909
+
128910
+ **Important Notes:**
128911
+ - When adding catalog line items, the \`lineItems.catalogReference.appId\` and \`lineItems.catalogReference.catalogItemId\` fields are required.
128912
+ - This method requires visitor or member authentication.
128913
+ - After a cart is updated, call Refresh Cart to update the cart's UI elements and trigger the Cart Updated event.
128914
+
128915
+ **Example - Apply a coupon to the current cart:**
128916
+ \`\`\`javascript
128917
+ // Backend code - my-backend-file.web.js/ts
128918
+ import { Permissions, webMethod } from '@wix/web-methods';
128919
+ import { currentCart } from '@wix/ecom';
128920
+
128921
+ export const myUpdateCurrentCartFunction = webMethod(Permissions.Anyone, async (options) => {
128922
+ try {
128923
+ const updatedCurrentCart = await currentCart.updateCurrentCart(options);
128924
+ console.log('Success! Updated current cart:', updatedCurrentCart);
128925
+ return updatedCurrentCart;
128926
+ } catch (error) {
128927
+ console.error(error);
128928
+ }
128929
+ });
128930
+
128931
+ // Page code
128932
+ import { ecom } from "@wix/site-ecom";
128933
+ import { myUpdateCurrentCartFunction } from 'backend/my-backend-file.web';
128934
+
128935
+ const updateOptions = {
128936
+ "couponCode": "SUMMERSALE10"
128937
+ };
128938
+
128939
+ const updatedCurrentCart = await myUpdateCurrentCartFunction(updateOptions);
128940
+ await ecom.refreshCart();
128941
+ await ecom.navigateToCartPage();
128942
+ \`\`\`
128943
+
128944
+ ---
128945
+
128946
+ ## updateCurrentCartLineItemQuantity(lineItems)
128947
+
128948
+ Updates the quantity of 1 or more line items in the current site visitor's cart.
128949
+
128950
+ **Important Notes:**
128951
+ - This method is only for updating the quantity of line items.
128952
+ - To entirely remove a line item from the current cart, use the removeLineItemsFromCurrentCart method.
128953
+ - To add a new line item to the current cart, use the addToCurrentCart method.
128954
+ - This method checks the amount of stock remaining for this line item. If the specified quantity is greater than the remaining stock, then the quantity returned in the response is the total amount of remaining stock.
128955
+ - This method requires visitor or member authentication.
128956
+ - After a cart is updated, call Refresh Cart to update the cart's UI elements and trigger the Cart Updated event.
128957
+
128958
+ **Example:**
128959
+ \`\`\`javascript
128960
+ // Backend code - my-backend-file.web.js/ts
128961
+ import { Permissions, webMethod } from '@wix/web-methods';
128962
+ import { currentCart } from '@wix/ecom';
128963
+
128964
+ export const myUpdateCurrentCartLineItemQuantityFunction = webMethod(Permissions.Anyone, async (lineItems) => {
128965
+ try {
128966
+ const updatedCurrentCart = await currentCart.updateCurrentCartLineItemQuantity(lineItems);
128967
+ console.log('Success! Line item quantities updated:', updatedCurrentCart);
128968
+ return updatedCurrentCart;
128969
+ } catch (error) {
128970
+ console.error(error);
128971
+ }
128972
+ });
128973
+
128974
+ // Page code
128975
+ import { ecom } from "@wix/site-ecom";
128976
+ import { myUpdateCurrentCartLineItemQuantityFunction } from 'backend/my-backend-file.web';
128977
+
128978
+ const lineItems = [
128979
+ {
128980
+ "_id": '00000000-0000-0000-0000-000000000001',
128981
+ "quantity": 2
128982
+ },
128983
+ {
128984
+ "_id": '00000000-0000-0000-0000-000000000002',
128985
+ "quantity": 3
128986
+ }
128987
+ ];
128988
+
128989
+ const updatedCurrentCart = await myUpdateCurrentCartLineItemQuantityFunction(lineItems);
128990
+ await ecom.refreshCart();
128991
+ await ecom.navigateToCartPage();
128992
+ \`\`\`
128993
+
128994
+ ---
128995
+
128996
+ ## removeCouponFromCurrentCart()
128997
+
128998
+ Removes the coupon from the current site visitor's cart.
128999
+
129000
+ **Important Notes:**
129001
+ - This method requires visitor or member authentication.
129002
+ - After a cart is updated, call Refresh Cart to update the cart's UI elements and trigger the Cart Updated event.
129003
+
129004
+ **Example:**
129005
+ \`\`\`javascript
129006
+ // Backend code - my-backend-file.web.js/ts
129007
+ import { Permissions, webMethod } from '@wix/web-methods';
129008
+ import { currentCart } from '@wix/ecom';
129009
+
129010
+ export const myRemoveCouponFromCurrentCartFunction = webMethod(Permissions.Anyone, async () => {
129011
+ try {
129012
+ const updatedCurrentCart = await currentCart.removeCouponFromCurrentCart();
129013
+ console.log('Success! Updated current cart:', updatedCurrentCart);
129014
+ return updatedCurrentCart;
129015
+ } catch (error) {
129016
+ console.error(error);
129017
+ }
129018
+ });
129019
+
129020
+ // Page code
129021
+ import { ecom } from "@wix/site-ecom";
129022
+ import { myRemoveCouponFromCurrentCartFunction } from 'backend/my-backend-file.web';
129023
+
129024
+ const updatedCurrentCart = await myRemoveCouponFromCurrentCartFunction();
129025
+ await ecom.refreshCart();
129026
+ await ecom.navigateToCartPage();
129027
+ \`\`\`
129028
+
129029
+ ---
129030
+
129031
+ ## removeLineItemsFromCurrentCart(lineItemIds)
129032
+
129033
+ Removes line items from the current site visitor's cart.
129034
+
129035
+ **Important Notes:**
129036
+ - This method requires visitor or member authentication.
129037
+ - After a cart is updated, call Refresh Cart to update the cart's UI elements and trigger the Cart Updated event.
129038
+
129039
+ **Example - Remove 3 line items from the current cart:**
129040
+ \`\`\`javascript
129041
+ // Backend code - my-backend-file.web.js/ts
129042
+ import { Permissions, webMethod } from '@wix/web-methods';
129043
+ import { currentCart } from '@wix/ecom';
129044
+
129045
+ export const myRemoveLineItemsFromCurrentCartFunction = webMethod(Permissions.Anyone, async (lineItemIds) => {
129046
+ try {
129047
+ const updatedCurrentCart = await currentCart.removeLineItemsFromCurrentCart(lineItemIds);
129048
+ console.log('Success! Line items removed from cart:', updatedCurrentCart);
129049
+ return updatedCurrentCart;
129050
+ } catch (error) {
129051
+ console.error(error);
129052
+ }
129053
+ });
129054
+
129055
+ // Page code
129056
+ import { ecom } from "@wix/site-ecom";
129057
+ import { myRemoveLineItemsFromCurrentCartFunction } from 'backend/my-backend-file.web';
129058
+
129059
+ const lineItemIds = [
129060
+ '00000000-0000-0000-0000-000000000001',
129061
+ '00000000-0000-0000-0000-000000000002',
129062
+ '00000000-0000-0000-0000-000000000003'
129063
+ ];
129064
+
129065
+ const updatedCurrentCart = await myRemoveLineItemsFromCurrentCartFunction(lineItemIds);
129066
+ await ecom.refreshCart();
129067
+ await ecom.navigateToCartPage();
129068
+ \`\`\`
129069
+
129070
+ ---
129071
+
129072
+ ## deleteCurrentCart()
129073
+
129074
+ Deletes the current site visitor's cart.
129075
+
129076
+ **Important Notes:**
129077
+ - This method requires visitor or member authentication.
129078
+
129079
+ **Example:**
129080
+ \`\`\`javascript
129081
+ // Backend code - my-backend-file.web.js/ts
129082
+ import { Permissions, webMethod } from '@wix/web-methods';
129083
+ import { currentCart } from '@wix/ecom';
129084
+
129085
+ export const myDeleteCurrentCartFunction = webMethod(Permissions.Anyone, async () => {
129086
+ try {
129087
+ await currentCart.deleteCurrentCart();
129088
+ console.log('Success! Deleted cart');
129089
+ return;
129090
+ } catch (error) {
129091
+ console.error(error);
129092
+ }
129093
+ });
129094
+
129095
+ // Page code
129096
+ import { myDeleteCurrentCartFunction } from 'backend/my-backend-file.web';
129097
+
129098
+ myDeleteCurrentCartFunction()
129099
+ .then(() => {
129100
+ console.log('Success! Deleted current cart');
129101
+ })
129102
+ .catch((error) => {
129103
+ console.error(error);
129104
+ });
129105
+ \`\`\`
129106
+
129107
+ </methods>
129108
+
129109
+ <events>
129110
+
129111
+ ## onCartCreated(handler)
129112
+
129113
+ Triggered when a cart is created.
129114
+
129115
+ **Event Handler:**
129116
+ \`\`\`javascript
129117
+ import { currentCart } from '@wix/ecom';
129118
+
129119
+ currentCart.onCartCreated((event) => {
129120
+ const cart = event.entity;
129121
+ console.log('Cart created:', cart);
129122
+ });
129123
+ \`\`\`
129124
+
129125
+ ---
129126
+
129127
+ ## onCartUpdated(handler)
129128
+
129129
+ Triggered when a cart is updated.
129130
+
129131
+ **Event Handler:**
129132
+ \`\`\`javascript
129133
+ import { currentCart } from '@wix/ecom';
129134
+
129135
+ currentCart.onCartUpdated((event) => {
129136
+ const cart = event.entity;
129137
+ console.log('Cart updated:', cart);
129138
+ });
129139
+ \`\`\`
129140
+
129141
+ ---
129142
+
129143
+ ## onCartDeleted(handler)
129144
+
129145
+ Triggered when a cart is deleted.
129146
+
129147
+ **Event Handler:**
129148
+ \`\`\`javascript
129149
+ import { currentCart } from '@wix/ecom';
129150
+
129151
+ currentCart.onCartDeleted((event) => {
129152
+ const cartId = event.metadata.entityId;
129153
+ console.log('Cart deleted:', cartId);
129154
+ });
129155
+ \`\`\`
129156
+
129157
+ </events>
129158
+
129159
+ <migration_note>
129160
+ To assist in migration from the Stores to eCommerce APIs, please refer to the Stores to eCommerce Cart Conversion Table.
129161
+ </migration_note>
129162
+
129163
+ </ecom_cart_docs>
129164
+ `;
129165
+ exports2.cartPrompt = cartPrompt;
129166
+ }
129167
+ });
129168
+
129169
+ // dist/system-prompts/embeddedScript/data.js
129170
+ var require_data4 = __commonJS({
129171
+ "dist/system-prompts/embeddedScript/data.js"(exports2) {
129172
+ "use strict";
129173
+ Object.defineProperty(exports2, "__esModule", { value: true });
129174
+ exports2.dataPrompt = void 0;
129175
+ var dataPrompt = () => `
129176
+ <wix_data_integration>
128174
129177
  <description>
128175
- Embedded scripts are HTML code fragments that get injected into the DOM of Wix sites. They enable integration with third-party services, analytics tracking, advertising, and custom JavaScript functionality.
129178
+ This embedded script can access and display dynamic content from Wix Data collections.
128176
129179
 
128177
- Each embedded script lives in its own folder under src/site/embedded-scripts/ and you generate the embedded.html file containing the HTML/JavaScript code to be injected.
129180
+ IMPORTANT: Since collections are provided in the CREATED COLLECTIONS section, you MUST use @wix/data to interact with them - BUT ONLY if the collection is relevant to your use case. Import and use the data module to query, retrieve, and display collection items in your embedded script when they serve a clear purpose in the script's functionality.
128178
129181
  </description>
128179
129182
 
128180
- <metadata_fields>
128181
- You will also specify metadata that determines how the script is injected:
128182
- - scriptType: ESSENTIAL | FUNCTIONAL | ANALYTICS | ADVERTISING
128183
- - placement: HEAD | BODY_START | BODY_END
129183
+ <wix_data_docs>
129184
+ Summary:
129185
+ - Read: items.query('Collection').filter/sort.limit.find() \u2192 { items, totalCount, hasNext }
129186
+ - Embedded scripts primarily use read-only data operations for displaying dynamic content
128184
129187
 
128185
- These are returned separately from the HTML file.
128186
- </metadata_fields>
129188
+ Access data using the collection schema:
129189
+ - Always use the exact field keys you defined in the collection schema.
129190
+ - YOU MUST use the collection id exactly as you defined it in the collection schema.
129191
+ - YOU MUST use the collection schema's exact field types for all operations (query, insert, update, remove)
129192
+ - All custom fields are stored in the [key: string]: any part of the WixDataItem interface
128187
129193
 
128188
- <script_types>
128189
- An enum used by consent management apps to determine whether site visitors consent to having your script run during their visit. Possible values are:
128190
- - ESSENTIAL: Enables site visitors to move around the site and use essential features like secure and private areas crucial to the functioning of the site.
128191
- - FUNCTIONAL: Remembers choices site visitors make to improve their experience, such as language.
128192
- - ANALYTICS: Provides statistics to the site owner on how visitors use the site, such as which pages they visit. This helps improve the site by identifying errors and performance issues.
128193
- - ADVERTISING: Provides visitor information to the site owner to help market their products, such as data on the impact of marketing campaigns, re-targeted advertising, and so on.
128194
- An embedded script must have a type. If your script falls into more than one type, choose the option closest to the bottom of the list above. For example, if your script has Advertising and Analytics aspects, choose Advertising as its type. It's unlikely that you'll need to mark it as Essential.
128195
- </script_types>
129194
+ Import (for backend-rendered embedded scripts):
129195
+ import { items } from '@wix/data';
128196
129196
 
128197
- <placement_options>
128198
- An enum indicating where in the page's DOM the HTML code will be injected. Possible values are:
128199
- - HEAD: Injects the code between the page's <head> and </head> tags.
128200
- - BODY_START: Injects the code immediately after the page's opening <body> tag.
128201
- - BODY_END: Injects the code immediately before the page's closing </body> tag.
128202
- </placement_options>
129197
+ Available Methods:
128203
129198
 
128204
- <template_variables>
128205
- Embedded scripts support parameterization using template variable syntax {{variableName}}.
128206
- - Correct: <div data-value="{{myVariable}}"></div>
128207
- - Common use cases: API keys, configuration values, user-specific data
128208
- </template_variables>
129199
+ #### items.query(dataCollectionId: string)
129200
+ - **Description**: Creates a query to retrieve items from a collection. Supports filtering, sorting, and pagination via chaining methods.
129201
+ Use for reading dynamic content to display in embedded scripts.
129202
+ The query() method runs with the following WixDataQuery defaults that you can override:
129203
+ - skip: 0
129204
+ - limit: 50
129205
+ - descending: by _createdDate
129206
+ - include: none
129207
+ - Example:
129208
+ const result = await items.query("myCollection")
129209
+ .eq("status", "active")
129210
+ .limit(10)
129211
+ .find();
128209
129212
 
128210
- </embedded_script_extension_files_and_code>
129213
+ #### items.get(dataCollectionId: string, itemId: string)
129214
+ - **Description**: Retrieves a single item by ID from a collection.
129215
+ Use for fetching specific content entries.
129216
+ - Example:
129217
+ const item = await items.get("myCollection", "00001");
128211
129218
 
128212
- <core_principles>
128213
- - Do NOT invent or assume new types, modules, functions, or imports not available in standard browser APIs or explicitly imported libraries
128214
- - NEVER use mocks, placeholders, or TODOs in any code
128215
- - ALWAYS implement complete, production-ready functionality
128216
- - Handle errors gracefully and fail silently when appropriate for embedded scripts
128217
- - Minimize performance impact - embedded scripts should be lightweight and non-blocking
128218
- - Follow web security best practices (avoid inline event handlers, validate data, escape user input)
128219
- </core_principles>
129219
+ Note: Embedded scripts should primarily focus on read operations. For write operations (insert, update, remove),
129220
+ consider using backend code (HTTP functions or service plugins) and calling them from the embedded script via fetch/AJAX.
129221
+ </wix_data_docs>
129222
+
129223
+ <usage_in_embedded_scripts>
129224
+
129225
+ 1. Relevant Collection Usage (CRITICAL):
129226
+ - Only use collections that are directly relevant to your embedded script's functionality
129227
+ - Ignore collections that don't apply to what you're implementing
129228
+ - Each collection you query should serve a clear purpose in the script's behavior
129229
+ - It's perfectly fine to not use any collections if they're not applicable to your use case
129230
+ - Don't force data usage just because collections exist - use them only when they add value
129231
+
129232
+ 2. DIRECT SDK USAGE (REQUIRED):
129233
+ - Embedded scripts MUST use @wix/data SDK directly - DO NOT use fetch() calls to API endpoints
129234
+ - Import and use the items module from @wix/data directly in your embedded script
129235
+ - NEVER create fetch() calls to /api/* endpoints for data operations
129236
+ - Use items.query() directly in the embedded script code
129237
+
129238
+ 3. Display Dynamic Content:
129239
+ - Query collections directly using @wix/data to get dynamic content that's relevant to your embedded script
129240
+ - Render the data in your HTML/JavaScript
129241
+ - Handle loading states and errors gracefully
129242
+
129243
+ 4. Example Pattern - Displaying Collection Items:
129244
+ <div id="content-container"></div>
129245
+ <script type="module">
129246
+ import { items } from '@wix/data';
129247
+
129248
+ // CORRECT: Use @wix/data directly
129249
+ async function loadContent() {
129250
+ try {
129251
+ const result = await items.query('myCollection')
129252
+ .limit(10)
129253
+ .find();
129254
+
129255
+ const container = document.getElementById('content-container');
129256
+ result.items.forEach(item => {
129257
+ const el = document.createElement('div');
129258
+ el.textContent = item.title;
129259
+ container.appendChild(el);
129260
+ });
129261
+ } catch (error) {
129262
+ console.error('Failed to load content:', error);
129263
+ }
129264
+ }
129265
+
129266
+ loadContent();
129267
+ </script>
129268
+
129269
+ 5. Best Practices:
129270
+ - Cache data when appropriate to reduce queries
129271
+ - Handle empty states gracefully
129272
+ - Show loading indicators for better UX
129273
+ - Implement error handling for failed queries
129274
+ - Consider pagination for large datasets
129275
+
129276
+ </usage_in_embedded_scripts>
128220
129277
 
128221
- <generation_requirements>
128222
- 1. Generate the embedded.html file with complete HTML/JavaScript implementation
128223
- 2. Specify appropriate scriptType based on the use case:
128224
- - Analytics tools \u2192 ANALYTICS
128225
- - Ad networks, marketing pixels \u2192 ADVERTISING
128226
- - Core functionality \u2192 ESSENTIAL
128227
- - Enhanced features \u2192 FUNCTIONAL
128228
- 3. Choose optimal placement:
128229
- - Analytics/tracking \u2192 HEAD (initialize early)
128230
- - Advertising \u2192 BODY_END (non-blocking)
128231
- - Critical functionality \u2192 HEAD or BODY_START
128232
- - Non-critical features \u2192 BODY_END (performance)
128233
- 4. Implement complete business logic with proper error handling
128234
- 5. Use template variables {{variableName}} for configurable values (API keys, settings, etc.)
128235
- 6. Include proper TypeScript imports when using external modules
128236
- </generation_requirements>
129278
+ <validation_requirements>
129279
+ - Only query collections that are directly relevant to your embedded script's specific use case
129280
+ - Ignore collections that don't contribute to the functionality you're implementing
129281
+ - Each collection query should serve a clear, necessary purpose
129282
+ - Don't include data operations just because collections are available
129283
+ - Use the exact collection IDs and field keys as defined in the collection schema
129284
+ - Handle cases where collections might be empty or queries might fail
129285
+ </validation_requirements>
128237
129286
 
128238
- <implementation_guidelines>
129287
+ </wix_data_integration>
129288
+ `;
129289
+ exports2.dataPrompt = dataPrompt;
129290
+ }
129291
+ });
128239
129292
 
128240
- ${hasDynamicParameters ? `
129293
+ // dist/system-prompts/embeddedScript/dynamicParameters.js
129294
+ var require_dynamicParameters3 = __commonJS({
129295
+ "dist/system-prompts/embeddedScript/dynamicParameters.js"(exports2) {
129296
+ "use strict";
129297
+ Object.defineProperty(exports2, "__esModule", { value: true });
129298
+ exports2.dynamicParametersPrompt = void 0;
129299
+ var dynamicParametersPrompt = () => `
128241
129300
  <dynamic_parameters_usage>
128242
129301
 
128243
129302
  <description>
@@ -128357,8 +129416,108 @@ Pattern 3 - Conditional Logic:
128357
129416
  </validation_requirements>
128358
129417
 
128359
129418
  </dynamic_parameters_usage>
128360
- ` : ""}
129419
+ `;
129420
+ exports2.dynamicParametersPrompt = dynamicParametersPrompt;
129421
+ }
129422
+ });
129423
+
129424
+ // dist/system-prompts/embeddedScript/embededScript.js
129425
+ var require_embededScript = __commonJS({
129426
+ "dist/system-prompts/embeddedScript/embededScript.js"(exports2) {
129427
+ "use strict";
129428
+ Object.defineProperty(exports2, "__esModule", { value: true });
129429
+ exports2.embeddedScriptPrompt = void 0;
129430
+ var apiDocLoader_1 = require_apiDocLoader();
129431
+ var cart_1 = require_cart();
129432
+ var data_1 = require_data4();
129433
+ var dynamicParameters_1 = require_dynamicParameters3();
129434
+ var embeddedScriptPrompt = (hasDynamicParameters, useData = false, apiNames) => {
129435
+ const apiDocs = (0, apiDocLoader_1.loadApiDocumentation)(apiNames);
129436
+ return `
129437
+ <WIXCLI_EMBEDDED_SCRIPT_SYSTEM_PROMPT>
128361
129438
 
129439
+ <role>
129440
+ You are a senior Wix CLI App Developer Expert specialized in creating embedded scripts for Wix applications. You have deep knowledge of embedded script best practices, HTML/JavaScript injection patterns, and third-party integrations.
129441
+
129442
+ You are tasked with generating a complete Wix CLI embedded script implementation based on the user's requirements.
129443
+ </role>
129444
+
129445
+ <embedded_script_extension_files_and_code>
129446
+ <description>
129447
+ Embedded scripts are HTML code fragments that get injected into the DOM of Wix sites. They enable integration with third-party services, analytics tracking, advertising, and custom JavaScript functionality.
129448
+
129449
+ Each embedded script lives in its own folder under src/site/embedded-scripts/ and you generate the embedded.html file containing the HTML/JavaScript code to be injected.
129450
+ </description>
129451
+
129452
+ <metadata_fields>
129453
+ You will also specify metadata that determines how the script is injected:
129454
+ - scriptType: ESSENTIAL | FUNCTIONAL | ANALYTICS | ADVERTISING
129455
+ - placement: HEAD | BODY_START | BODY_END
129456
+
129457
+ These are returned separately from the HTML file.
129458
+ </metadata_fields>
129459
+
129460
+ <script_types>
129461
+ An enum used by consent management apps to determine whether site visitors consent to having your script run during their visit. Possible values are:
129462
+ - ESSENTIAL: Enables site visitors to move around the site and use essential features like secure and private areas crucial to the functioning of the site.
129463
+ - FUNCTIONAL: Remembers choices site visitors make to improve their experience, such as language.
129464
+ - ANALYTICS: Provides statistics to the site owner on how visitors use the site, such as which pages they visit. This helps improve the site by identifying errors and performance issues.
129465
+ - ADVERTISING: Provides visitor information to the site owner to help market their products, such as data on the impact of marketing campaigns, re-targeted advertising, and so on.
129466
+ An embedded script must have a type. If your script falls into more than one type, choose the option closest to the bottom of the list above. For example, if your script has Advertising and Analytics aspects, choose Advertising as its type. It's unlikely that you'll need to mark it as Essential.
129467
+ </script_types>
129468
+
129469
+ <placement_options>
129470
+ An enum indicating where in the page's DOM the HTML code will be injected. Possible values are:
129471
+ - HEAD: Injects the code between the page's <head> and </head> tags.
129472
+ - BODY_START: Injects the code immediately after the page's opening <body> tag.
129473
+ - BODY_END: Injects the code immediately before the page's closing </body> tag.
129474
+ </placement_options>
129475
+
129476
+ <template_variables>
129477
+ Embedded scripts support parameterization using template variable syntax {{variableName}}.
129478
+ - Correct: <div data-value="{{myVariable}}"></div>
129479
+ - Common use cases: API keys, configuration values, user-specific data
129480
+ </template_variables>
129481
+
129482
+ </embedded_script_extension_files_and_code>
129483
+
129484
+ <core_principles>
129485
+ - Do NOT invent or assume new types, modules, functions, or imports not available in standard browser APIs or explicitly imported libraries
129486
+ - NEVER use mocks, placeholders, or TODOs in any code
129487
+ - ALWAYS implement complete, production-ready functionality
129488
+ - Handle errors gracefully and fail silently when appropriate for embedded scripts
129489
+ - Minimize performance impact - embedded scripts should be lightweight and non-blocking
129490
+ - Follow web security best practices (avoid inline event handlers, validate data, escape user input)
129491
+ - ONLY create fetch() calls to /api/* endpoints that are explicitly defined in the provided API spec - verify each endpoint exists before using it
129492
+ - If no API spec is provided, do NOT create ANY /api/* fetch calls
129493
+ </core_principles>
129494
+
129495
+ <generation_requirements>
129496
+ 1. Generate the embedded.html file with complete HTML/JavaScript implementation
129497
+ 2. **VERIFY API ENDPOINTS**: Before using fetch() to /api/*, confirm the endpoint exists in "## API SPEC" section
129498
+ 3. Specify appropriate scriptType based on the use case:
129499
+ - Analytics tools \u2192 ANALYTICS
129500
+ - Ad networks, marketing pixels \u2192 ADVERTISING
129501
+ - Core functionality \u2192 ESSENTIAL
129502
+ - Enhanced features \u2192 FUNCTIONAL
129503
+ 5. Choose optimal placement:
129504
+ - Analytics/tracking \u2192 HEAD (initialize early)
129505
+ - Advertising \u2192 BODY_END (non-blocking)
129506
+ - Critical functionality \u2192 HEAD or BODY_START
129507
+ - Non-critical features \u2192 BODY_END (performance)
129508
+ 6. Implement complete business logic with proper error handling
129509
+ 7. Use template variables {{variableName}} for configurable values and backend data
129510
+ </generation_requirements>
129511
+
129512
+ <implementation_guidelines>
129513
+
129514
+ ${useData ? (0, data_1.dataPrompt)() : ""}
129515
+
129516
+ ${hasDynamicParameters ? (0, dynamicParameters_1.dynamicParametersPrompt)() : ""}
129517
+
129518
+ ${(0, cart_1.cartPrompt)()}
129519
+
129520
+ ${apiDocs}
128362
129521
  </WIXCLI_EMBEDDED_SCRIPT_SYSTEM_PROMPT>
128363
129522
  `;
128364
129523
  };
@@ -128404,14 +129563,16 @@ var require_EmbeddedScriptAgent = __commonJS({
128404
129563
  this.apiKey = apiKey;
128405
129564
  this.name = "EmbeddedScriptAgent";
128406
129565
  }
128407
- async buildSystemPrompt(hasDynamicParameters) {
128408
- return (0, embededScript_1.embeddedScriptPrompt)(hasDynamicParameters);
129566
+ buildSystemPrompt(hasDynamicParameters, useData, apiNames) {
129567
+ return (0, embededScript_1.embeddedScriptPrompt)(hasDynamicParameters, useData, apiNames);
128409
129568
  }
128410
129569
  async generate(params) {
128411
129570
  const { blueprint, planAndResources } = params;
128412
129571
  const examples = (0, load_examples_1.loadExamples)([load_examples_1.types.EmbeddedScript]);
128413
129572
  const hasDynamicParameters = Boolean(planAndResources?.embeddedScriptParameters && planAndResources.embeddedScriptParameters.length > 0);
128414
- const systemPrompt = `${await this.buildSystemPrompt(hasDynamicParameters)}
129573
+ const useData = Boolean(planAndResources?.createdCollections?.length);
129574
+ const apiNames = (0, utils_1.extractApiNames)(params.extension);
129575
+ const systemPrompt = `${this.buildSystemPrompt(hasDynamicParameters, useData, apiNames)}
128415
129576
  ${examples}
128416
129577
  `;
128417
129578
  console.log(`Embedded Script Agent System Prompt length: ${systemPrompt.length} (is that what you expect?)`);