@streamoid/agent 0.10.6 → 0.10.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.
Files changed (2) hide show
  1. package/dist/index.js +93 -2
  2. package/package.json +1 -1
package/dist/index.js CHANGED
@@ -74060,11 +74060,27 @@ function save(e) {
74060
74060
  const useSampleDataStore = create((e) => ({
74061
74061
  draft: !1,
74062
74062
  chats: load(),
74063
+ switching: {},
74063
74064
  setDraft: (t) => e((n) => n.draft === t ? n : { draft: t }),
74064
74065
  claim: (t) => e((n) => {
74065
74066
  if (!n.draft) return n;
74066
74067
  const s = { ...n.chats, [t]: !0 };
74067
74068
  return save(s), { draft: !1, chats: s };
74069
+ }),
74070
+ adopt: (t) => e((n) => {
74071
+ if (!t || n.chats[t]) return n;
74072
+ const s = { ...n.chats, [t]: !0 };
74073
+ return save(s), { chats: s };
74074
+ }),
74075
+ setSwitching: (t, n) => e((s) => {
74076
+ if (!t || s.switching[t] === (n ?? void 0)) return s;
74077
+ const o = { ...s.switching };
74078
+ return n === null ? delete o[t] : o[t] = n, { switching: o };
74079
+ }),
74080
+ release: (t) => e((n) => {
74081
+ if (!t || !n.chats[t]) return n;
74082
+ const s = { ...n.chats };
74083
+ return delete s[t], save(s), { chats: s };
74068
74084
  })
74069
74085
  }));
74070
74086
  function sampleDataHostContext(e, t, n) {
@@ -76718,6 +76734,69 @@ function ScopePromotion(e) {
76718
76734
  const t = useScopeStore((s) => s.scope), n = useScopeStore((s) => s.setScope);
76719
76735
  return /* @__PURE__ */ jsx(ScopePromotion$1, { ...e, currentScope: t, normalizeApp: hostScopeApp, onPromote: () => n(null), labelForApp: (s) => scopeLabel(s) });
76720
76736
  }
76737
+ function SampleSwitch({ uiProps: e, conversationId: t, submitted: n, submittedValues: s, onSubmit: o, submitting: l = !1 }) {
76738
+ const c = useSampleDataStore((I) => I.adopt), d = useSampleDataStore((I) => I.release), h = useSampleDataStore((I) => I.setSwitching), g = useSampleDataStore((I) => t ? I.switching[t] : void 0), v = typeof e.brand == "string" && e.brand.trim() ? e.brand : "Tacx", C = typeof e.reason == "string" ? e.reason : "", N = n || !!s || g !== void 0, T = s?.sample === !0 || g === !0, j = async (I) => {
76739
+ if (!(N || l)) {
76740
+ h(t, I), I ? c(t) : d(t);
76741
+ try {
76742
+ await Promise.resolve(o({ sample: I }, I ? `Use the ${v} sample` : "Keep my data"));
76743
+ } catch {
76744
+ h(t, null), I && d(t);
76745
+ }
76746
+ }
76747
+ };
76748
+ return /* @__PURE__ */ jsxs(
76749
+ "div",
76750
+ {
76751
+ "data-testid": "sample-switch",
76752
+ className: "flex w-full flex-col gap-[10px] rounded-[16px] border border-[var(--alias-border-subtle)] bg-[var(--alias-surface-base)] p-[14px]",
76753
+ children: [
76754
+ /* @__PURE__ */ jsxs("p", { className: "m-0 text-[14px] leading-[20px] text-[var(--alias-text---icons-primary)]", children: [
76755
+ "Use the ",
76756
+ v,
76757
+ " sample for this chat?"
76758
+ ] }),
76759
+ /* @__PURE__ */ jsxs("p", { className: "m-0 text-[13px] leading-[19px] text-[var(--alias-text---icons-tertiary)]", children: [
76760
+ C ? `${C} ` : "",
76761
+ v,
76762
+ " is a fictional brand with your own copy of its data. This chat stays on it; your data and Tactix don't change."
76763
+ ] }),
76764
+ N ? /* @__PURE__ */ jsx("p", { "data-testid": "sample-switch-decided", className: "m-0 text-[12px] leading-[18px] text-[var(--alias-text---icons-tertiary)]", children: T ? `Using the ${v} sample` : "Kept to your data" }) : /* @__PURE__ */ jsxs("div", { className: "flex flex-wrap gap-[8px]", children: [
76765
+ /* @__PURE__ */ jsxs(
76766
+ "button",
76767
+ {
76768
+ type: "button",
76769
+ "data-testid": "sample-switch-accept",
76770
+ disabled: l,
76771
+ onClick: () => {
76772
+ j(!0);
76773
+ },
76774
+ className: "h-[32px] rounded-[999px] bg-[var(--alias-text---icons-primary)] px-[12px] text-[13px] font-medium text-[var(--alias-text---icons-inverse)] hover:opacity-90 disabled:opacity-60",
76775
+ children: [
76776
+ "Use the ",
76777
+ v,
76778
+ " sample"
76779
+ ]
76780
+ }
76781
+ ),
76782
+ /* @__PURE__ */ jsx(
76783
+ "button",
76784
+ {
76785
+ type: "button",
76786
+ "data-testid": "sample-switch-decline",
76787
+ disabled: l,
76788
+ onClick: () => {
76789
+ j(!1);
76790
+ },
76791
+ className: "h-[32px] rounded-[999px] border border-[var(--alias-border-subtle)] px-[12px] text-[13px] text-[var(--alias-text---icons-secondary)] hover:bg-[var(--alias-surface-subtle)]",
76792
+ children: "Keep my data"
76793
+ }
76794
+ )
76795
+ ] })
76796
+ ]
76797
+ }
76798
+ );
76799
+ }
76721
76800
  const mergeClasses$1 = (...e) => e.filter((t, n, s) => !!t && t.trim() !== "" && s.indexOf(t) === n).join(" ").trim();
76722
76801
  const toKebabCase$1 = (e) => e.replace(/([a-z0-9])([A-Z])/g, "$1-$2").toLowerCase();
76723
76802
  const toCamelCase$1 = (e) => e.replace(
@@ -135721,6 +135800,18 @@ registry.register({
135721
135800
  width: "100%"
135722
135801
  }
135723
135802
  });
135803
+ registry.register({
135804
+ name: "generic:sample-switch",
135805
+ aliases: ["sample_switch"],
135806
+ service: "generic",
135807
+ type: "react",
135808
+ component: SampleSwitch,
135809
+ blocking: !0,
135810
+ surface: "inline",
135811
+ containerStyle: {
135812
+ width: "100%"
135813
+ }
135814
+ });
135724
135815
  for (const e of portableComponentEntries.filter((t) => ["generic:image-tiles", "generic:file-preview", "generic:react-widget", "generic:table"].includes(t.name))) {
135725
135816
  const n = { "generic:image-tiles": "Images", "generic:file-preview": "File", "generic:react-widget": "Widget", "generic:table": "Table" }[e.name];
135726
135817
  registry.register({
@@ -136090,11 +136181,11 @@ function UIComponents({ chatId: e, message: t, isActive: n, embedded: s, footerE
136090
136181
  if (Nt.ok && ft && T(ft), Nt.ok)
136091
136182
  c?.();
136092
136183
  else {
136093
- if (Ve === "host_actions" || Ve === "tactix:onboarding") throw new Error("Could not resume the conversation");
136184
+ if (Ve === "host_actions" || Ve === "tactix:onboarding" || Ve === "sample_switch") throw new Error("Could not resume the conversation");
136094
136185
  Q(!1), h?.(De);
136095
136186
  }
136096
136187
  } catch (Ct) {
136097
- if (console.error("[UIComponents] handleSubmit failed", Ct), Q(!1), h?.(De), Ve === "host_actions" || Ve === "tactix:onboarding") throw Ct;
136188
+ if (console.error("[UIComponents] handleSubmit failed", Ct), Q(!1), h?.(De), Ve === "host_actions" || Ve === "tactix:onboarding" || Ve === "sample_switch") throw Ct;
136098
136189
  }
136099
136190
  }
136100
136191
  }, [
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@streamoid/agent",
3
- "version": "0.10.6",
3
+ "version": "0.10.7",
4
4
  "description": "Native (no-iframe) embeddable Streamoid agent chat panel. Host renders <AgentPanel adapters={\u2026}/>. Prebuilt bundle \u2014 source + build live in the stream-agent repo.",
5
5
  "type": "module",
6
6
  "main": "./dist/index.js",