@tellyouai/plugin 0.1.6 → 0.1.7
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/dist/package/index.js +220 -227
- package/dist/package/public.d.ts +1 -5
- package/package.json +2 -1
package/dist/package/index.js
CHANGED
|
@@ -22308,14 +22308,11 @@ var A, j, M, N, P, F, ne, re, ie, ae, oe, I, se, ce, le, ue, de, fe, pe, L, me,
|
|
|
22308
22308
|
}, Nt = (e) => document.querySelector(e)?.textContent?.replace(/\s+/g, " ").trim() || void 0, Pt = () => {
|
|
22309
22309
|
let e = At();
|
|
22310
22310
|
return document.body.classList.contains("woocommerce") || document.body.classList.contains("woocommerce-page") || e.wc_add_to_cart_params || e.wc_cart_fragments_params ? "woocommerce" : e.Shopify || e.ShopifyAnalytics ? "shopify" : e.BCData || Mt(/BigCommerce/i) ? "bigcommerce" : e.checkoutConfig || document.querySelector("script[src*=\"/static/version\"]") || document.querySelector("body[data-container='body'] [data-mage-init]") ? "magento" : e.Squarespace || e.Static?.SQUARESPACE_CONTEXT ? "squarespace" : e.wixBiSession || e.Wix || Mt(/Wix\.com/i) ? "wix" : e.wp || e.wpApiSettings || Mt(/WordPress/i) ? "wordpress" : "unknown";
|
|
22311
|
-
}, Ft = (e) => {
|
|
22312
|
-
|
|
22313
|
-
|
|
22314
|
-
|
|
22315
|
-
|
|
22316
|
-
description: t?.description || ""
|
|
22317
|
-
}));
|
|
22318
|
-
}, It = (e) => {
|
|
22311
|
+
}, Ft = (e, t = []) => ({
|
|
22312
|
+
type: "object",
|
|
22313
|
+
properties: e,
|
|
22314
|
+
required: t
|
|
22315
|
+
}), It = (e) => {
|
|
22319
22316
|
let t = new URL(e, window.location.origin);
|
|
22320
22317
|
if (t.protocol !== "http:" && t.protocol !== "https:") throw Error("Unsupported URL scheme");
|
|
22321
22318
|
if (t.origin !== window.location.origin) throw Error("Refusing to navigate off-site");
|
|
@@ -22323,11 +22320,10 @@ var A, j, M, N, P, F, ne, re, ie, ae, oe, I, se, ce, le, ue, de, fe, pe, L, me,
|
|
|
22323
22320
|
}, Lt = () => ({
|
|
22324
22321
|
"navigate-to": {
|
|
22325
22322
|
description: "Navigate the user to a page on this site. Accepts a relative path (e.g. /about, /contact) or a full same-origin URL.",
|
|
22326
|
-
|
|
22327
|
-
name: "path",
|
|
22323
|
+
inputSchema: Ft({ path: {
|
|
22328
22324
|
type: "string",
|
|
22329
22325
|
description: "Destination path or same-origin URL to navigate the user to."
|
|
22330
|
-
}],
|
|
22326
|
+
} }, ["path"]),
|
|
22331
22327
|
execute: async ({ path: e }) => {
|
|
22332
22328
|
let t = String(e || "").trim();
|
|
22333
22329
|
if (!t) throw Error("No destination provided");
|
|
@@ -22340,13 +22336,13 @@ var A, j, M, N, P, F, ne, re, ie, ae, oe, I, se, ce, le, ue, de, fe, pe, L, me,
|
|
|
22340
22336
|
},
|
|
22341
22337
|
"go-back": {
|
|
22342
22338
|
description: "Navigate the user back to the previous page.",
|
|
22343
|
-
|
|
22339
|
+
inputSchema: Ft({}),
|
|
22344
22340
|
execute: async () => (window.history.back(), { success: !0 })
|
|
22345
22341
|
}
|
|
22346
22342
|
}), Rt = () => ({
|
|
22347
22343
|
"get-page-content": {
|
|
22348
22344
|
description: "Get the main text content of the page the user is currently viewing, so it can be summarised or answered from directly in the chat.",
|
|
22349
|
-
|
|
22345
|
+
inputSchema: Ft({}),
|
|
22350
22346
|
execute: async () => {
|
|
22351
22347
|
let e = ((document.querySelector("main, article, [role='main'], #content, .entry-content") || document.body).textContent || "").replace(/\s+/g, " ").trim().slice(0, 8e3);
|
|
22352
22348
|
return {
|
|
@@ -22358,11 +22354,10 @@ var A, j, M, N, P, F, ne, re, ie, ae, oe, I, se, ce, le, ue, de, fe, pe, L, me,
|
|
|
22358
22354
|
},
|
|
22359
22355
|
"scroll-to": {
|
|
22360
22356
|
description: "Scroll the current page to the first heading or section whose text matches the given query, and briefly highlight it.",
|
|
22361
|
-
|
|
22362
|
-
name: "query",
|
|
22357
|
+
inputSchema: Ft({ query: {
|
|
22363
22358
|
type: "string",
|
|
22364
22359
|
description: "Text to find on the page and scroll to."
|
|
22365
|
-
}],
|
|
22360
|
+
} }, ["query"]),
|
|
22366
22361
|
execute: async ({ query: e }) => {
|
|
22367
22362
|
let t = String(e || "").trim().toLowerCase();
|
|
22368
22363
|
if (!t) throw Error("No text to scroll to");
|
|
@@ -22407,15 +22402,16 @@ var A, j, M, N, P, F, ne, re, ie, ae, oe, I, se, ce, le, ue, de, fe, pe, L, me,
|
|
|
22407
22402
|
}), Vt = () => ({
|
|
22408
22403
|
"get-post": {
|
|
22409
22404
|
description: "Fetch the full content of a WordPress post or page by its ID or slug, so it can be answered from directly in the chat.",
|
|
22410
|
-
|
|
22411
|
-
|
|
22412
|
-
|
|
22413
|
-
|
|
22414
|
-
|
|
22415
|
-
|
|
22416
|
-
|
|
22417
|
-
|
|
22418
|
-
|
|
22405
|
+
inputSchema: Ft({
|
|
22406
|
+
id: {
|
|
22407
|
+
type: "string",
|
|
22408
|
+
description: "The post/page ID. Provide this or slug."
|
|
22409
|
+
},
|
|
22410
|
+
slug: {
|
|
22411
|
+
type: "string",
|
|
22412
|
+
description: "The post/page slug. Provide this or id."
|
|
22413
|
+
}
|
|
22414
|
+
}),
|
|
22419
22415
|
execute: async ({ id: e, slug: t }) => {
|
|
22420
22416
|
let n = String(e || "").trim(), r = String(t || "").trim();
|
|
22421
22417
|
if (!n && !r) throw Error("Provide a post id or slug");
|
|
@@ -22439,11 +22435,10 @@ var A, j, M, N, P, F, ne, re, ie, ae, oe, I, se, ce, le, ue, de, fe, pe, L, me,
|
|
|
22439
22435
|
},
|
|
22440
22436
|
"list-recent-posts": {
|
|
22441
22437
|
description: "List the most recent posts on this WordPress site (title + link).",
|
|
22442
|
-
|
|
22443
|
-
name: "limit",
|
|
22438
|
+
inputSchema: Ft({ limit: {
|
|
22444
22439
|
type: "number",
|
|
22445
22440
|
description: "How many posts to return. Defaults to 5."
|
|
22446
|
-
}
|
|
22441
|
+
} }),
|
|
22447
22442
|
execute: async ({ limit: e }) => {
|
|
22448
22443
|
let t = Math.min(Math.max(Number(e) || 5, 1), 20), n = await fetch(`/wp-json/wp/v2/posts?per_page=${t}&orderby=date&_fields=id,title,link,date`, {
|
|
22449
22444
|
headers: { Accept: "application/json" },
|
|
@@ -22464,7 +22459,7 @@ var A, j, M, N, P, F, ne, re, ie, ae, oe, I, se, ce, le, ue, de, fe, pe, L, me,
|
|
|
22464
22459
|
},
|
|
22465
22460
|
"get-site-info": {
|
|
22466
22461
|
description: "Get basic information about this WordPress site (name, description, home URL).",
|
|
22467
|
-
|
|
22462
|
+
inputSchema: Ft({}),
|
|
22468
22463
|
execute: async () => {
|
|
22469
22464
|
let e = await fetch("/wp-json", {
|
|
22470
22465
|
headers: { Accept: "application/json" },
|
|
@@ -22482,15 +22477,16 @@ var A, j, M, N, P, F, ne, re, ie, ae, oe, I, se, ce, le, ue, de, fe, pe, L, me,
|
|
|
22482
22477
|
}), Ht = () => ({
|
|
22483
22478
|
"search-site": {
|
|
22484
22479
|
description: "Search this WordPress site's posts and pages and return the matching results (title + link) so they can be shown directly in the chat.",
|
|
22485
|
-
|
|
22486
|
-
|
|
22487
|
-
|
|
22488
|
-
|
|
22489
|
-
|
|
22490
|
-
|
|
22491
|
-
|
|
22492
|
-
|
|
22493
|
-
|
|
22480
|
+
inputSchema: Ft({
|
|
22481
|
+
query: {
|
|
22482
|
+
type: "string",
|
|
22483
|
+
description: "The search terms."
|
|
22484
|
+
},
|
|
22485
|
+
limit: {
|
|
22486
|
+
type: "number",
|
|
22487
|
+
description: "Maximum number of results to return. Defaults to 5."
|
|
22488
|
+
}
|
|
22489
|
+
}, ["query"]),
|
|
22494
22490
|
execute: async ({ query: e, limit: t }) => {
|
|
22495
22491
|
let n = String(e || "").trim();
|
|
22496
22492
|
if (!n) throw Error("No search query provided");
|
|
@@ -22513,11 +22509,10 @@ var A, j, M, N, P, F, ne, re, ie, ae, oe, I, se, ce, le, ue, de, fe, pe, L, me,
|
|
|
22513
22509
|
},
|
|
22514
22510
|
"open-search-results": {
|
|
22515
22511
|
description: "Open the site's search results page for the given query in the browser.",
|
|
22516
|
-
|
|
22517
|
-
name: "query",
|
|
22512
|
+
inputSchema: Ft({ query: {
|
|
22518
22513
|
type: "string",
|
|
22519
22514
|
description: "The search terms."
|
|
22520
|
-
}],
|
|
22515
|
+
} }, ["query"]),
|
|
22521
22516
|
execute: async ({ query: e }) => {
|
|
22522
22517
|
let t = String(e || "").trim();
|
|
22523
22518
|
if (!t) throw Error("No search query provided");
|
|
@@ -22548,15 +22543,16 @@ var A, j, M, N, P, F, ne, re, ie, ae, oe, I, se, ce, le, ue, de, fe, pe, L, me,
|
|
|
22548
22543
|
...Vt(),
|
|
22549
22544
|
"search-products": {
|
|
22550
22545
|
description: "Search this store's products and return the matches (name, price, link) so they can be shown directly in the chat.",
|
|
22551
|
-
|
|
22552
|
-
|
|
22553
|
-
|
|
22554
|
-
|
|
22555
|
-
|
|
22556
|
-
|
|
22557
|
-
|
|
22558
|
-
|
|
22559
|
-
|
|
22546
|
+
inputSchema: Ft({
|
|
22547
|
+
query: {
|
|
22548
|
+
type: "string",
|
|
22549
|
+
description: "The product search terms."
|
|
22550
|
+
},
|
|
22551
|
+
limit: {
|
|
22552
|
+
type: "number",
|
|
22553
|
+
description: "Maximum number of results to return. Defaults to 5."
|
|
22554
|
+
}
|
|
22555
|
+
}, ["query"]),
|
|
22560
22556
|
execute: async ({ query: e, limit: t }) => {
|
|
22561
22557
|
let n = String(e || "").trim();
|
|
22562
22558
|
if (!n) throw Error("No search query provided");
|
|
@@ -22581,11 +22577,10 @@ var A, j, M, N, P, F, ne, re, ie, ae, oe, I, se, ce, le, ue, de, fe, pe, L, me,
|
|
|
22581
22577
|
},
|
|
22582
22578
|
"get-product-details": {
|
|
22583
22579
|
description: "Get full details for a product (description, price, stock, variations). Defaults to the product the user is currently viewing.",
|
|
22584
|
-
|
|
22585
|
-
name: "productId",
|
|
22580
|
+
inputSchema: Ft({ productId: {
|
|
22586
22581
|
type: "string",
|
|
22587
22582
|
description: "WooCommerce product ID. Omit to use the current product."
|
|
22588
|
-
}
|
|
22583
|
+
} }),
|
|
22589
22584
|
execute: async ({ productId: t }) => {
|
|
22590
22585
|
let n = String(t || e?.productId || "").trim();
|
|
22591
22586
|
if (!n) throw Error("No product specified");
|
|
@@ -22607,7 +22602,7 @@ var A, j, M, N, P, F, ne, re, ie, ae, oe, I, se, ce, le, ue, de, fe, pe, L, me,
|
|
|
22607
22602
|
},
|
|
22608
22603
|
"view-cart": {
|
|
22609
22604
|
description: "Read the current shopping cart and return its items and total so they can be shown in the chat.",
|
|
22610
|
-
|
|
22605
|
+
inputSchema: Ft({}),
|
|
22611
22606
|
execute: async () => {
|
|
22612
22607
|
let e = await fetch("/wp-json/wc/store/v1/cart", {
|
|
22613
22608
|
headers: { Accept: "application/json" },
|
|
@@ -22630,15 +22625,16 @@ var A, j, M, N, P, F, ne, re, ie, ae, oe, I, se, ce, le, ue, de, fe, pe, L, me,
|
|
|
22630
22625
|
},
|
|
22631
22626
|
"update-cart-quantity": {
|
|
22632
22627
|
description: "Change the quantity of a product already in the cart. Defaults to the product the user is currently viewing.",
|
|
22633
|
-
|
|
22634
|
-
|
|
22635
|
-
|
|
22636
|
-
|
|
22637
|
-
|
|
22638
|
-
|
|
22639
|
-
|
|
22640
|
-
|
|
22641
|
-
|
|
22628
|
+
inputSchema: Ft({
|
|
22629
|
+
productId: {
|
|
22630
|
+
type: "string",
|
|
22631
|
+
description: "WooCommerce product ID. Omit to use the current product."
|
|
22632
|
+
},
|
|
22633
|
+
quantity: {
|
|
22634
|
+
type: "number",
|
|
22635
|
+
description: "The new quantity (use 0 to remove)."
|
|
22636
|
+
}
|
|
22637
|
+
}, ["quantity"]),
|
|
22642
22638
|
execute: async ({ productId: t, quantity: r }) => {
|
|
22643
22639
|
let i = String(t || e?.productId || "").trim();
|
|
22644
22640
|
if (!i) throw Error("No product specified");
|
|
@@ -22668,11 +22664,10 @@ var A, j, M, N, P, F, ne, re, ie, ae, oe, I, se, ce, le, ue, de, fe, pe, L, me,
|
|
|
22668
22664
|
},
|
|
22669
22665
|
"apply-coupon": {
|
|
22670
22666
|
description: "Apply a discount coupon code to the cart.",
|
|
22671
|
-
|
|
22672
|
-
name: "code",
|
|
22667
|
+
inputSchema: Ft({ code: {
|
|
22673
22668
|
type: "string",
|
|
22674
22669
|
description: "The coupon code to apply."
|
|
22675
|
-
}],
|
|
22670
|
+
} }, ["code"]),
|
|
22676
22671
|
execute: async ({ code: e }) => {
|
|
22677
22672
|
let t = String(e || "").trim();
|
|
22678
22673
|
if (!t) throw Error("No coupon code provided");
|
|
@@ -22694,15 +22689,16 @@ var A, j, M, N, P, F, ne, re, ie, ae, oe, I, se, ce, le, ue, de, fe, pe, L, me,
|
|
|
22694
22689
|
},
|
|
22695
22690
|
"add-to-cart": {
|
|
22696
22691
|
description: "Add a product to the shopping cart. Defaults to the product the user is currently viewing if no productId is given.",
|
|
22697
|
-
|
|
22698
|
-
|
|
22699
|
-
|
|
22700
|
-
|
|
22701
|
-
|
|
22702
|
-
|
|
22703
|
-
|
|
22704
|
-
|
|
22705
|
-
|
|
22692
|
+
inputSchema: Ft({
|
|
22693
|
+
productId: {
|
|
22694
|
+
type: "string",
|
|
22695
|
+
description: "WooCommerce product ID. Omit to use the current product."
|
|
22696
|
+
},
|
|
22697
|
+
quantity: {
|
|
22698
|
+
type: "number",
|
|
22699
|
+
description: "Quantity to add. Defaults to 1."
|
|
22700
|
+
}
|
|
22701
|
+
}),
|
|
22706
22702
|
execute: async ({ productId: t, quantity: r }) => {
|
|
22707
22703
|
let i = String(t || e?.productId || "").trim();
|
|
22708
22704
|
if (!i) throw Error("No product to add to cart");
|
|
@@ -22725,11 +22721,10 @@ var A, j, M, N, P, F, ne, re, ie, ae, oe, I, se, ce, le, ue, de, fe, pe, L, me,
|
|
|
22725
22721
|
},
|
|
22726
22722
|
"remove-from-cart": {
|
|
22727
22723
|
description: "Remove a product from the shopping cart. Defaults to the product the user is currently viewing if no productId is given.",
|
|
22728
|
-
|
|
22729
|
-
name: "productId",
|
|
22724
|
+
inputSchema: Ft({ productId: {
|
|
22730
22725
|
type: "string",
|
|
22731
22726
|
description: "WooCommerce product ID to remove. Omit to use the current product."
|
|
22732
|
-
}
|
|
22727
|
+
} }),
|
|
22733
22728
|
execute: async ({ productId: t }) => {
|
|
22734
22729
|
let r = String(t || e?.productId || "").trim();
|
|
22735
22730
|
if (!r) throw Error("No product to remove from cart");
|
|
@@ -22760,7 +22755,7 @@ var A, j, M, N, P, F, ne, re, ie, ae, oe, I, se, ce, le, ue, de, fe, pe, L, me,
|
|
|
22760
22755
|
},
|
|
22761
22756
|
"go-to-checkout": {
|
|
22762
22757
|
description: "Navigate the user to the checkout page.",
|
|
22763
|
-
|
|
22758
|
+
inputSchema: Ft({}),
|
|
22764
22759
|
execute: async () => (window.location.assign("/checkout/"), { success: !0 })
|
|
22765
22760
|
}
|
|
22766
22761
|
}
|
|
@@ -22776,15 +22771,16 @@ var A, j, M, N, P, F, ne, re, ie, ae, oe, I, se, ce, le, ue, de, fe, pe, L, me,
|
|
|
22776
22771
|
clientTools: {
|
|
22777
22772
|
"search-products": {
|
|
22778
22773
|
description: "Search this store's products and return the matches (title, price, link) so they can be shown directly in the chat.",
|
|
22779
|
-
|
|
22780
|
-
|
|
22781
|
-
|
|
22782
|
-
|
|
22783
|
-
|
|
22784
|
-
|
|
22785
|
-
|
|
22786
|
-
|
|
22787
|
-
|
|
22774
|
+
inputSchema: Ft({
|
|
22775
|
+
query: {
|
|
22776
|
+
type: "string",
|
|
22777
|
+
description: "The product search terms."
|
|
22778
|
+
},
|
|
22779
|
+
limit: {
|
|
22780
|
+
type: "number",
|
|
22781
|
+
description: "Maximum number of results to return. Defaults to 5."
|
|
22782
|
+
}
|
|
22783
|
+
}, ["query"]),
|
|
22788
22784
|
execute: async ({ query: e, limit: t }) => {
|
|
22789
22785
|
let n = String(e || "").trim();
|
|
22790
22786
|
if (!n) throw Error("No search query provided");
|
|
@@ -22808,7 +22804,7 @@ var A, j, M, N, P, F, ne, re, ie, ae, oe, I, se, ce, le, ue, de, fe, pe, L, me,
|
|
|
22808
22804
|
},
|
|
22809
22805
|
"view-cart": {
|
|
22810
22806
|
description: "Read the current cart and return its items and total so they can be shown in the chat.",
|
|
22811
|
-
|
|
22807
|
+
inputSchema: Ft({}),
|
|
22812
22808
|
execute: async () => {
|
|
22813
22809
|
let e = await fetch("/cart.js", {
|
|
22814
22810
|
headers: { Accept: "application/json" },
|
|
@@ -22831,15 +22827,16 @@ var A, j, M, N, P, F, ne, re, ie, ae, oe, I, se, ce, le, ue, de, fe, pe, L, me,
|
|
|
22831
22827
|
},
|
|
22832
22828
|
"add-to-cart": {
|
|
22833
22829
|
description: "Add a product variant to the cart. Defaults to the variant of the product the user is currently viewing.",
|
|
22834
|
-
|
|
22835
|
-
|
|
22836
|
-
|
|
22837
|
-
|
|
22838
|
-
|
|
22839
|
-
|
|
22840
|
-
|
|
22841
|
-
|
|
22842
|
-
|
|
22830
|
+
inputSchema: Ft({
|
|
22831
|
+
variantId: {
|
|
22832
|
+
type: "string",
|
|
22833
|
+
description: "Shopify variant ID. Omit to use the current variant."
|
|
22834
|
+
},
|
|
22835
|
+
quantity: {
|
|
22836
|
+
type: "number",
|
|
22837
|
+
description: "Quantity to add. Defaults to 1."
|
|
22838
|
+
}
|
|
22839
|
+
}),
|
|
22843
22840
|
execute: async ({ variantId: e, quantity: t }) => {
|
|
22844
22841
|
let r = String(e || n || "").trim();
|
|
22845
22842
|
if (!r) throw Error("No variant to add to cart");
|
|
@@ -22858,15 +22855,16 @@ var A, j, M, N, P, F, ne, re, ie, ae, oe, I, se, ce, le, ue, de, fe, pe, L, me,
|
|
|
22858
22855
|
},
|
|
22859
22856
|
"update-cart-quantity": {
|
|
22860
22857
|
description: "Change the quantity of a variant already in the cart. Defaults to the current variant. Use 0 to remove it.",
|
|
22861
|
-
|
|
22862
|
-
|
|
22863
|
-
|
|
22864
|
-
|
|
22865
|
-
|
|
22866
|
-
|
|
22867
|
-
|
|
22868
|
-
|
|
22869
|
-
|
|
22858
|
+
inputSchema: Ft({
|
|
22859
|
+
variantId: {
|
|
22860
|
+
type: "string",
|
|
22861
|
+
description: "Shopify variant ID. Omit to use the current variant."
|
|
22862
|
+
},
|
|
22863
|
+
quantity: {
|
|
22864
|
+
type: "number",
|
|
22865
|
+
description: "The new quantity (use 0 to remove)."
|
|
22866
|
+
}
|
|
22867
|
+
}, ["quantity"]),
|
|
22870
22868
|
execute: async ({ variantId: e, quantity: t }) => {
|
|
22871
22869
|
let r = String(e || n || "").trim();
|
|
22872
22870
|
if (!r) throw Error("No variant specified");
|
|
@@ -22885,11 +22883,10 @@ var A, j, M, N, P, F, ne, re, ie, ae, oe, I, se, ce, le, ue, de, fe, pe, L, me,
|
|
|
22885
22883
|
},
|
|
22886
22884
|
"remove-from-cart": {
|
|
22887
22885
|
description: "Remove a product variant from the cart. Defaults to the variant of the product the user is currently viewing.",
|
|
22888
|
-
|
|
22889
|
-
name: "variantId",
|
|
22886
|
+
inputSchema: Ft({ variantId: {
|
|
22890
22887
|
type: "string",
|
|
22891
22888
|
description: "Shopify variant ID to remove. Omit to use the current variant."
|
|
22892
|
-
}
|
|
22889
|
+
} }),
|
|
22893
22890
|
execute: async ({ variantId: e }) => {
|
|
22894
22891
|
let t = String(e || n || "").trim();
|
|
22895
22892
|
if (!t) throw Error("No variant to remove from cart");
|
|
@@ -22908,7 +22905,7 @@ var A, j, M, N, P, F, ne, re, ie, ae, oe, I, se, ce, le, ue, de, fe, pe, L, me,
|
|
|
22908
22905
|
},
|
|
22909
22906
|
"go-to-checkout": {
|
|
22910
22907
|
description: "Navigate the user to the checkout page.",
|
|
22911
|
-
|
|
22908
|
+
inputSchema: Ft({}),
|
|
22912
22909
|
execute: async () => (window.location.assign("/checkout"), { success: !0 })
|
|
22913
22910
|
}
|
|
22914
22911
|
}
|
|
@@ -22925,15 +22922,16 @@ var A, j, M, N, P, F, ne, re, ie, ae, oe, I, se, ce, le, ue, de, fe, pe, L, me,
|
|
|
22925
22922
|
clientTools: {
|
|
22926
22923
|
"add-to-cart": {
|
|
22927
22924
|
description: "Add a product to the cart. Defaults to the product the user is currently viewing.",
|
|
22928
|
-
|
|
22929
|
-
|
|
22930
|
-
|
|
22931
|
-
|
|
22932
|
-
|
|
22933
|
-
|
|
22934
|
-
|
|
22935
|
-
|
|
22936
|
-
|
|
22925
|
+
inputSchema: Ft({
|
|
22926
|
+
productId: {
|
|
22927
|
+
type: "string",
|
|
22928
|
+
description: "BigCommerce product ID. Omit to use the current product."
|
|
22929
|
+
},
|
|
22930
|
+
quantity: {
|
|
22931
|
+
type: "number",
|
|
22932
|
+
description: "Quantity to add. Defaults to 1."
|
|
22933
|
+
}
|
|
22934
|
+
}),
|
|
22937
22935
|
execute: async ({ productId: t, quantity: n }) => {
|
|
22938
22936
|
let r = String(t || e || "").trim();
|
|
22939
22937
|
if (!r) throw Error("No product to add to cart");
|
|
@@ -22952,7 +22950,7 @@ var A, j, M, N, P, F, ne, re, ie, ae, oe, I, se, ce, le, ue, de, fe, pe, L, me,
|
|
|
22952
22950
|
},
|
|
22953
22951
|
"go-to-checkout": {
|
|
22954
22952
|
description: "Navigate the user to the checkout page.",
|
|
22955
|
-
|
|
22953
|
+
inputSchema: Ft({}),
|
|
22956
22954
|
execute: async () => (window.location.assign("/checkout"), { success: !0 })
|
|
22957
22955
|
}
|
|
22958
22956
|
}
|
|
@@ -22968,7 +22966,7 @@ var A, j, M, N, P, F, ne, re, ie, ae, oe, I, se, ce, le, ue, de, fe, pe, L, me,
|
|
|
22968
22966
|
context: e,
|
|
22969
22967
|
clientTools: { "go-to-checkout": {
|
|
22970
22968
|
description: "Navigate the user to the checkout page.",
|
|
22971
|
-
|
|
22969
|
+
inputSchema: Ft({}),
|
|
22972
22970
|
execute: async () => (window.location.assign("/checkout"), { success: !0 })
|
|
22973
22971
|
} }
|
|
22974
22972
|
};
|
|
@@ -22990,22 +22988,20 @@ var A, j, M, N, P, F, ne, re, ie, ae, oe, I, se, ce, le, ue, de, fe, pe, L, me,
|
|
|
22990
22988
|
pageUrl: window.location.href
|
|
22991
22989
|
},
|
|
22992
22990
|
clientTools: {}
|
|
22993
|
-
}), Xt = () => {
|
|
22994
|
-
let
|
|
22995
|
-
if (!
|
|
22996
|
-
let t = [];
|
|
22991
|
+
}), Xt = async (e = !0) => {
|
|
22992
|
+
let t = document.modelContext;
|
|
22993
|
+
if (!t || typeof t.getTools != "function") return {};
|
|
22997
22994
|
try {
|
|
22998
|
-
|
|
22995
|
+
let n = await t.getTools(), r = Object.create(null);
|
|
22996
|
+
for (let i of n) i && typeof i.name == "string" && (e !== "readonly" || i.annotations?.readOnlyHint === !0) && (r[i.name] = {
|
|
22997
|
+
description: i.description || i.name,
|
|
22998
|
+
inputSchema: i.inputSchema && typeof i.inputSchema == "object" ? i.inputSchema : Ft({}),
|
|
22999
|
+
execute: async (e) => JSON.parse(await t.executeTool(i, e))
|
|
23000
|
+
});
|
|
23001
|
+
return r;
|
|
22999
23002
|
} catch (e) {
|
|
23000
|
-
return console.warn("modelContext tool
|
|
23003
|
+
return console.warn("modelContext tool discovery failed", e), {};
|
|
23001
23004
|
}
|
|
23002
|
-
let n = {};
|
|
23003
|
-
for (let e of t) e && typeof e.name == "string" && typeof e.execute == "function" && (n[e.name] = {
|
|
23004
|
-
description: e.description || e.name,
|
|
23005
|
-
parameters: Ft(e.inputSchema || e.parameters),
|
|
23006
|
-
execute: (t) => e.execute(t)
|
|
23007
|
-
});
|
|
23008
|
-
return n;
|
|
23009
23005
|
}, Zt = (e) => {
|
|
23010
23006
|
switch (e) {
|
|
23011
23007
|
case "woocommerce": return Wt();
|
|
@@ -23017,24 +23013,23 @@ var A, j, M, N, P, F, ne, re, ie, ae, oe, I, se, ce, le, ue, de, fe, pe, L, me,
|
|
|
23017
23013
|
case "wordpress": return Bt();
|
|
23018
23014
|
default: return {};
|
|
23019
23015
|
}
|
|
23020
|
-
}, Qt = (e = !0) => {
|
|
23021
|
-
let t = Pt(), n = Zt(t), r = Xt(), i =
|
|
23016
|
+
}, Qt = async (e = !0) => {
|
|
23017
|
+
let t = Pt(), n = Zt(t), r = await Xt(e), i = {
|
|
23022
23018
|
...Lt(),
|
|
23023
23019
|
...Rt(),
|
|
23024
23020
|
...n.clientTools || {},
|
|
23025
23021
|
...r
|
|
23026
|
-
},
|
|
23027
|
-
e === "readonly" && (
|
|
23028
|
-
let
|
|
23029
|
-
return
|
|
23022
|
+
}, a = i;
|
|
23023
|
+
e === "readonly" && (a = Object.fromEntries(Object.entries(i).filter(([e]) => !!r[e] || !kt.has(e))));
|
|
23024
|
+
let o = Object.keys(a), s = e === "readonly" ? Object.keys(i).filter((e) => !a[e]) : [], c = `${t}|${e}|${o.join(",")}`;
|
|
23025
|
+
return c !== jt && (jt = c, console.log(`Tellyou AI: premade tools — platform="${t}", mode="${e}", ${o.length} tool(s) added`, {
|
|
23030
23026
|
platform: t,
|
|
23031
23027
|
mode: e,
|
|
23032
|
-
tools:
|
|
23033
|
-
...
|
|
23034
|
-
...c.length ? { strippedWriteTools: c } : {}
|
|
23028
|
+
tools: o,
|
|
23029
|
+
...s.length ? { strippedWriteTools: s } : {}
|
|
23035
23030
|
})), {
|
|
23036
23031
|
context: n.context,
|
|
23037
|
-
clientTools:
|
|
23032
|
+
clientTools: a
|
|
23038
23033
|
};
|
|
23039
23034
|
};
|
|
23040
23035
|
})), en = /* @__PURE__ */ s(((e) => {
|
|
@@ -23220,30 +23215,19 @@ var A, j, M, N, P, F, ne, re, ie, ae, oe, I, se, ce, le, ue, de, fe, pe, L, me,
|
|
|
23220
23215
|
let t = window.tellyouai || {}, n = Array.isArray(t) ? t : [t], r = n[e] ? { ...n[e] } : {};
|
|
23221
23216
|
r.user ||= { name: " " };
|
|
23222
23217
|
let i = document.title || window.location.pathname;
|
|
23223
|
-
|
|
23224
|
-
let e = Qt(r.autoTools ?? !0);
|
|
23225
|
-
e.clientTools && (r.clientTools = {
|
|
23226
|
-
...e.clientTools,
|
|
23227
|
-
...r.clientTools || {}
|
|
23228
|
-
}), e.context && (r.context = {
|
|
23229
|
-
...e.context,
|
|
23230
|
-
...r.context || {}
|
|
23231
|
-
});
|
|
23232
|
-
} catch (e) {
|
|
23233
|
-
console.warn(Vl + ": premade tools detection failed", e);
|
|
23234
|
-
}
|
|
23235
|
-
r.withSources === void 0 && (r.withSources = !1);
|
|
23218
|
+
r.user.name || (r.user.name = " "), r.context ||= { pageName: i }, r.withSources === void 0 && (r.withSources = !1);
|
|
23236
23219
|
let a = window.__tellyouaiEntryUrl || import.meta.url, o = new URLSearchParams(new URL(a).search), s = r.thingId || o.get("id") || void 0, c = r.entityId || o.get("entityId") || void 0, l = r.widgetId || o.get("widget") || o.get("widgetId") || void 0;
|
|
23237
23220
|
return !s && !c && console.error(Vl + ": id missing"), r.thingId = s, r.entityId = c, r.widgetId = l, r;
|
|
23238
23221
|
}, sn = (0, rn.createContext)({
|
|
23222
|
+
config: {},
|
|
23239
23223
|
thingId: void 0,
|
|
23240
23224
|
entityId: void 0,
|
|
23241
23225
|
widgetId: void 0,
|
|
23242
23226
|
target: "tellyouai-plugin",
|
|
23243
23227
|
isCustomTarget: !0,
|
|
23244
|
-
getDynamic: () => ({})
|
|
23228
|
+
getDynamic: async () => ({})
|
|
23245
23229
|
}), cn = ({ instanceIndex: e, target: t, isCustomTarget: n, children: r }) => {
|
|
23246
|
-
let i =
|
|
23230
|
+
let i = on(e), [, a] = (0, rn.useState)(0);
|
|
23247
23231
|
(0, rn.useEffect)(() => {
|
|
23248
23232
|
let e = (e) => {
|
|
23249
23233
|
let n = e.detail || {};
|
|
@@ -23251,15 +23235,31 @@ var A, j, M, N, P, F, ne, re, ie, ae, oe, I, se, ce, le, ue, de, fe, pe, L, me,
|
|
|
23251
23235
|
};
|
|
23252
23236
|
return window.addEventListener("tellyouai-config-changed", e), () => window.removeEventListener("tellyouai-config-changed", e);
|
|
23253
23237
|
}, [t]);
|
|
23254
|
-
let o = (0, rn.useCallback)(() =>
|
|
23255
|
-
|
|
23256
|
-
|
|
23257
|
-
|
|
23258
|
-
|
|
23259
|
-
|
|
23260
|
-
|
|
23238
|
+
let o = (0, rn.useCallback)(async () => {
|
|
23239
|
+
let t = on(e);
|
|
23240
|
+
if (t.autoTools !== !1) try {
|
|
23241
|
+
let e = await Qt(t.autoTools ?? !0);
|
|
23242
|
+
t.clientTools = {
|
|
23243
|
+
...e.clientTools,
|
|
23244
|
+
...t.clientTools
|
|
23245
|
+
}, t.context = {
|
|
23246
|
+
...e.context,
|
|
23247
|
+
...t.context
|
|
23248
|
+
};
|
|
23249
|
+
} catch (e) {
|
|
23250
|
+
console.warn(Vl + ": premade tools detection failed", e);
|
|
23251
|
+
}
|
|
23252
|
+
return {
|
|
23253
|
+
...t,
|
|
23254
|
+
target: void 0,
|
|
23255
|
+
thingId: void 0,
|
|
23256
|
+
entityId: void 0,
|
|
23257
|
+
widgetId: void 0
|
|
23258
|
+
};
|
|
23259
|
+
}, [e]);
|
|
23261
23260
|
return /* @__PURE__ */ (0, an.jsx)(sn.Provider, {
|
|
23262
23261
|
value: {
|
|
23262
|
+
config: i,
|
|
23263
23263
|
isCustomTarget: n,
|
|
23264
23264
|
target: t,
|
|
23265
23265
|
thingId: i.thingId,
|
|
@@ -32605,12 +32605,12 @@ var Tl, El, Dl, Ol, kl, Al, jl, Ml, Nl, Pl, Fl, Il = o((() => {
|
|
|
32605
32605
|
graphicType: t[12] || void 0
|
|
32606
32606
|
};
|
|
32607
32607
|
}, Kl = () => {
|
|
32608
|
-
let { thingId: e, entityId: t, widgetId: n,
|
|
32608
|
+
let { thingId: e, entityId: t, widgetId: n, config: r } = ql(), i = r.accessToken, a = !e && !t ? null : vn(`${Wl}${e ? `/${e}` : ""}`, {
|
|
32609
32609
|
entityId: t,
|
|
32610
32610
|
widget: n
|
|
32611
32611
|
}), { data: o, isLoading: s } = mt(a ? [a, i] : null, ([e, t]) => fetch(e, { headers: t ? { Authorization: `Bearer ${t}` } : void 0 }).then((e) => e.ok ? e : Promise.reject(e)).then((e) => e.json())), c = { ...o || {} };
|
|
32612
32612
|
c.withHelp === void 0 && (c.withHelp = !0), c.withVoice === void 0 && (c.withVoice = !!c.voiceId), c.withMessageAvatars === void 0 && (c.withMessageAvatars = !0), c.withQuickActions === void 0 && (c.withQuickActions = "visible-desktop"), c.quickActionsSpeed === void 0 && (c.quickActionsSpeed = "normal");
|
|
32613
|
-
let l = r
|
|
32613
|
+
let l = r.options;
|
|
32614
32614
|
return l?.theme !== void 0 && (c.theme = l.theme === "auto" ? void 0 : l.theme), l?.background !== void 0 && (c.background = l.background === "none" ? void 0 : l.background), l?.backgroundIntensity !== void 0 && (c.backgroundIntensity = l.backgroundIntensity), l?.borderRadius !== void 0 && (c.borderRadius = l.borderRadius), l?.shadow !== void 0 && (c.shadow = l.shadow), l?.avatarId !== void 0 && (c.avatarId = l.avatarId, l.avatarId && (c.mediaUrl = void 0)), l?.mediaUrl !== void 0 && (c.mediaUrl = l.mediaUrl, l.mediaUrl && (c.avatarId = void 0)), l?.mediaUrls !== void 0 && (c.mediaUrls = l.mediaUrls), l?.name !== void 0 && (c.name = l.name), l?.withEmoji !== void 0 && (c.withEmoji = l.withEmoji), l?.withFiles !== void 0 && (c.withFiles = l.withFiles), l?.withMessageAvatars !== void 0 && (c.withMessageAvatars = l.withMessageAvatars), l?.withDisplaySize !== void 0 && (c.withDisplaySize = l.withDisplaySize), l?.withLocale !== void 0 && (c.withLocale = l.withLocale), l?.withQuickActions !== void 0 && (c.withQuickActions = l.withQuickActions), l?.withVoice !== void 0 && (c.withVoice = l.withVoice), l?.greeting !== void 0 && (c.greeting = l.greeting), l?.quickActions !== void 0 && (c.quickActions = l.quickActions), l?.quickActionsSpeed !== void 0 && (c.quickActionsSpeed = l.quickActionsSpeed), l?.styles && (c.styles = {
|
|
32615
32615
|
...c.styles || {},
|
|
32616
32616
|
...l.styles
|
|
@@ -32759,7 +32759,7 @@ var Tl, El, Dl, Ol, kl, Al, jl, Ml, Nl, Pl, Fl, Il = o((() => {
|
|
|
32759
32759
|
};
|
|
32760
32760
|
})), vu, yu, bu, xu, Su = o((() => {
|
|
32761
32761
|
vu = /* @__PURE__ */ u(w(), 1), yu = /* @__PURE__ */ u(m(), 1), vt(), Dt(), $l(), _u(), bu = Vl + "Auth", xu = () => {
|
|
32762
|
-
let { thingId: e, entityId: t,
|
|
32762
|
+
let { thingId: e, entityId: t, config: n } = ql(), { user: r } = n, i = gu(n.consent), a = i.status !== "unknown" && i.functional, [o] = (0, yu.useState)(() => ({ entityId: Tt() })), { data: s, mutate: c, isLoading: l } = _t(a ? "auth" : null, async () => vu.default.getItem(bu)), u = r?.entityId, { data: d, isLoading: f } = _t(r?.id && !u && (e || t) ? [
|
|
32763
32763
|
"identified-auth",
|
|
32764
32764
|
e,
|
|
32765
32765
|
t,
|
|
@@ -41017,7 +41017,7 @@ var bp, xp, Sp, Cp, wp, Tp, Ep, Dp, Op, kp, Ap, jp, Mp, Np, Pp, Fp, Ip, Lp, Rp,
|
|
|
41017
41017
|
let r = await navigator.mediaDevices.enumerateDevices(), i = r.find((e) => e.kind === "audioinput" && e.deviceId === n), a = r.find((e) => e.kind === "audiooutput" && i?.groupId && e.groupId === i.groupId);
|
|
41018
41018
|
a && await e.setSinkId(a.deviceId);
|
|
41019
41019
|
}, lce = (e) => {
|
|
41020
|
-
let { config: { entityId: t } } = Kl(), { entityId: n } = xu(), { locale: r } = cA(), i = ql(), a = gu(i.
|
|
41020
|
+
let { config: { entityId: t } } = Kl(), { entityId: n } = xu(), { locale: r } = cA(), i = ql(), a = gu(i.config.consent), [o, s] = (0, lA.useState)([]), [c, l] = (0, lA.useState)(!1), [u, d] = (0, lA.useState)(!1), f = (0, lA.useRef)(null), p = (0, lA.useRef)(null), m = (0, lA.useRef)(null), h = (0, lA.useRef)(null), g = (0, lA.useRef)(null), _ = (0, lA.useRef)(0), v = (0, lA.useRef)(/* @__PURE__ */ new Set()), y = (0, lA.useRef)(null), b = (0, lA.useRef)(null), x = (0, lA.useCallback)((e) => {
|
|
41021
41021
|
s((t) => {
|
|
41022
41022
|
let n = e.filter((e) => t.some((t) => t.id === e.id)), r = e.filter((e) => !t.some((t) => t.id === e.id));
|
|
41023
41023
|
return [...t.map((e) => {
|
|
@@ -41110,14 +41110,7 @@ var bp, xp, Sp, Cp, wp, Tp, Ep, Dp, Op, kp, Ap, jp, Mp, Np, Pp, Fp, Ip, Lp, Rp,
|
|
|
41110
41110
|
type: "function",
|
|
41111
41111
|
name: e,
|
|
41112
41112
|
description: t.description,
|
|
41113
|
-
parameters:
|
|
41114
|
-
type: "object",
|
|
41115
|
-
properties: Object.fromEntries((t.parameters || []).map((e) => [e.name, {
|
|
41116
|
-
type: e.type,
|
|
41117
|
-
description: e.description
|
|
41118
|
-
}])),
|
|
41119
|
-
required: (t.parameters || []).map((e) => e.name)
|
|
41120
|
-
}
|
|
41113
|
+
parameters: t.inputSchema
|
|
41121
41114
|
}))
|
|
41122
41115
|
}));
|
|
41123
41116
|
}, x.onmessage = async (e) => {
|
|
@@ -41245,7 +41238,7 @@ var bp, xp, Sp, Cp, wp, Tp, Ep, Dp, Op, kp, Ap, jp, Mp, Np, Pp, Fp, Ip, Lp, Rp,
|
|
|
41245
41238
|
withResponse: t,
|
|
41246
41239
|
...o ? { aiEntityId: o } : {}
|
|
41247
41240
|
}), mce = (e, t = !1) => {
|
|
41248
|
-
let { config: { entityId: n, avatarId: r, mediaUrl: i, name: a } } = Kl(), {
|
|
41241
|
+
let { config: { entityId: n, avatarId: r, mediaUrl: i, name: a } } = Kl(), { config: o, getDynamic: s } = ql(), c = gu(o.consent), { entityId: l } = xu(), { data: u, isLoading: d } = mt(e && t ? `${Ul}/cm?chatId=${e}&count=100` : null, (e) => fetch(e).then((e) => e.ok ? e : Promise.reject(e)).then((e) => e.json()), { onError: (e) => console.warn("Failed to fetch chat messages:", e) }), [f, p] = (0, dA.useState)([]), [m, h] = (0, dA.useState)(!1), g = (0, dA.useCallback)((e) => {
|
|
41249
41242
|
if (e && e === n) return {
|
|
41250
41243
|
id: n,
|
|
41251
41244
|
name: a || "",
|
|
@@ -41257,8 +41250,8 @@ var bp, xp, Sp, Cp, wp, Tp, Ep, Dp, Op, kp, Ap, jp, Mp, Np, Pp, Fp, Ip, Lp, Rp,
|
|
|
41257
41250
|
i,
|
|
41258
41251
|
n,
|
|
41259
41252
|
a
|
|
41260
|
-
]),
|
|
41261
|
-
|
|
41253
|
+
]), _ = (0, dA.useCallback)((t) => {
|
|
41254
|
+
p((n) => {
|
|
41262
41255
|
let r = t.filter((e) => n.some((t) => t.id === e.id)), i = t.filter((e) => !n.some((t) => t.id === e.id));
|
|
41263
41256
|
return [...n.map((e) => {
|
|
41264
41257
|
let t = r.find((t) => t.id === e.id);
|
|
@@ -41271,15 +41264,15 @@ var bp, xp, Sp, Cp, wp, Tp, Ep, Dp, Op, kp, Ap, jp, Mp, Np, Pp, Fp, Ip, Lp, Rp,
|
|
|
41271
41264
|
id: t.id || Tt(),
|
|
41272
41265
|
createdAt: t.createdAt || /* @__PURE__ */ new Date(),
|
|
41273
41266
|
chatId: e,
|
|
41274
|
-
entity: t.entity ||
|
|
41267
|
+
entity: t.entity || g(t.entityId)
|
|
41275
41268
|
}))];
|
|
41276
41269
|
});
|
|
41277
|
-
}, [e,
|
|
41270
|
+
}, [e, g]), v = (0, dA.useEffectEvent)(_);
|
|
41278
41271
|
return (0, dA.useLayoutEffect)(() => {
|
|
41279
|
-
|
|
41272
|
+
p([]);
|
|
41280
41273
|
}, [e]), (0, dA.useEffect)(() => {
|
|
41281
|
-
|
|
41282
|
-
}, [
|
|
41274
|
+
u && v([...u].reverse());
|
|
41275
|
+
}, [u]), (0, dA.useEffect)(() => {
|
|
41283
41276
|
if (!e || !t) return;
|
|
41284
41277
|
let n = !1, r = `chatMessages:chat-${e}:${Tt()}`, i = xl.channel(r);
|
|
41285
41278
|
return i.on("postgres_changes", {
|
|
@@ -41288,48 +41281,48 @@ var bp, xp, Sp, Cp, wp, Tp, Ep, Dp, Op, kp, Ap, jp, Mp, Np, Pp, Fp, Ip, Lp, Rp,
|
|
|
41288
41281
|
table: "chatMessages",
|
|
41289
41282
|
filter: `chatId=eq.${e}`
|
|
41290
41283
|
}, async (e) => {
|
|
41291
|
-
let t = e.new, n =
|
|
41292
|
-
|
|
41284
|
+
let t = e.new, n = g(t.entityId);
|
|
41285
|
+
_([{
|
|
41293
41286
|
...t,
|
|
41294
41287
|
entity: n
|
|
41295
41288
|
}]);
|
|
41296
41289
|
}).subscribe((e) => {
|
|
41297
|
-
console.log(e), !n && e === "SUBSCRIBED" &&
|
|
41290
|
+
console.log(e), !n && e === "SUBSCRIBED" && h(!0);
|
|
41298
41291
|
}), () => {
|
|
41299
41292
|
n = !0, xl.removeChannel(i);
|
|
41300
41293
|
};
|
|
41301
41294
|
}, [
|
|
41302
41295
|
e,
|
|
41303
41296
|
t,
|
|
41304
|
-
|
|
41305
|
-
|
|
41297
|
+
g,
|
|
41298
|
+
_
|
|
41306
41299
|
]), {
|
|
41307
41300
|
sendMessage: (0, dA.useCallback)(async (t, r) => {
|
|
41308
|
-
let i =
|
|
41301
|
+
let i = l !== n, a = [], o = {
|
|
41309
41302
|
id: Tt(),
|
|
41310
41303
|
createdAt: /* @__PURE__ */ new Date(),
|
|
41311
|
-
entityId:
|
|
41304
|
+
entityId: l || "",
|
|
41312
41305
|
content: t,
|
|
41313
41306
|
chatId: e
|
|
41314
41307
|
};
|
|
41315
|
-
a.push(
|
|
41308
|
+
a.push(o);
|
|
41316
41309
|
let u = Tt();
|
|
41317
41310
|
i && a.push({
|
|
41318
41311
|
id: u,
|
|
41319
41312
|
entityId: n || "",
|
|
41320
|
-
entity:
|
|
41313
|
+
entity: g(n),
|
|
41321
41314
|
content: "",
|
|
41322
41315
|
status: "saving",
|
|
41323
41316
|
createdAt: /* @__PURE__ */ new Date(),
|
|
41324
41317
|
chatId: e
|
|
41325
|
-
}),
|
|
41326
|
-
let { clientTools: d, servers:
|
|
41318
|
+
}), p((e) => [...e.filter((e) => e.status !== "saving"), ...a]);
|
|
41319
|
+
let { clientTools: d, servers: f, context: m, user: h } = await s(), _ = await fetch(`${Ul}/cm/`, {
|
|
41327
41320
|
method: "POST",
|
|
41328
41321
|
headers: { "Content-Type": "application/json" },
|
|
41329
|
-
body: JSON.stringify(pce(
|
|
41322
|
+
body: JSON.stringify(pce(o, u, {
|
|
41330
41323
|
...m || {},
|
|
41331
41324
|
...r || {}
|
|
41332
|
-
},
|
|
41325
|
+
}, h, d, f, n, c.analytics))
|
|
41333
41326
|
});
|
|
41334
41327
|
if (!_.ok) throw _.statusText;
|
|
41335
41328
|
let v = _.body?.getReader(), y = new TextDecoder();
|
|
@@ -41353,7 +41346,7 @@ var bp, xp, Sp, Cp, wp, Tp, Ep, Dp, Op, kp, Ap, jp, Mp, Np, Pp, Fp, Ip, Lp, Rp,
|
|
|
41353
41346
|
...S[C],
|
|
41354
41347
|
type: "tool-call",
|
|
41355
41348
|
input: {}
|
|
41356
|
-
},
|
|
41349
|
+
}, p((e) => e.map((e) => e.id === u ? {
|
|
41357
41350
|
...e,
|
|
41358
41351
|
steps: [...S]
|
|
41359
41352
|
} : e))), t.type === "tool-input-delta" && t.delta && C >= 0 && S[C]) try {
|
|
@@ -41361,7 +41354,7 @@ var bp, xp, Sp, Cp, wp, Tp, Ep, Dp, Op, kp, Ap, jp, Mp, Np, Pp, Fp, Ip, Lp, Rp,
|
|
|
41361
41354
|
S[C].input = {
|
|
41362
41355
|
...S[C].input,
|
|
41363
41356
|
...e
|
|
41364
|
-
},
|
|
41357
|
+
}, p((e) => e.map((e) => e.id === u ? {
|
|
41365
41358
|
...e,
|
|
41366
41359
|
steps: [...S]
|
|
41367
41360
|
} : e));
|
|
@@ -41373,7 +41366,7 @@ var bp, xp, Sp, Cp, wp, Tp, Ep, Dp, Op, kp, Ap, jp, Mp, Np, Pp, Fp, Ip, Lp, Rp,
|
|
|
41373
41366
|
...S[C],
|
|
41374
41367
|
type: "tool-call",
|
|
41375
41368
|
input: t.input
|
|
41376
|
-
},
|
|
41369
|
+
}, p((e) => e.map((e) => e.id === u ? {
|
|
41377
41370
|
...e,
|
|
41378
41371
|
steps: [...S]
|
|
41379
41372
|
} : e));
|
|
@@ -41387,7 +41380,7 @@ var bp, xp, Sp, Cp, wp, Tp, Ep, Dp, Op, kp, Ap, jp, Mp, Np, Pp, Fp, Ip, Lp, Rp,
|
|
|
41387
41380
|
...S[C],
|
|
41388
41381
|
type: "tool-result",
|
|
41389
41382
|
text: JSON.stringify(e)
|
|
41390
|
-
},
|
|
41383
|
+
}, p((e) => e.map((e) => e.id === u ? {
|
|
41391
41384
|
...e,
|
|
41392
41385
|
steps: [...S]
|
|
41393
41386
|
} : e));
|
|
@@ -41396,7 +41389,7 @@ var bp, xp, Sp, Cp, wp, Tp, Ep, Dp, Op, kp, Ap, jp, Mp, Np, Pp, Fp, Ip, Lp, Rp,
|
|
|
41396
41389
|
...S[C],
|
|
41397
41390
|
type: "tool-result",
|
|
41398
41391
|
text: JSON.stringify({ error: t?.message || "Tool execution failed" })
|
|
41399
|
-
},
|
|
41392
|
+
}, p((e) => e.map((e) => e.id === u ? {
|
|
41400
41393
|
...e,
|
|
41401
41394
|
steps: [...S]
|
|
41402
41395
|
} : e));
|
|
@@ -41414,7 +41407,7 @@ var bp, xp, Sp, Cp, wp, Tp, Ep, Dp, Op, kp, Ap, jp, Mp, Np, Pp, Fp, Ip, Lp, Rp,
|
|
|
41414
41407
|
...S[C],
|
|
41415
41408
|
type: "tool-result",
|
|
41416
41409
|
text: JSON.stringify(t.output)
|
|
41417
|
-
},
|
|
41410
|
+
}, p((t) => t.map((t) => t.id === u ? {
|
|
41418
41411
|
...t,
|
|
41419
41412
|
steps: [...S],
|
|
41420
41413
|
structuredContent: e ?? t.structuredContent,
|
|
@@ -41423,16 +41416,16 @@ var bp, xp, Sp, Cp, wp, Tp, Ep, Dp, Op, kp, Ap, jp, Mp, Np, Pp, Fp, Ip, Lp, Rp,
|
|
|
41423
41416
|
}
|
|
41424
41417
|
if (t.type === "knowledges" && t.content) {
|
|
41425
41418
|
let e = t.content;
|
|
41426
|
-
|
|
41419
|
+
p((t) => t.map((t) => t.id === u ? {
|
|
41427
41420
|
...t,
|
|
41428
41421
|
knowledges: e
|
|
41429
41422
|
} : t));
|
|
41430
41423
|
}
|
|
41431
|
-
t.type === "text-delta" && t.text && (x += t.text,
|
|
41424
|
+
t.type === "text-delta" && t.text && (x += t.text, p((e) => e.map((e) => e.id === u ? {
|
|
41432
41425
|
...e,
|
|
41433
41426
|
content: x,
|
|
41434
41427
|
steps: [...S]
|
|
41435
|
-
} : e))), (t.type === "finish" || t.type === "finish-step") &&
|
|
41428
|
+
} : e))), (t.type === "finish" || t.type === "finish-step") && p((e) => e.map((e) => e.id === u ? {
|
|
41436
41429
|
...e,
|
|
41437
41430
|
content: x,
|
|
41438
41431
|
status: "sent",
|
|
@@ -41445,20 +41438,20 @@ var bp, xp, Sp, Cp, wp, Tp, Ep, Dp, Op, kp, Ap, jp, Mp, Np, Pp, Fp, Ip, Lp, Rp,
|
|
|
41445
41438
|
}
|
|
41446
41439
|
}
|
|
41447
41440
|
} finally {
|
|
41448
|
-
v.releaseLock(),
|
|
41441
|
+
v.releaseLock(), p((e) => e.filter((e) => e.status !== "saving"));
|
|
41449
41442
|
}
|
|
41450
41443
|
}, [
|
|
41451
|
-
|
|
41444
|
+
l,
|
|
41452
41445
|
n,
|
|
41453
41446
|
e,
|
|
41454
|
-
|
|
41455
|
-
|
|
41456
|
-
|
|
41447
|
+
s,
|
|
41448
|
+
g,
|
|
41449
|
+
c.analytics
|
|
41457
41450
|
]),
|
|
41458
|
-
messages:
|
|
41459
|
-
onMessages:
|
|
41460
|
-
isConnected:
|
|
41461
|
-
isLoading:
|
|
41451
|
+
messages: f,
|
|
41452
|
+
onMessages: _,
|
|
41453
|
+
isConnected: m,
|
|
41454
|
+
isLoading: d
|
|
41462
41455
|
};
|
|
41463
41456
|
}, hce = (e, t) => {
|
|
41464
41457
|
if (!t.length) return e;
|
|
@@ -41516,7 +41509,7 @@ var bp, xp, Sp, Cp, wp, Tp, Ep, Dp, Op, kp, Ap, jp, Mp, Np, Pp, Fp, Ip, Lp, Rp,
|
|
|
41516
41509
|
let t = e.toLowerCase();
|
|
41517
41510
|
return Cce.some((e) => t.includes(e));
|
|
41518
41511
|
}, wce = (e, t) => {
|
|
41519
|
-
let { target: n,
|
|
41512
|
+
let { target: n, config: r } = ql(), i = gu(r.consent), a = `${n}`, o = n, { locationKey: s } = t || {}, c = (t?.speed || 1e3) * 10, l = c / 3;
|
|
41520
41513
|
(0, pA.useEffect)(() => {
|
|
41521
41514
|
if (!mA(document.title)) return;
|
|
41522
41515
|
let t = setTimeout(() => {
|
|
@@ -67453,7 +67446,7 @@ var rV, iV, Bpe = o((() => {
|
|
|
67453
67446
|
};
|
|
67454
67447
|
})), gH, _H, vH, yH, bH, xH = o((() => {
|
|
67455
67448
|
gH = /* @__PURE__ */ u(m(), 1), Hp(), aA(), yA(), Ot(), _H = nn(), vH = (0, gH.createContext)({ setLocale: () => {} }), yH = () => (0, gH.useContext)(vH).setLocale, bH = ({ children: e }) => {
|
|
67456
|
-
let { config: { language: t, languages: n } } = Kl(), {
|
|
67449
|
+
let { config: { language: t, languages: n } } = Kl(), { config: r } = ql(), i = (r.languages || n || []).map(rA).filter((e) => !!e), a = rA(t), o = a && i.includes(a) ? a : i[0], s = i.includes(iA()) || !i.length ? iA() : o, [c, l] = (0, gH.useState)(s), u = !i?.length || i.includes(c);
|
|
67457
67450
|
(0, gH.useEffect)(() => {
|
|
67458
67451
|
u || l(s);
|
|
67459
67452
|
}, [u, s]);
|
|
@@ -68567,7 +68560,7 @@ var rV, iV, Bpe = o((() => {
|
|
|
68567
68560
|
};
|
|
68568
68561
|
})), Pq, Fq, Iq, eye = o((() => {
|
|
68569
68562
|
Pq = /* @__PURE__ */ u(m(), 1), yA(), Gpe(), fH(), hH(), Nq(), Fq = nn(), Iq = ({ canStore: e, displayMode: t, displaySize: n, onClickQuickAction: r, onClickDisplaySize: i, onMessages: a, sendMessage: o, children: s, onOpenChange: c, hasChatUserMessages: l, userMessages: u, mode: d, onClickNewChat: f, onClickCall: p, callIsConnected: m, callIsConnecting: h }) => {
|
|
68570
|
-
let { formatMessage: g } = cA(), { isMobile: _ } = Tu(), { config: { entityId: v, withQuickActions: y, quickActions: b, withLocale: x, withConsent: S, privacyUrl: C }, isLoading: w } = Kl(), { entityId: T } = xu(), E = y === "visible" || y === "visible-desktop" && !_, { background: D, styles: { color: O, borderColor: ee, backgroundColor70: k, spacingXS: te, spacingMD: A, marginRight: j, marginBottom: M, openerDimensions: N, transitionSpeed: P, borderRadiusLg: F, shadowOuter: ne, themeColors: re } } = gA(), {
|
|
68563
|
+
let { formatMessage: g } = cA(), { isMobile: _ } = Tu(), { config: { entityId: v, withQuickActions: y, quickActions: b, withLocale: x, withConsent: S, privacyUrl: C }, isLoading: w } = Kl(), { entityId: T } = xu(), E = y === "visible" || y === "visible-desktop" && !_, { background: D, styles: { color: O, borderColor: ee, backgroundColor70: k, spacingXS: te, spacingMD: A, marginRight: j, marginBottom: M, openerDimensions: N, transitionSpeed: P, borderRadiusLg: F, shadowOuter: ne, themeColors: re } } = gA(), { config: ie, target: ae, isCustomTarget: oe } = ql(), { session: I, setSession: se } = Yl(v, T, ae, ie.widgetId, e), [ce, le] = (0, Pq.useState)(), ue = ce ?? ie.isOpen ?? I.isOpen ?? !1, de = I.isMaximized ?? ie.isMaximized ?? !1, fe = (0, Pq.useRef)(null), pe = (0, Pq.useRef)(null), L = (0, Pq.useRef)(!1), me = (0, Pq.useCallback)((e) => {
|
|
68571
68564
|
le(e), se({ isOpen: e }), c?.(e);
|
|
68572
68565
|
}, [se, c]), he = (0, Pq.useCallback)((e) => {
|
|
68573
68566
|
se({ isMaximized: e });
|
|
@@ -85038,7 +85031,7 @@ var x4, S4, ike, ake, C4, oke, ske, w4, T4, cke, Q, E4, D4, O4, k4, A4, j4, M4,
|
|
|
85038
85031
|
return (async () => {
|
|
85039
85032
|
h(void 0), d(void 0);
|
|
85040
85033
|
try {
|
|
85041
|
-
let { servers: r } = n(), i = e.serverId ? r?.[e.serverId] : void 0, a = JSON.stringify({
|
|
85034
|
+
let { servers: r } = await n(), i = e.serverId ? r?.[e.serverId] : void 0, a = JSON.stringify({
|
|
85042
85035
|
resourceUri: e.resourceUri,
|
|
85043
85036
|
resourceToken: e.resourceToken,
|
|
85044
85037
|
serverId: e.serverId,
|
|
@@ -85117,7 +85110,7 @@ var x4, S4, ike, ake, C4, oke, ske, w4, T4, cke, Q, E4, D4, O4, k4, A4, j4, M4,
|
|
|
85117
85110
|
serverResources: { listChanged: !1 },
|
|
85118
85111
|
serverTools: { listChanged: !1 }
|
|
85119
85112
|
}), []), A = (0, m9.useCallback)(async (t) => {
|
|
85120
|
-
let { servers: r } = n(), i = await fetch(`${Ul}/mcp-app-resource`, {
|
|
85113
|
+
let { servers: r } = await n(), i = await fetch(`${Ul}/mcp-app-resource`, {
|
|
85121
85114
|
method: "POST",
|
|
85122
85115
|
headers: { "Content-Type": "application/json" },
|
|
85123
85116
|
body: JSON.stringify({
|
|
@@ -85195,7 +85188,7 @@ var x4, S4, ike, ake, C4, oke, ske, w4, T4, cke, Q, E4, D4, O4, k4, A4, j4, M4,
|
|
|
85195
85188
|
};
|
|
85196
85189
|
})), C9, w9, T9, Nje, Pje, Fje = o((() => {
|
|
85197
85190
|
C9 = /* @__PURE__ */ u(m(), 1), yA(), gV(), zl(), SV(), EV(), m(), Hq(), Mje(), w9 = nn(), T9 = ({ message: e, style: t = {}, sendMessage: n, onClickKnowledges: r, withTextAnimation: i = !1, onTextAnimate: a }) => {
|
|
85198
|
-
let { formatMessage: o } = cA(), s = Nje(e.content), c = e.mcpApps || [], {
|
|
85191
|
+
let { formatMessage: o } = cA(), s = Nje(e.content), c = e.mcpApps || [], { config: l } = ql(), { withSources: u, consent: d } = l, f = gu(d), { config: { entityId: p } } = Kl(), { entityId: m } = xu(), h = e.reactions?.find((e) => e.entityId === m)?.emotion, [g, _] = (0, C9.useState)(h), [v, y] = (0, C9.useState)(!1);
|
|
85199
85192
|
(0, C9.useEffect)(() => _(h), [h]);
|
|
85200
85193
|
let b = async (t) => {
|
|
85201
85194
|
if (!m || v) return;
|
|
@@ -86549,7 +86542,7 @@ var Y9, aMe = o((() => {
|
|
|
86549
86542
|
//#endregion
|
|
86550
86543
|
//#region src/App.tsx
|
|
86551
86544
|
function oMe() {
|
|
86552
|
-
let { config: { entityId: e, withContextualAssist: t, withConsent: n, withDisplaySize: r, displayMode: i } } = Kl(), { entityId: a } = xu(), { target: o, widgetId: s,
|
|
86545
|
+
let { config: { entityId: e, withContextualAssist: t, withConsent: n, withDisplaySize: r, displayMode: i } } = Kl(), { entityId: a } = xu(), { target: o, widgetId: s, config: c } = ql(), l = c.consent, u = gu(l), d = c.displayMode || i, f = c.widgetId;
|
|
86553
86546
|
return !e || !a || s && !d ? null : /* @__PURE__ */ (0, Z9.jsx)(sMe, {
|
|
86554
86547
|
thingEntityId: e,
|
|
86555
86548
|
authEntityId: a,
|
|
@@ -86562,7 +86555,7 @@ function oMe() {
|
|
|
86562
86555
|
}, `${e}.${a}.${o || "default"}.${f || "default"}.${u.functional}`);
|
|
86563
86556
|
}
|
|
86564
86557
|
function sMe({ thingEntityId: e, authEntityId: t, canStore: n, chatTtlDays: r, withContextualAssist: i, withConsent: a, withDisplaySize: o, displayMode: s }) {
|
|
86565
|
-
let { formatMessage: c } = cA(), { target: l,
|
|
86558
|
+
let { formatMessage: c } = cA(), { target: l, config: u } = ql(), { session: d, sessionKey: f, setSession: p } = Yl(e, t, l, u.widgetId, n), { chatId: m, setChatId: h } = Ql(f, n, r), g = u.chat?.textChatId || m || d.chat?.textChatId, [_, v] = (0, X9.useState)(1), y = g || s === "bar" ? "text" : "start", [b, x] = (0, X9.useState)(y);
|
|
86566
86559
|
(0, X9.useLayoutEffect)(() => {
|
|
86567
86560
|
x((e) => e || y);
|
|
86568
86561
|
}, [y]);
|
|
@@ -86677,7 +86670,7 @@ function sMe({ thingEntityId: e, authEntityId: t, canStore: n, chatTtlDays: r, w
|
|
|
86677
86670
|
});
|
|
86678
86671
|
let R = () => {
|
|
86679
86672
|
x("call"), j ? A() : te();
|
|
86680
|
-
}, ve = (0, X9.useMemo)(() => [t, e].filter(Boolean), [t, e]), ye = o === !1 ? void 0 : () => v((e) => e === 5 ? 1 : e + 1), be = s === "widget" || s === "widget-maximized" || s === "overlay" || s === "overlay-maximized" || s === "bar" || s === "bar-maximized", [xe, Se] = (0, X9.useState)(u
|
|
86673
|
+
}, ve = (0, X9.useMemo)(() => [t, e].filter(Boolean), [t, e]), ye = o === !1 ? void 0 : () => v((e) => e === 5 ? 1 : e + 1), be = s === "widget" || s === "widget-maximized" || s === "overlay" || s === "overlay-maximized" || s === "bar" || s === "bar-maximized", [xe, Se] = (0, X9.useState)(u.isOpen ?? d.isOpen ?? !1);
|
|
86681
86674
|
return be ? /* @__PURE__ */ (0, Z9.jsx)(Iq, {
|
|
86682
86675
|
canStore: n,
|
|
86683
86676
|
mode: b,
|
package/dist/package/public.d.ts
CHANGED
|
@@ -14,11 +14,7 @@ export type ConsentState = {
|
|
|
14
14
|
};
|
|
15
15
|
export type ClientTool = {
|
|
16
16
|
description: string;
|
|
17
|
-
|
|
18
|
-
name: string;
|
|
19
|
-
type: string;
|
|
20
|
-
description: string;
|
|
21
|
-
}[];
|
|
17
|
+
inputSchema: Record<string, unknown>;
|
|
22
18
|
execute: (params: Record<string, unknown>) => unknown | Promise<unknown>;
|
|
23
19
|
};
|
|
24
20
|
export type McpServer = {
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@tellyouai/plugin",
|
|
3
|
-
"version": "0.1.
|
|
3
|
+
"version": "0.1.7",
|
|
4
4
|
"description": "Framework-agnostic browser SDK for the Tellyou AI plugin",
|
|
5
5
|
"repository": {
|
|
6
6
|
"type": "git",
|
|
@@ -30,6 +30,7 @@
|
|
|
30
30
|
"prepack": "npm run build && npm run build:package",
|
|
31
31
|
"pack:check": "npm pack --dry-run",
|
|
32
32
|
"test:package": "node scripts/package-smoke.mjs",
|
|
33
|
+
"test:webmcp": "node --test scripts/webmcp.test.mjs",
|
|
33
34
|
"lint": "eslint .",
|
|
34
35
|
"preview": "vite preview"
|
|
35
36
|
},
|