@levo-so/studio 0.1.111 → 0.1.113

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.
@@ -0,0 +1,175 @@
1
+ "use client";
2
+ import { a as e, r as t, t as n } from "./gradients-DfbdH7nO.js";
3
+ import { useEffect as r, useRef as i, useState as a } from "react";
4
+ import { jsx as o, jsxs as s } from "react/jsx-runtime";
5
+ import { ArrowUp as c, Sparkles as l } from "lucide-react";
6
+ //#region ../../libraries/ai-chat/src/useActiveAgent.ts
7
+ var u = (t) => e("active_agent", t), d = (e) => {
8
+ let t = u(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
+ }, f = (e, t) => {
19
+ let n = u(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
+ }, p = ({ url: e, workspaceId: t, headers: n }) => {
24
+ let o = i(null), [s, c] = a(() => {
25
+ let e = d(t);
26
+ return e ? {
27
+ status: "ready",
28
+ agent: e
29
+ } : { status: "loading" };
30
+ });
31
+ if (o.current !== (t ?? null)) {
32
+ o.current = t ?? null;
33
+ let e = d(t);
34
+ e ? (s.status !== "ready" || s.agent.id !== e.id) && c({
35
+ status: "ready",
36
+ agent: e
37
+ }) : s.status === "ready" && c({ status: "loading" });
38
+ }
39
+ let l = i(n);
40
+ return l.current = n, r(() => {
41
+ if (!t || !e) return;
42
+ let n = new AbortController();
43
+ return (async () => {
44
+ try {
45
+ let r = await fetch(e, {
46
+ method: "GET",
47
+ credentials: "include",
48
+ headers: l.current,
49
+ signal: n.signal
50
+ });
51
+ if (!r.ok) {
52
+ f(t, null), c({ status: "missing" });
53
+ return;
54
+ }
55
+ let i = (await r.json())?.content?.data;
56
+ if (!i || typeof i.id != "string" || i.id.length === 0) {
57
+ f(t, null), c({ status: "missing" });
58
+ return;
59
+ }
60
+ f(t, i), c({
61
+ status: "ready",
62
+ agent: i
63
+ });
64
+ } catch (e) {
65
+ if (e?.name === "AbortError") return;
66
+ console.warn("[levo-kb-chat] active-agent boot failed:", e), c({ status: "error" });
67
+ }
68
+ })(), () => n.abort();
69
+ }, [t, e]), s;
70
+ }, m = (...e) => e.filter(Boolean).join(" "), h = () => import("./KBChatWidget-C6K3zT6G.js"), g = (e) => {
71
+ let [t, n] = a(null), [r, i] = a(!1), [s, c] = a("");
72
+ return t ? /* @__PURE__ */ o(t, {
73
+ initialOpen: !0,
74
+ initialDraft: s,
75
+ ...e
76
+ }) : /* @__PURE__ */ o(v, {
77
+ siteName: e.siteName,
78
+ draft: s,
79
+ loading: r,
80
+ onDraftChange: c,
81
+ onActivate: () => {
82
+ r || t || (i(!0), h().then((e) => n(() => e.KBChatWidget)).catch((e) => {
83
+ i(!1), console.warn("[levo-kb-chat] widget load failed:", e);
84
+ }));
85
+ },
86
+ onPrefetch: () => {
87
+ h().catch(() => {});
88
+ }
89
+ });
90
+ }, _ = () => /* @__PURE__ */ o("span", {
91
+ "aria-hidden": !0,
92
+ className: "h-3.5 w-3.5 animate-spin rounded-full border-2 border-current border-t-transparent"
93
+ }), v = ({ siteName: e, draft: r, loading: a, onDraftChange: u, onActivate: d, onPrefetch: f }) => {
94
+ let p = i(null), h = e ? `Ask ${e}` : "Ask AI";
95
+ return /* @__PURE__ */ o("div", {
96
+ onPointerEnter: f,
97
+ className: m("ai-chat-launcher fixed bottom-8 left-1/2 z-[60] w-64 -translate-x-1/2", "transition-all duration-500 ease-out"),
98
+ children: /* @__PURE__ */ o("div", {
99
+ className: "relative rounded-xl p-[2px] shadow-2xl",
100
+ style: { background: n },
101
+ children: /* @__PURE__ */ o("div", {
102
+ className: "flex max-h-[46px] flex-col overflow-hidden rounded-xl bg-white",
103
+ children: /* @__PURE__ */ o("div", {
104
+ className: "h-[42px] w-full shrink-0 px-2",
105
+ children: /* @__PURE__ */ s("div", {
106
+ className: "flex h-full items-center gap-2",
107
+ children: [
108
+ /* @__PURE__ */ o("button", {
109
+ type: "button",
110
+ onClick: d,
111
+ onFocus: f,
112
+ "aria-label": "Open AI chat",
113
+ className: "flex h-8 w-8 flex-shrink-0 items-center justify-center rounded-md text-blue-500 transition-colors hover:bg-zinc-50",
114
+ children: a ? /* @__PURE__ */ o(_, {}) : /* @__PURE__ */ o(l, { className: "h-3.5 w-3.5" })
115
+ }),
116
+ /* @__PURE__ */ s("div", {
117
+ className: "relative min-w-0 flex-1",
118
+ children: [/* @__PURE__ */ o("textarea", {
119
+ ref: p,
120
+ rows: 1,
121
+ value: r,
122
+ "aria-label": h,
123
+ onFocus: d,
124
+ onChange: (e) => {
125
+ u(e.currentTarget.value), t(e.currentTarget);
126
+ },
127
+ className: m("block h-5 max-h-[80px] w-full resize-none overflow-hidden bg-transparent", "text-sm text-zinc-900 leading-5 focus:outline-none")
128
+ }), !r && /* @__PURE__ */ o("span", {
129
+ className: "pointer-events-none absolute inset-y-0 left-0 flex max-w-full items-center truncate bg-clip-text font-semibold text-sm text-transparent",
130
+ style: { backgroundImage: "linear-gradient(to right, var(--ai-chat-thinking-1, oklch(0.65 0.15 253.81)), var(--ai-chat-thinking-2, oklch(0.65 0.15 17.5826)))" },
131
+ "aria-hidden": !0,
132
+ children: h
133
+ })]
134
+ }),
135
+ /* @__PURE__ */ o("button", {
136
+ type: "button",
137
+ onClick: d,
138
+ "aria-label": "Open AI chat",
139
+ className: m("flex h-8 w-8 flex-shrink-0 items-center justify-center rounded-full shadow-sm", "transition-transform hover:scale-105 active:scale-95"),
140
+ style: {
141
+ backgroundColor: "var(--color-brand, #0a0a0a)",
142
+ color: "var(--color-brand-foreground, #fff)"
143
+ },
144
+ children: a ? /* @__PURE__ */ o(_, {}) : /* @__PURE__ */ o(c, { className: "h-3.5 w-3.5 stroke-[2.5px]" })
145
+ })
146
+ ]
147
+ })
148
+ })
149
+ })
150
+ })
151
+ });
152
+ }, y = "/.levo/public/api/v1/agents/kb-chat/public", b = (e) => e.replace(/\/v1\/agents\/kb-chat\/public\/?$/, ""), x = ({ workspaceId: e, siteName: t, siteLogo: n, siteIcon: r, apiBaseUrl: i = y, authHeaders: a }) => {
153
+ let s = p({
154
+ url: `${b(i)}/v1/intelligence/site-agent/get-active`,
155
+ workspaceId: e,
156
+ headers: e ? {
157
+ ...a,
158
+ "Levo-Workspace": e
159
+ } : a
160
+ });
161
+ return s.status === "ready" ? /* @__PURE__ */ o("div", {
162
+ "data-ai-chat-root": !0,
163
+ children: /* @__PURE__ */ o(g, {
164
+ workspaceId: e,
165
+ siteName: t,
166
+ siteLogo: n,
167
+ siteIcon: r,
168
+ agentId: s.agent.id,
169
+ apiBaseUrl: i,
170
+ authHeaders: a
171
+ })
172
+ }) : null;
173
+ };
174
+ //#endregion
175
+ export { x as default };
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@levo-so/studio",
3
- "version": "0.1.111",
3
+ "version": "0.1.113",
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",
@@ -83,6 +83,9 @@
83
83
  "@nanostores/persistent": "1.3.3",
84
84
  "@nanostores/react": "0.8.4",
85
85
  "nanostores": "0.11.4",
86
+ "@assistant-ui/react-ai-sdk": "1.3.10",
87
+ "@assistant-ui/react-markdown": "0.12.5",
88
+ "remark-gfm": "4.0.1",
86
89
  "@emotion/is-prop-valid": "1.3.1",
87
90
  "@stripe/react-stripe-js": "3.1.1",
88
91
  "@stripe/stripe-js": "5.5.0",
@@ -112,11 +115,12 @@
112
115
  "yup": "1.7.1"
113
116
  },
114
117
  "peerDependencies": {
118
+ "@assistant-ui/react": ">=0.12",
115
119
  "react": ">=19",
116
120
  "next": ">=14",
117
121
  "react-dom": ">=19",
118
- "@levo-so/insights": "0.1.111",
119
- "@levo-so/core": "0.1.111",
120
- "@levo-so/react": "0.1.111"
122
+ "@levo-so/react": "0.1.113",
123
+ "@levo-so/core": "0.1.113",
124
+ "@levo-so/insights": "0.1.113"
121
125
  }
122
126
  }