@streamoid/agent 0.10.4 → 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.
- package/dist/index.d.ts +10 -0
- package/dist/index.js +100 -6
- package/package.json +1 -1
package/dist/index.d.ts
CHANGED
|
@@ -103,6 +103,16 @@ export interface AgentChatShellAdapters {
|
|
|
103
103
|
theme: { mode: 'light' | 'dark' };
|
|
104
104
|
config: {
|
|
105
105
|
apiBase: string;
|
|
106
|
+
/**
|
|
107
|
+
* Where react widgets (dashboards, charts) load their sandbox document:
|
|
108
|
+
* the agent origin's `/widget/widget-sandbox.html`. Pass it when `apiBase`
|
|
109
|
+
* is a path on your own origin (a same-origin proxy such as
|
|
110
|
+
* `/stream-agent`): the panel can't tell the agent origin then, falls back
|
|
111
|
+
* to an inline `srcdoc` frame, and that frame inherits your page's CSP, so
|
|
112
|
+
* a `script-src 'self'` policy leaves widgets on "Loading dashboard…".
|
|
113
|
+
* Your CSP must allow framing that origin (`frame-src`).
|
|
114
|
+
*/
|
|
115
|
+
widgetSandboxUrl?: string;
|
|
106
116
|
/** Compact host-pane typography: 14px text, 1.45 leading and a 60ch measure. */
|
|
107
117
|
textSize?: 'default' | 'small';
|
|
108
118
|
hide?: {
|
package/dist/index.js
CHANGED
|
@@ -73972,12 +73972,14 @@ function apiUrl(e) {
|
|
|
73972
73972
|
}
|
|
73973
73973
|
const WIDGET_SANDBOX_PATH = "/widget/widget-sandbox.html";
|
|
73974
73974
|
function widgetSandboxUrl() {
|
|
73975
|
-
const e = normalizeBase(
|
|
73975
|
+
const e = normalizeBase(clientAdapter.getWidgetSandboxUrl?.() ?? void 0);
|
|
73976
|
+
if (e) return e;
|
|
73977
|
+
const t = normalizeBase(
|
|
73976
73978
|
void 0
|
|
73977
73979
|
);
|
|
73978
|
-
if (
|
|
73979
|
-
const
|
|
73980
|
-
return !
|
|
73980
|
+
if (t) return t;
|
|
73981
|
+
const n = getOrigin(void 0) || getOrigin(getApiBase());
|
|
73982
|
+
return !n || typeof window < "u" && window.location.origin === n ? null : `${n}${WIDGET_SANDBOX_PATH}`;
|
|
73981
73983
|
}
|
|
73982
73984
|
function resolveApiAssetUrl(e) {
|
|
73983
73985
|
return resolveApiAssetUrlWithContext(e, {
|
|
@@ -74058,11 +74060,27 @@ function save(e) {
|
|
|
74058
74060
|
const useSampleDataStore = create((e) => ({
|
|
74059
74061
|
draft: !1,
|
|
74060
74062
|
chats: load(),
|
|
74063
|
+
switching: {},
|
|
74061
74064
|
setDraft: (t) => e((n) => n.draft === t ? n : { draft: t }),
|
|
74062
74065
|
claim: (t) => e((n) => {
|
|
74063
74066
|
if (!n.draft) return n;
|
|
74064
74067
|
const s = { ...n.chats, [t]: !0 };
|
|
74065
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 };
|
|
74066
74084
|
})
|
|
74067
74085
|
}));
|
|
74068
74086
|
function sampleDataHostContext(e, t, n) {
|
|
@@ -76716,6 +76734,69 @@ function ScopePromotion(e) {
|
|
|
76716
76734
|
const t = useScopeStore((s) => s.scope), n = useScopeStore((s) => s.setScope);
|
|
76717
76735
|
return /* @__PURE__ */ jsx(ScopePromotion$1, { ...e, currentScope: t, normalizeApp: hostScopeApp, onPromote: () => n(null), labelForApp: (s) => scopeLabel(s) });
|
|
76718
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
|
+
}
|
|
76719
76800
|
const mergeClasses$1 = (...e) => e.filter((t, n, s) => !!t && t.trim() !== "" && s.indexOf(t) === n).join(" ").trim();
|
|
76720
76801
|
const toKebabCase$1 = (e) => e.replace(/([a-z0-9])([A-Z])/g, "$1-$2").toLowerCase();
|
|
76721
76802
|
const toCamelCase$1 = (e) => e.replace(
|
|
@@ -135719,6 +135800,18 @@ registry.register({
|
|
|
135719
135800
|
width: "100%"
|
|
135720
135801
|
}
|
|
135721
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
|
+
});
|
|
135722
135815
|
for (const e of portableComponentEntries.filter((t) => ["generic:image-tiles", "generic:file-preview", "generic:react-widget", "generic:table"].includes(t.name))) {
|
|
135723
135816
|
const n = { "generic:image-tiles": "Images", "generic:file-preview": "File", "generic:react-widget": "Widget", "generic:table": "Table" }[e.name];
|
|
135724
135817
|
registry.register({
|
|
@@ -136088,11 +136181,11 @@ function UIComponents({ chatId: e, message: t, isActive: n, embedded: s, footerE
|
|
|
136088
136181
|
if (Nt.ok && ft && T(ft), Nt.ok)
|
|
136089
136182
|
c?.();
|
|
136090
136183
|
else {
|
|
136091
|
-
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");
|
|
136092
136185
|
Q(!1), h?.(De);
|
|
136093
136186
|
}
|
|
136094
136187
|
} catch (Ct) {
|
|
136095
|
-
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;
|
|
136096
136189
|
}
|
|
136097
136190
|
}
|
|
136098
136191
|
}, [
|
|
@@ -145299,6 +145392,7 @@ function AgentChatShell({ adapters: e }) {
|
|
|
145299
145392
|
useState(() => {
|
|
145300
145393
|
configureStreamAgentClient({
|
|
145301
145394
|
getApiBase: () => t.current.config.apiBase,
|
|
145395
|
+
getWidgetSandboxUrl: () => t.current.config.widgetSandboxUrl ?? null,
|
|
145302
145396
|
getToken: () => t.current.auth.getToken?.() ?? null,
|
|
145303
145397
|
getWorkspaceId: () => t.current.workspace.current.id,
|
|
145304
145398
|
onSessionExpired: () => t.current.auth.onSessionExpired?.(),
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@streamoid/agent",
|
|
3
|
-
"version": "0.10.
|
|
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",
|