@levo-so/studio 0.1.113 → 0.1.114

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/index.js CHANGED
@@ -560,7 +560,7 @@ var Ur = Ht.extend({
560
560
  showCaption: !0
561
561
  } : !1;
562
562
  },
563
- contentElement: "figcaption"
563
+ contentElement: (e) => e.querySelector("figcaption") ?? e.ownerDocument.createElement("figcaption")
564
564
  }, {
565
565
  tag: "img",
566
566
  getAttrs: (e) => {
@@ -4035,7 +4035,7 @@ var Gi = ({ isPageGenerating: e = !1, isGenerationCancelled: t = !1, totalBlocks
4035
4035
  getAllBlocks() {
4036
4036
  return this.blocks;
4037
4037
  }
4038
- }, bo = yo.getInstance(), xo = hn(() => import("./kbChat-D7WQsERz.js"), { ssr: !1 }), So = ({ workspace: e, site: t }) => /* @__PURE__ */ H(xo, {
4038
+ }, bo = yo.getInstance(), xo = hn(() => import("./kbChat-DCrdcXir.js"), { ssr: !1 }), So = ({ workspace: e, site: t }) => /* @__PURE__ */ H(xo, {
4039
4039
  workspaceId: e?.id,
4040
4040
  siteName: t?.name ?? e?.name,
4041
4041
  siteLogo: t?.logo?.location,
@@ -0,0 +1,166 @@
1
+ "use client";
2
+ import { _ as e, a as t, c as n, d as r, f as i, h as a, l as o, n as s, o as c, p as l, r as u, t as d, u as f } from "./pillChrome-CQoJfFk3.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 = (t) => e("active_agent", t), 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 }) => {
24
+ let [r, i] = h({ status: "loading" });
25
+ p(() => {
26
+ let e = x(t);
27
+ i(e ? {
28
+ status: "ready",
29
+ agent: e
30
+ } : (e) => e.status === "ready" ? { status: "loading" } : e);
31
+ }, [t]);
32
+ let a = m(n);
33
+ return a.current = n, p(() => {
34
+ if (!t || !e) return;
35
+ let n = new AbortController();
36
+ return (async () => {
37
+ try {
38
+ let r = await fetch(e, {
39
+ method: "GET",
40
+ credentials: "include",
41
+ headers: a.current,
42
+ signal: n.signal
43
+ });
44
+ if (!r.ok) {
45
+ S(t, null), i({ status: "missing" });
46
+ return;
47
+ }
48
+ let o = (await r.json())?.content?.data;
49
+ if (!o || typeof o.id != "string" || o.id.length === 0) {
50
+ S(t, null), i({ status: "missing" });
51
+ return;
52
+ }
53
+ S(t, o), i({
54
+ status: "ready",
55
+ agent: o
56
+ });
57
+ } catch (e) {
58
+ if (e?.name === "AbortError") return;
59
+ console.warn("[levo-kb-chat] active-agent boot failed:", e), i({ status: "error" });
60
+ }
61
+ })(), () => n.abort();
62
+ }, [t, e]), r;
63
+ }, w = (...e) => e.filter(Boolean).join(" "), T = () => import("./KBChatWidget-CPrg_etS.js"), E = (e) => {
64
+ let [t, n] = h(null), [r, i] = h(!1), [a, o] = h("");
65
+ return t ? /* @__PURE__ */ g(t, {
66
+ initialOpen: !0,
67
+ initialDraft: a,
68
+ ...e
69
+ }) : /* @__PURE__ */ g(O, {
70
+ siteName: e.siteName,
71
+ draft: a,
72
+ loading: r,
73
+ onDraftChange: o,
74
+ onActivate: () => {
75
+ r || t || (i(!0), T().then((e) => n(() => e.KBChatWidget)).catch((e) => {
76
+ i(!1), console.warn("[levo-kb-chat] widget load failed:", e);
77
+ }));
78
+ },
79
+ onPrefetch: () => {
80
+ T().catch(() => {});
81
+ }
82
+ });
83
+ }, D = () => /* @__PURE__ */ g("span", {
84
+ "aria-hidden": !0,
85
+ className: "h-5 w-5 animate-spin rounded-full border-2 border-current border-t-transparent"
86
+ }), O = ({ siteName: e, draft: p, loading: h, onDraftChange: b, onActivate: x, onPrefetch: S }) => {
87
+ let C = m(null), T = l(e);
88
+ return /* @__PURE__ */ g("div", {
89
+ onPointerEnter: S,
90
+ className: w("ai-chat-launcher fixed bottom-8 left-1/2 z-[60] -translate-x-1/2", i),
91
+ children: /* @__PURE__ */ _("div", {
92
+ className: w(d, n),
93
+ style: s,
94
+ children: [/* @__PURE__ */ g("span", {
95
+ "aria-hidden": !0,
96
+ className: "ai-chat-intro-aurora",
97
+ children: /* @__PURE__ */ g("span", { className: "ai-chat-intro-aurora-bloom" })
98
+ }), /* @__PURE__ */ _("div", {
99
+ className: f,
100
+ children: [
101
+ /* @__PURE__ */ g("button", {
102
+ type: "button",
103
+ onClick: x,
104
+ onFocus: S,
105
+ "aria-label": "Open AI chat",
106
+ className: w(o, "ai-chat-intro-spark"),
107
+ children: h ? /* @__PURE__ */ g(D, {}) : /* @__PURE__ */ g(y, { className: "h-5 w-5" })
108
+ }),
109
+ /* @__PURE__ */ _("div", {
110
+ className: u,
111
+ children: [/* @__PURE__ */ g("textarea", {
112
+ ref: C,
113
+ rows: 1,
114
+ autoComplete: "off",
115
+ autoCorrect: "off",
116
+ autoCapitalize: "none",
117
+ inputMode: "text",
118
+ value: p,
119
+ "aria-label": T,
120
+ onFocus: x,
121
+ onChange: (e) => {
122
+ b(e.currentTarget.value), a(e.currentTarget, 120);
123
+ },
124
+ className: r
125
+ }), !p && /* @__PURE__ */ g("span", {
126
+ className: "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",
127
+ "aria-hidden": !0,
128
+ children: T
129
+ })]
130
+ }),
131
+ /* @__PURE__ */ g("button", {
132
+ type: "button",
133
+ onClick: x,
134
+ "aria-label": "Open AI chat",
135
+ className: t,
136
+ style: c,
137
+ children: h ? /* @__PURE__ */ g(D, {}) : /* @__PURE__ */ g(v, { className: "h-5 w-5 stroke-[2.5px]" })
138
+ })
139
+ ]
140
+ })]
141
+ })
142
+ });
143
+ }, 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 }) => {
144
+ let o = C({
145
+ url: `${A(i)}/v1/intelligence/site-agent/get-active`,
146
+ workspaceId: e,
147
+ headers: e ? {
148
+ ...a,
149
+ "Levo-Workspace": e
150
+ } : a
151
+ });
152
+ return o.status === "ready" ? /* @__PURE__ */ g("div", {
153
+ "data-ai-chat-root": !0,
154
+ children: /* @__PURE__ */ g(E, {
155
+ workspaceId: e,
156
+ siteName: t,
157
+ siteLogo: n,
158
+ siteIcon: r,
159
+ agentId: o.agent.id,
160
+ apiBaseUrl: i,
161
+ authHeaders: a
162
+ })
163
+ }) : null;
164
+ };
165
+ //#endregion
166
+ export { j as default };
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@levo-so/studio",
3
- "version": "0.1.113",
3
+ "version": "0.1.114",
4
4
  "author": "Levo Engineering <devs@theinternetfolks.com>",
5
5
  "description": "Levo Studio components and utilities for building block-based pages",
6
6
  "type": "module",
@@ -120,7 +120,7 @@
120
120
  "next": ">=14",
121
121
  "react-dom": ">=19",
122
122
  "@levo-so/react": "0.1.113",
123
- "@levo-so/core": "0.1.113",
124
- "@levo-so/insights": "0.1.113"
123
+ "@levo-so/insights": "0.1.113",
124
+ "@levo-so/core": "0.1.113"
125
125
  }
126
126
  }
@@ -0,0 +1,16 @@
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 = "linear-gradient(to right, color-mix(in oklch, var(--ai-chat-thinking-1, oklch(0.65 0.15 253.81)) 40%, transparent), color-mix(in oklch, var(--ai-chat-thinking-2, oklch(0.65 0.15 17.5826)) 40%, transparent))", i = "w-72", a = "relative rounded-full p-[2px] transition-shadow duration-300", o = "shadow-lg shadow-zinc-950/10", s = "shadow-md", c = "flex min-h-14 w-full items-end gap-1.5 rounded-full bg-white p-1.5", l = "relative min-w-0 flex-1 py-2.5", u = "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", d = "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", f = "block h-6 max-h-[120px] w-full resize-none overflow-hidden bg-transparent text-base text-zinc-900 leading-6 placeholder:text-zinc-400 focus:outline-none", p = "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", m = { background: r }, h = {
12
+ backgroundColor: "var(--color-brand, #0a0a0a)",
13
+ color: "var(--color-brand-foreground, #fff)"
14
+ }, g = (e) => e ? `Ask ${e}` : "Ask AI";
15
+ //#endregion
16
+ export { t as _, d as a, o as c, f as d, i as f, e as g, n as h, p as i, u as l, r as m, m as n, h as o, g as p, l as r, s, a as t, c as u };