@salla.sa/twilight 3.0.0-beta.1 → 3.0.0

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 CHANGED
@@ -252,6 +252,35 @@ This is particularly useful for debugging, support, and ensuring compatibility b
252
252
 
253
253
  <p align="right">(<a href="#top">back to top</a>)</p>
254
254
 
255
+ ### WebMCP (tools for in-browser AI agents)
256
+
257
+ Twilight can register [WebMCP](https://webmachinelearning.github.io/webmcp/) tools so an AI agent running in the shopper's browser can search, fill the cart and head to checkout. The tools call the regular SDK (`salla.cart.*`, `salla.product.*`) in the shopper's own tab, so they fire the normal cart events and the cart badge and mini-cart update as they would for a click. They never call the `/mcp` worker, whose carts are not the tab's cart.
258
+
259
+ | Tool | Read-only | What it does |
260
+ |------|-----------|--------------|
261
+ | `search_products` | yes | Search the store's products by keyword (`query`, optional `limit`). |
262
+ | `get_product` | yes | Product details by `product_id`. |
263
+ | `get_cart` | yes | The shopper's current cart: items, totals, coupon. |
264
+ | `add_to_cart` | no | Add `product_id` (`quantity`, and `options` keyed by option id for products that need them). |
265
+ | `update_cart_item` | no | Change the quantity of a cart item. |
266
+ | `remove_cart_item` | no | Remove a cart item. |
267
+ | `apply_coupon` | no | Apply a coupon code. |
268
+ | `go_to_checkout` | no | Navigate to checkout (guests go to login first). It only navigates; **it never places an order**, the shopper pays on the checkout page. |
269
+
270
+ Failures come back as `{ isError: true, content: [...] }` with the API's own message.
271
+
272
+ **Off by default.** Stores opt in through the config passed to `Salla.init`:
273
+
274
+ ```js
275
+ Salla.init({ store: { id: 1234 }, webmcp: { enabled: true } });
276
+ ```
277
+
278
+ Only the boolean `true` (or `'true'` / `1`) turns it on. Salla Store renders this value for you from `TWILIGHT_WEBMCP_ENABLED` (all stores) or the `themes::webmcp.enabled` store setting; set it back to `false` to switch the tools off. No Twilight release is involved.
279
+
280
+ **Browser support.** Needs a browser that implements WebMCP and an HTTPS page. It looks for `document.modelContext` first, then `navigator.modelContext`, and does nothing when neither exists (all other browsers, including current Firefox and Safari) or on HTTP. In Chrome 146+ the API is behind the `chrome://flags/#enable-webmcp-testing` flag ("WebMCP for testing"). Registering the same tool twice (for example when init runs twice) is tolerated.
281
+
282
+ <p align="right">(<a href="#top">back to top</a>)</p>
283
+
255
284
  ## Support
256
285
 
257
286
  The team is always here to help you. Happen to face an issue? Want to report a bug? You can submit one here on GitHub using the [Issue Tracker](https://github.com/SallaApp/twilight-vscode-extension/issues/new). If you still have any questions, please contact us via the [Telegram Bot](https://t.me/SallaSupportBot) or join the Global Developer Community on [Telegram](https://t.me/salladev).