@levo-so/studio 0.3.9 → 0.3.11
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/{KBChatWidget-Cgsubvuk.js → KBChatWidget-aK7vt64V.js} +407 -402
- package/index.d.ts +1 -1
- package/index.js +1 -1
- package/kbChat-DfcTNf0n.js +173 -0
- package/package.json +4 -4
- package/pillChrome-QDjBETmP.js +50 -0
- package/studio.css +1 -1
- package/kbChat-QDHdRejh.js +0 -173
- package/pillChrome-CYoMtUAv.js +0 -30
package/kbChat-QDHdRejh.js
DELETED
|
@@ -1,173 +0,0 @@
|
|
|
1
|
-
"use client";
|
|
2
|
-
import { a as e, c as t, f as n, h as r, l as i, m as a, n as o, o as s, p as c, r as l, t as u, u as d, y as f } from "./pillChrome-CYoMtUAv.js";
|
|
3
|
-
import { useEffect as p, useRef as m, useState as h } from "react";
|
|
4
|
-
import { jsx as g, jsxs as _ } from "react/jsx-runtime";
|
|
5
|
-
import { ArrowUp as v, Sparkles as y } from "lucide-react";
|
|
6
|
-
//#region ../../libraries/ai-chat/src/useActiveAgent.ts
|
|
7
|
-
var b = (e) => f("active_agent", e), x = (e) => {
|
|
8
|
-
let t = b(e);
|
|
9
|
-
if (!t || typeof window > "u") return null;
|
|
10
|
-
try {
|
|
11
|
-
let e = window.sessionStorage.getItem(t);
|
|
12
|
-
if (!e) return null;
|
|
13
|
-
let n = JSON.parse(e);
|
|
14
|
-
return typeof n?.id != "string" || n.id.length === 0 ? null : n;
|
|
15
|
-
} catch {
|
|
16
|
-
return null;
|
|
17
|
-
}
|
|
18
|
-
}, S = (e, t) => {
|
|
19
|
-
let n = b(e);
|
|
20
|
-
if (!(!n || typeof window > "u")) try {
|
|
21
|
-
t === null ? window.sessionStorage.removeItem(n) : window.sessionStorage.setItem(n, JSON.stringify(t));
|
|
22
|
-
} catch {}
|
|
23
|
-
}, C = ({ url: e, workspaceId: t, headers: n, path: r }) => {
|
|
24
|
-
let [i, a] = h({ status: "loading" });
|
|
25
|
-
p(() => {
|
|
26
|
-
let e = x(t);
|
|
27
|
-
a(e ? {
|
|
28
|
-
status: "ready",
|
|
29
|
-
agent: e
|
|
30
|
-
} : (e) => e.status === "ready" ? { status: "loading" } : e);
|
|
31
|
-
}, [t]);
|
|
32
|
-
let o = m(n);
|
|
33
|
-
return o.current = n, p(() => {
|
|
34
|
-
if (!t || !e) return;
|
|
35
|
-
let n = r ? `${e}${e.includes("?") ? "&" : "?"}path=${encodeURIComponent(r)}` : e, i = new AbortController();
|
|
36
|
-
return (async () => {
|
|
37
|
-
try {
|
|
38
|
-
let e = await fetch(n, {
|
|
39
|
-
method: "GET",
|
|
40
|
-
credentials: "include",
|
|
41
|
-
headers: o.current,
|
|
42
|
-
signal: i.signal
|
|
43
|
-
});
|
|
44
|
-
if (!e.ok) {
|
|
45
|
-
S(t, null), a({ status: "missing" });
|
|
46
|
-
return;
|
|
47
|
-
}
|
|
48
|
-
let r = (await e.json())?.content?.data;
|
|
49
|
-
if (!r || typeof r.id != "string" || r.id.length === 0) {
|
|
50
|
-
S(t, null), a({ status: "missing" });
|
|
51
|
-
return;
|
|
52
|
-
}
|
|
53
|
-
S(t, r), a({
|
|
54
|
-
status: "ready",
|
|
55
|
-
agent: r
|
|
56
|
-
});
|
|
57
|
-
} catch (e) {
|
|
58
|
-
if (e?.name === "AbortError") return;
|
|
59
|
-
console.warn("[levo-kb-chat] active-agent boot failed:", e), a({ status: "error" });
|
|
60
|
-
}
|
|
61
|
-
})(), () => i.abort();
|
|
62
|
-
}, [
|
|
63
|
-
t,
|
|
64
|
-
e,
|
|
65
|
-
r
|
|
66
|
-
]), i;
|
|
67
|
-
}, w = (...e) => e.filter(Boolean).join(" "), T = () => import("./KBChatWidget-Cgsubvuk.js"), E = (e) => {
|
|
68
|
-
let [t, n] = h(null), [r, i] = h(!1), [a, o] = h("");
|
|
69
|
-
return t ? /* @__PURE__ */ g(t, {
|
|
70
|
-
initialOpen: !0,
|
|
71
|
-
initialDraft: a,
|
|
72
|
-
...e
|
|
73
|
-
}) : /* @__PURE__ */ g(O, {
|
|
74
|
-
siteName: e.siteName,
|
|
75
|
-
draft: a,
|
|
76
|
-
loading: r,
|
|
77
|
-
onDraftChange: o,
|
|
78
|
-
onActivate: () => {
|
|
79
|
-
r || t || (i(!0), T().then((e) => n(() => e.KBChatWidget)).catch((e) => {
|
|
80
|
-
i(!1), console.warn("[levo-kb-chat] widget load failed:", e);
|
|
81
|
-
}));
|
|
82
|
-
},
|
|
83
|
-
onPrefetch: () => {
|
|
84
|
-
T().catch(() => {});
|
|
85
|
-
}
|
|
86
|
-
});
|
|
87
|
-
}, D = () => /* @__PURE__ */ g("span", {
|
|
88
|
-
"aria-hidden": !0,
|
|
89
|
-
className: "h-5 w-5 animate-spin rounded-full border-2 border-current border-t-transparent"
|
|
90
|
-
}), O = ({ siteName: f, draft: p, loading: b, onDraftChange: x, onActivate: S, onPrefetch: C }) => {
|
|
91
|
-
let T = m(null), E = m(null), O = r(f), [k, A] = h(!1);
|
|
92
|
-
return /* @__PURE__ */ g("div", {
|
|
93
|
-
onPointerEnter: C,
|
|
94
|
-
className: w("ai-chat-launcher fixed bottom-8 left-1/2 z-[60] -translate-x-1/2", c),
|
|
95
|
-
children: /* @__PURE__ */ g("div", {
|
|
96
|
-
className: w(o, t, "ai-chat-intro-morph"),
|
|
97
|
-
children: /* @__PURE__ */ _("div", {
|
|
98
|
-
ref: E,
|
|
99
|
-
className: w(d, k && "ai-chat-pill-surface--stacked"),
|
|
100
|
-
children: [
|
|
101
|
-
/* @__PURE__ */ g("button", {
|
|
102
|
-
type: "button",
|
|
103
|
-
onClick: S,
|
|
104
|
-
onFocus: C,
|
|
105
|
-
"aria-label": "Open AI chat",
|
|
106
|
-
className: i,
|
|
107
|
-
children: b ? /* @__PURE__ */ g(D, {}) : /* @__PURE__ */ g(y, { className: "h-5 w-5" })
|
|
108
|
-
}),
|
|
109
|
-
/* @__PURE__ */ _("div", {
|
|
110
|
-
className: l,
|
|
111
|
-
children: [/* @__PURE__ */ g("textarea", {
|
|
112
|
-
ref: T,
|
|
113
|
-
rows: 1,
|
|
114
|
-
autoComplete: "off",
|
|
115
|
-
autoCorrect: "off",
|
|
116
|
-
autoCapitalize: "none",
|
|
117
|
-
inputMode: "text",
|
|
118
|
-
value: p,
|
|
119
|
-
"aria-label": O,
|
|
120
|
-
onFocus: S,
|
|
121
|
-
onChange: (e) => {
|
|
122
|
-
let t = e.currentTarget;
|
|
123
|
-
x(t.value), E.current && A(a(E.current, t));
|
|
124
|
-
},
|
|
125
|
-
className: n
|
|
126
|
-
}), !p && /* @__PURE__ */ g("span", {
|
|
127
|
-
className: w("ai-chat-pill-label pointer-events-none absolute inset-y-0 left-0 flex max-w-full items-center truncate bg-clip-text font-semibold text-[15px] text-transparent", "ai-chat-intro-label"),
|
|
128
|
-
"aria-hidden": !0,
|
|
129
|
-
children: O
|
|
130
|
-
})]
|
|
131
|
-
}),
|
|
132
|
-
/* @__PURE__ */ g("div", {
|
|
133
|
-
className: u,
|
|
134
|
-
children: /* @__PURE__ */ g("button", {
|
|
135
|
-
type: "button",
|
|
136
|
-
onClick: S,
|
|
137
|
-
"aria-label": "Open AI chat",
|
|
138
|
-
className: e,
|
|
139
|
-
style: s,
|
|
140
|
-
children: b ? /* @__PURE__ */ g(D, {}) : /* @__PURE__ */ g(v, { className: "h-5 w-5 stroke-[2.5px]" })
|
|
141
|
-
})
|
|
142
|
-
})
|
|
143
|
-
]
|
|
144
|
-
})
|
|
145
|
-
})
|
|
146
|
-
});
|
|
147
|
-
}, k = "/.levo/public/api/v1/agents/kb-chat/public", A = (e) => e.replace(/\/v1\/agents\/kb-chat\/public\/?$/, ""), j = ({ workspaceId: e, siteName: t, siteLogo: n, siteIcon: r, apiBaseUrl: i = k, authHeaders: a, showBranding: o, siteSlug: s, path: c }) => {
|
|
148
|
-
let l = C({
|
|
149
|
-
url: `${A(i)}/v1/intelligence/site-agent/get-active`,
|
|
150
|
-
workspaceId: e,
|
|
151
|
-
headers: e ? {
|
|
152
|
-
...a,
|
|
153
|
-
"Levo-Workspace": e
|
|
154
|
-
} : a,
|
|
155
|
-
path: c
|
|
156
|
-
});
|
|
157
|
-
return l.status === "ready" ? /* @__PURE__ */ g("div", {
|
|
158
|
-
"data-ai-chat-root": !0,
|
|
159
|
-
children: /* @__PURE__ */ g(E, {
|
|
160
|
-
workspaceId: e,
|
|
161
|
-
siteName: t,
|
|
162
|
-
siteLogo: n,
|
|
163
|
-
siteIcon: r,
|
|
164
|
-
agentId: l.agent.id,
|
|
165
|
-
apiBaseUrl: i,
|
|
166
|
-
authHeaders: a,
|
|
167
|
-
showBranding: o,
|
|
168
|
-
siteSlug: s
|
|
169
|
-
})
|
|
170
|
-
}) : null;
|
|
171
|
-
};
|
|
172
|
-
//#endregion
|
|
173
|
-
export { j as default };
|
package/pillChrome-CYoMtUAv.js
DELETED
|
@@ -1,30 +0,0 @@
|
|
|
1
|
-
//#region ../../libraries/ai-chat/src/helpers.ts
|
|
2
|
-
var e = (e, t = {
|
|
3
|
-
hour: "numeric",
|
|
4
|
-
minute: "2-digit"
|
|
5
|
-
}) => {
|
|
6
|
-
if (!e) return "";
|
|
7
|
-
let n = e instanceof Date ? e : new Date(e);
|
|
8
|
-
return Number.isNaN(n.getTime()) ? "" : n.toLocaleTimeString([], t);
|
|
9
|
-
}, t = (e, t) => t ? `levo.site_chat.${e}.${t}` : null, n = (e, t) => {
|
|
10
|
-
e.style.height = "auto", e.style.height = t === void 0 ? `${e.scrollHeight}px` : `${Math.min(e.scrollHeight, t)}px`;
|
|
11
|
-
}, r = (e, t) => {
|
|
12
|
-
e.setText(t);
|
|
13
|
-
let n = document.activeElement?.closest("[data-ai-chat-root]") ?? document;
|
|
14
|
-
requestAnimationFrame(() => {
|
|
15
|
-
let e = n.querySelector("textarea[data-ai-chat-composer]");
|
|
16
|
-
if (!e) return;
|
|
17
|
-
e.focus();
|
|
18
|
-
let t = e.value.length;
|
|
19
|
-
e.setSelectionRange(t, t);
|
|
20
|
-
});
|
|
21
|
-
}, i = "w-72", a = "ai-chat-pill-gradient relative rounded-[30px] p-[2px] transition-shadow duration-300", o = "shadow-lg shadow-zinc-950/10", s = "shadow-md", c = "ai-chat-pill-surface min-h-14 w-full rounded-[28px] bg-white p-1.5", l = "ai-chat-pill-surface--stacked", u = "ai-chat-pill-input relative min-w-0", d = "ai-chat-pill-actions flex items-center gap-1.5", f = "ai-chat-pill-spark flex h-11 w-11 flex-shrink-0 items-center justify-center rounded-full text-blue-500 transition-[background-color,transform] duration-150 hover:bg-zinc-50 active:scale-95", p = "flex h-11 w-11 flex-shrink-0 items-center justify-center rounded-full shadow-sm transition-[transform,box-shadow] duration-150 hover:scale-105 hover:shadow-md active:scale-95", m = "block h-6 max-h-[120px] w-full resize-none overflow-y-auto bg-transparent text-base text-zinc-900 leading-6 placeholder:text-zinc-400 focus:outline-none", h = 24, g = (e, t) => {
|
|
22
|
-
e.classList.remove(l), t.style.height = "auto";
|
|
23
|
-
let r = t.scrollHeight > h + 4;
|
|
24
|
-
return e.classList.toggle(l, r), n(t, 120), r;
|
|
25
|
-
}, _ = "ai-chat-pill-label pointer-events-none absolute inset-y-0 left-0 flex max-w-full items-center truncate bg-clip-text font-semibold text-[15px] text-transparent", v = {
|
|
26
|
-
backgroundColor: "var(--color-brand, #0a0a0a)",
|
|
27
|
-
color: "var(--color-brand-foreground, #fff)"
|
|
28
|
-
}, y = (e) => e ? `Ask ${e}` : "Ask AI";
|
|
29
|
-
//#endregion
|
|
30
|
-
export { r as _, p as a, o as c, l as d, m as f, n as g, y as h, _ as i, f as l, g as m, a as n, v as o, i as p, u as r, s, d as t, c as u, e as v, t as y };
|