@inkeep/agents-ui 0.14.9 → 0.14.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/dist/primitives/atoms/dialog.cjs +1 -1
- package/dist/primitives/atoms/dialog.js +90 -87
- package/dist/primitives/components/embedded-chat/use-inkeep-chat.cjs +2 -2
- package/dist/primitives/components/embedded-chat/use-inkeep-chat.js +55 -54
- package/dist/primitives/components/embedded-chat/use-stream-processor.cjs +1 -1
- package/dist/primitives/components/embedded-chat/use-stream-processor.js +103 -64
- package/dist/primitives/components/embedded-chat.cjs +2 -2
- package/dist/primitives/components/embedded-chat.js +33 -33
- package/dist/primitives/hooks/use-streaming-events.cjs +1 -0
- package/dist/primitives/hooks/use-streaming-events.js +140 -0
- package/dist/primitives/providers/base-events-provider.cjs +1 -1
- package/dist/primitives/providers/base-events-provider.js +1 -1
- package/package.json +1 -1
|
@@ -1 +1 @@
|
|
|
1
|
-
"use client";"use strict";Object.defineProperty(exports,Symbol.toStringTag,{value:"Module"});const i=require("react/jsx-runtime"),T=require("react"),
|
|
1
|
+
"use client";"use strict";Object.defineProperty(exports,Symbol.toStringTag,{value:"Module"});const i=require("react/jsx-runtime"),T=require("react"),m=require("@radix-ui/primitive"),P=require("@radix-ui/react-compose-refs"),H=require("@radix-ui/react-context"),R=require("@radix-ui/react-id"),W=require("@radix-ui/react-use-controllable-state"),z=require("@radix-ui/react-dismissable-layer"),B=require("@zag-js/focus-trap"),K=require("@radix-ui/react-portal"),_=require("@radix-ui/react-presence"),f=require("@radix-ui/react-primitive"),U=require("@radix-ui/react-focus-guards"),V=require("react-remove-scroll"),Y=require("aria-hidden"),Z=require("@radix-ui/react-slot");function J(e){const r=Object.create(null,{[Symbol.toStringTag]:{value:"Module"}});if(e){for(const o in e)if(o!=="default"){const s=Object.getOwnPropertyDescriptor(e,o);Object.defineProperty(r,o,s.get?s:{enumerable:!0,get:()=>e[o]})}}return r.default=e,Object.freeze(r)}const c=J(T),x="Dialog",[N,Q]=H.createContextScope(x),[X,l]=N(x),O=e=>{const{__scopeDialog:r,children:o,open:s,defaultOpen:n,onOpenChange:t,modal:a=!0}=e,u=c.useRef(null),p=c.useRef(null),[g=!1,D]=W.useControllableState({prop:s,defaultProp:n??!1,onChange:t});return i.jsx(X,{scope:r,triggerRef:u,contentRef:p,contentId:R.useId(),titleId:R.useId(),descriptionId:R.useId(),open:g,onOpenChange:D,onOpenToggle:c.useCallback(()=>D(G=>!G),[D]),modal:a,children:o})};O.displayName=x;const M="DialogTrigger",S=c.forwardRef((e,r)=>{const{__scopeDialog:o,...s}=e,n=l(M,o),t=P.useComposedRefs(r,n.triggerRef);return i.jsx(f.Primitive.button,{type:"button","aria-haspopup":"dialog","aria-expanded":n.open,"aria-controls":n.contentId,"data-state":j(n.open),...s,ref:t,onClick:m.composeEventHandlers(e.onClick,n.onOpenToggle)})});S.displayName=M;const v="DialogPortal",[$,q]=N(v,{forceMount:void 0}),y=e=>{const{__scopeDialog:r,forceMount:o,children:s,container:n}=e,t=l(v,r);return i.jsx($,{scope:r,forceMount:o,children:c.Children.map(s,a=>i.jsx(_.Presence,{present:o||t.open,children:i.jsx(K.Portal,{asChild:!0,container:n,children:a})}))})};y.displayName=v;const C="DialogOverlay",E=c.forwardRef((e,r)=>{const o=q(C,e.__scopeDialog),{forceMount:s=o.forceMount,...n}=e,t=l(C,e.__scopeDialog);return t.modal?i.jsx(_.Presence,{present:s||t.open,children:i.jsx(ee,{...n,ref:r})}):null});E.displayName=C;const ee=c.forwardRef((e,r)=>{const{__scopeDialog:o,...s}=e,n=l(C,o);return i.jsx(V.RemoveScroll,{as:Z.Slot,allowPinchZoom:!0,shards:[n.contentRef],gapMode:"padding",removeScrollBar:!0,children:i.jsx(f.Primitive.div,{"data-state":j(n.open),...s,ref:r,style:{pointerEvents:"auto",...s.style}})})}),d="DialogContent",h=c.forwardRef((e,r)=>{const o=q(d,e.__scopeDialog),{forceMount:s=o.forceMount,...n}=e,t=l(d,e.__scopeDialog);return i.jsx(_.Presence,{present:s||t.open,children:t.modal?i.jsx(te,{...n,ref:r}):i.jsx(oe,{...n,ref:r})})});h.displayName=d;const te=c.forwardRef((e,r)=>{const o=l(d,e.__scopeDialog),s=c.useRef(null),n=P.useComposedRefs(r,o.contentRef,s);return c.useEffect(()=>{const t=s.current;if(t){const a=document.querySelectorAll("[data-ikp-component]");return Y.hideOthers([t,...Array.from(a)])}},[]),i.jsx(A,{...e,ref:n,trapFocus:o.open,disableOutsidePointerEvents:!0,onPointerDownOutside:m.composeEventHandlers(e.onPointerDownOutside,t=>{const a=t.detail.originalEvent,u=a.button===0&&a.ctrlKey===!0;(a.button===2||u)&&t.preventDefault(),t.target.closest("[data-ikp-component]")&&t.preventDefault()}),onFocusOutside:m.composeEventHandlers(e.onFocusOutside,t=>t.preventDefault())})}),oe=c.forwardRef((e,r)=>{const o=l(d,e.__scopeDialog),s=c.useRef(!1),n=c.useRef(!1);return i.jsx(A,{...e,ref:r,trapFocus:!1,disableOutsidePointerEvents:!1,onInteractOutside:t=>{e.onInteractOutside?.(t),t.defaultPrevented||(s.current=!0,t.detail.originalEvent.type==="pointerdown"&&(n.current=!0));const a=t.target;o.triggerRef.current?.contains(a)&&t.preventDefault(),t.detail.originalEvent.type==="focusin"&&n.current&&t.preventDefault()}})}),A=c.forwardRef((e,r)=>{const{__scopeDialog:o,trapFocus:s,onOpenAutoFocus:n,onCloseAutoFocus:t,...a}=e,u=l(d,o),p=c.useRef(null),g=P.useComposedRefs(r,p);return U.useFocusGuards(),T.useEffect(()=>{if(s)return B.trapFocus(p.current,{preventScroll:!0,onActivate:n,onDeactivate:t,initialFocus:!1})},[]),i.jsx(z.DismissableLayer,{role:"dialog",id:u.contentId,"aria-describedby":u.descriptionId,"aria-labelledby":u.titleId,"data-state":j(u.open),...a,ref:g,onDismiss:()=>u.onOpenChange(!1)})}),w="DialogTitle",I=c.forwardRef((e,r)=>{const{__scopeDialog:o,...s}=e,n=l(w,o);return i.jsx(f.Primitive.h2,{id:n.titleId,...s,ref:r})});I.displayName=w;const k="DialogDescription",F=c.forwardRef((e,r)=>{const{__scopeDialog:o,...s}=e,n=l(k,o);return i.jsx(f.Primitive.p,{id:n.descriptionId,...s,ref:r})});F.displayName=k;const L="DialogClose",b=c.forwardRef((e,r)=>{const{__scopeDialog:o,...s}=e,n=l(L,o);return i.jsx(f.Primitive.button,{type:"button",...s,ref:r,onClick:m.composeEventHandlers(e.onClick,()=>n.onOpenChange(!1))})});b.displayName=L;function j(e){return e?"open":"closed"}const ne=O,re=y,se=E,ce=h,ie=I,ae=b;exports.Close=ae;exports.Content=ce;exports.Dialog=O;exports.DialogClose=b;exports.DialogContent=h;exports.DialogDescription=F;exports.DialogOverlay=E;exports.DialogPortal=y;exports.DialogTitle=I;exports.DialogTrigger=S;exports.Overlay=se;exports.Portal=re;exports.Root=ne;exports.Title=ie;exports.createDialogScope=Q;
|
|
@@ -1,49 +1,49 @@
|
|
|
1
1
|
"use client";
|
|
2
|
-
import { jsx as
|
|
3
|
-
import * as
|
|
2
|
+
import { jsx as c } from "react/jsx-runtime";
|
|
3
|
+
import * as i from "react";
|
|
4
4
|
import { useEffect as G } from "react";
|
|
5
|
-
import { composeEventHandlers as
|
|
5
|
+
import { composeEventHandlers as D } from "@radix-ui/primitive";
|
|
6
6
|
import { useComposedRefs as _ } from "@radix-ui/react-compose-refs";
|
|
7
|
-
import { createContextScope as
|
|
7
|
+
import { createContextScope as W } from "@radix-ui/react-context";
|
|
8
8
|
import { useId as C } from "@radix-ui/react-id";
|
|
9
|
-
import { useControllableState as
|
|
10
|
-
import { DismissableLayer as
|
|
11
|
-
import { trapFocus as
|
|
12
|
-
import { Portal as
|
|
9
|
+
import { useControllableState as $ } from "@radix-ui/react-use-controllable-state";
|
|
10
|
+
import { DismissableLayer as j } from "@radix-ui/react-dismissable-layer";
|
|
11
|
+
import { trapFocus as q } from "@zag-js/focus-trap";
|
|
12
|
+
import { Portal as B } from "@radix-ui/react-portal";
|
|
13
13
|
import { Presence as O } from "@radix-ui/react-presence";
|
|
14
14
|
import { Primitive as d } from "@radix-ui/react-primitive";
|
|
15
|
-
import { useFocusGuards as
|
|
16
|
-
import { RemoveScroll as
|
|
17
|
-
import { hideOthers as
|
|
18
|
-
import { Slot as
|
|
19
|
-
const P = "Dialog", [E, Co] =
|
|
20
|
-
const { __scopeDialog: n, children: r, open: s, defaultOpen: e, onOpenChange: t, modal: a = !0 } = o,
|
|
15
|
+
import { useFocusGuards as H } from "@radix-ui/react-focus-guards";
|
|
16
|
+
import { RemoveScroll as K } from "react-remove-scroll";
|
|
17
|
+
import { hideOthers as V } from "aria-hidden";
|
|
18
|
+
import { Slot as Y } from "@radix-ui/react-slot";
|
|
19
|
+
const P = "Dialog", [E, Co] = W(P), [Z, l] = E(P), I = (o) => {
|
|
20
|
+
const { __scopeDialog: n, children: r, open: s, defaultOpen: e, onOpenChange: t, modal: a = !0 } = o, p = i.useRef(null), u = i.useRef(null), [g = !1, m] = $({
|
|
21
21
|
prop: s,
|
|
22
22
|
defaultProp: e ?? !1,
|
|
23
23
|
onChange: t
|
|
24
24
|
});
|
|
25
|
-
return /* @__PURE__ */
|
|
26
|
-
|
|
25
|
+
return /* @__PURE__ */ c(
|
|
26
|
+
Z,
|
|
27
27
|
{
|
|
28
28
|
scope: n,
|
|
29
|
-
triggerRef:
|
|
30
|
-
contentRef:
|
|
29
|
+
triggerRef: p,
|
|
30
|
+
contentRef: u,
|
|
31
31
|
contentId: C(),
|
|
32
32
|
titleId: C(),
|
|
33
33
|
descriptionId: C(),
|
|
34
|
-
open:
|
|
35
|
-
onOpenChange:
|
|
36
|
-
onOpenToggle:
|
|
34
|
+
open: g,
|
|
35
|
+
onOpenChange: m,
|
|
36
|
+
onOpenToggle: i.useCallback(() => m((L) => !L), [m]),
|
|
37
37
|
modal: a,
|
|
38
38
|
children: r
|
|
39
39
|
}
|
|
40
40
|
);
|
|
41
41
|
};
|
|
42
|
-
|
|
43
|
-
const
|
|
42
|
+
I.displayName = P;
|
|
43
|
+
const v = "DialogTrigger", z = i.forwardRef(
|
|
44
44
|
(o, n) => {
|
|
45
|
-
const { __scopeDialog: r, ...s } = o, e = l(
|
|
46
|
-
return /* @__PURE__ */
|
|
45
|
+
const { __scopeDialog: r, ...s } = o, e = l(v, r), t = _(n, e.triggerRef);
|
|
46
|
+
return /* @__PURE__ */ c(
|
|
47
47
|
d.button,
|
|
48
48
|
{
|
|
49
49
|
type: "button",
|
|
@@ -53,41 +53,41 @@ const I = "DialogTrigger", J = c.forwardRef(
|
|
|
53
53
|
"data-state": y(e.open),
|
|
54
54
|
...s,
|
|
55
55
|
ref: t,
|
|
56
|
-
onClick:
|
|
56
|
+
onClick: D(o.onClick, e.onOpenToggle)
|
|
57
57
|
}
|
|
58
58
|
);
|
|
59
59
|
}
|
|
60
60
|
);
|
|
61
|
-
|
|
62
|
-
const h = "DialogPortal", [
|
|
61
|
+
z.displayName = v;
|
|
62
|
+
const h = "DialogPortal", [J, x] = E(h, {
|
|
63
63
|
forceMount: void 0
|
|
64
64
|
}), N = (o) => {
|
|
65
65
|
const { __scopeDialog: n, forceMount: r, children: s, container: e } = o, t = l(h, n);
|
|
66
|
-
return /* @__PURE__ */
|
|
66
|
+
return /* @__PURE__ */ c(J, { scope: n, forceMount: r, children: i.Children.map(s, (a) => /* @__PURE__ */ c(O, { present: r || t.open, children: /* @__PURE__ */ c(B, { asChild: !0, container: e, children: a }) })) });
|
|
67
67
|
};
|
|
68
68
|
N.displayName = h;
|
|
69
|
-
const
|
|
69
|
+
const R = "DialogOverlay", M = i.forwardRef(
|
|
70
70
|
(o, n) => {
|
|
71
|
-
const r = x(
|
|
72
|
-
return t.modal ? /* @__PURE__ */
|
|
71
|
+
const r = x(R, o.__scopeDialog), { forceMount: s = r.forceMount, ...e } = o, t = l(R, o.__scopeDialog);
|
|
72
|
+
return t.modal ? /* @__PURE__ */ c(O, { present: s || t.open, children: /* @__PURE__ */ c(Q, { ...e, ref: n }) }) : null;
|
|
73
73
|
}
|
|
74
74
|
);
|
|
75
|
-
M.displayName =
|
|
76
|
-
const
|
|
75
|
+
M.displayName = R;
|
|
76
|
+
const Q = i.forwardRef(
|
|
77
77
|
(o, n) => {
|
|
78
|
-
const { __scopeDialog: r, ...s } = o, e = l(
|
|
78
|
+
const { __scopeDialog: r, ...s } = o, e = l(R, r);
|
|
79
79
|
return (
|
|
80
80
|
// Make sure `Content` is scrollable even when it doesn't live inside `RemoveScroll`
|
|
81
81
|
// ie. when `Overlay` and `Content` are siblings
|
|
82
|
-
/* @__PURE__ */
|
|
83
|
-
|
|
82
|
+
/* @__PURE__ */ c(
|
|
83
|
+
K,
|
|
84
84
|
{
|
|
85
|
-
as:
|
|
85
|
+
as: Y,
|
|
86
86
|
allowPinchZoom: !0,
|
|
87
87
|
shards: [e.contentRef],
|
|
88
88
|
gapMode: "padding",
|
|
89
89
|
removeScrollBar: !0,
|
|
90
|
-
children: /* @__PURE__ */
|
|
90
|
+
children: /* @__PURE__ */ c(
|
|
91
91
|
d.div,
|
|
92
92
|
{
|
|
93
93
|
"data-state": y(e.open),
|
|
@@ -100,42 +100,45 @@ const U = c.forwardRef(
|
|
|
100
100
|
)
|
|
101
101
|
);
|
|
102
102
|
}
|
|
103
|
-
),
|
|
103
|
+
), f = "DialogContent", T = i.forwardRef(
|
|
104
104
|
(o, n) => {
|
|
105
|
-
const r = x(
|
|
106
|
-
return /* @__PURE__ */
|
|
105
|
+
const r = x(f, o.__scopeDialog), { forceMount: s = r.forceMount, ...e } = o, t = l(f, o.__scopeDialog);
|
|
106
|
+
return /* @__PURE__ */ c(O, { present: s || t.open, children: t.modal ? /* @__PURE__ */ c(U, { ...e, ref: n }) : /* @__PURE__ */ c(X, { ...e, ref: n }) });
|
|
107
107
|
}
|
|
108
108
|
);
|
|
109
|
-
T.displayName =
|
|
110
|
-
const
|
|
109
|
+
T.displayName = f;
|
|
110
|
+
const U = i.forwardRef(
|
|
111
111
|
(o, n) => {
|
|
112
|
-
const r = l(
|
|
113
|
-
return
|
|
112
|
+
const r = l(f, o.__scopeDialog), s = i.useRef(null), e = _(n, r.contentRef, s);
|
|
113
|
+
return i.useEffect(() => {
|
|
114
114
|
const t = s.current;
|
|
115
|
-
if (t)
|
|
116
|
-
|
|
117
|
-
|
|
115
|
+
if (t) {
|
|
116
|
+
const a = document.querySelectorAll("[data-ikp-component]");
|
|
117
|
+
return V([t, ...Array.from(a)]);
|
|
118
|
+
}
|
|
119
|
+
}, []), /* @__PURE__ */ c(
|
|
120
|
+
A,
|
|
118
121
|
{
|
|
119
122
|
...o,
|
|
120
123
|
ref: e,
|
|
121
124
|
trapFocus: r.open,
|
|
122
125
|
disableOutsidePointerEvents: !0,
|
|
123
|
-
onPointerDownOutside:
|
|
124
|
-
const a = t.detail.originalEvent,
|
|
125
|
-
(a.button === 2 ||
|
|
126
|
+
onPointerDownOutside: D(o.onPointerDownOutside, (t) => {
|
|
127
|
+
const a = t.detail.originalEvent, p = a.button === 0 && a.ctrlKey === !0;
|
|
128
|
+
(a.button === 2 || p) && t.preventDefault(), t.target.closest("[data-ikp-component]") && t.preventDefault();
|
|
126
129
|
}),
|
|
127
|
-
onFocusOutside:
|
|
130
|
+
onFocusOutside: D(
|
|
128
131
|
o.onFocusOutside,
|
|
129
132
|
(t) => t.preventDefault()
|
|
130
133
|
)
|
|
131
134
|
}
|
|
132
135
|
);
|
|
133
136
|
}
|
|
134
|
-
), X =
|
|
137
|
+
), X = i.forwardRef(
|
|
135
138
|
(o, n) => {
|
|
136
|
-
const r = l(
|
|
137
|
-
return /* @__PURE__ */
|
|
138
|
-
|
|
139
|
+
const r = l(f, o.__scopeDialog), s = i.useRef(!1), e = i.useRef(!1);
|
|
140
|
+
return /* @__PURE__ */ c(
|
|
141
|
+
A,
|
|
139
142
|
{
|
|
140
143
|
...o,
|
|
141
144
|
ref: n,
|
|
@@ -149,75 +152,75 @@ const W = c.forwardRef(
|
|
|
149
152
|
}
|
|
150
153
|
);
|
|
151
154
|
}
|
|
152
|
-
),
|
|
155
|
+
), A = i.forwardRef(
|
|
153
156
|
(o, n) => {
|
|
154
|
-
const { __scopeDialog: r, trapFocus: s, onOpenAutoFocus: e, onCloseAutoFocus: t, ...a } = o,
|
|
155
|
-
return
|
|
157
|
+
const { __scopeDialog: r, trapFocus: s, onOpenAutoFocus: e, onCloseAutoFocus: t, ...a } = o, p = l(f, r), u = i.useRef(null), g = _(n, u);
|
|
158
|
+
return H(), G(() => {
|
|
156
159
|
if (s)
|
|
157
|
-
return
|
|
160
|
+
return q(u.current, {
|
|
158
161
|
preventScroll: !0,
|
|
159
162
|
onActivate: e,
|
|
160
163
|
onDeactivate: t,
|
|
161
164
|
initialFocus: !1
|
|
162
165
|
});
|
|
163
|
-
}, []), /* @__PURE__ */
|
|
164
|
-
|
|
166
|
+
}, []), /* @__PURE__ */ c(
|
|
167
|
+
j,
|
|
165
168
|
{
|
|
166
169
|
role: "dialog",
|
|
167
|
-
id:
|
|
168
|
-
"aria-describedby":
|
|
169
|
-
"aria-labelledby":
|
|
170
|
-
"data-state": y(
|
|
170
|
+
id: p.contentId,
|
|
171
|
+
"aria-describedby": p.descriptionId,
|
|
172
|
+
"aria-labelledby": p.titleId,
|
|
173
|
+
"data-state": y(p.open),
|
|
171
174
|
...a,
|
|
172
|
-
ref:
|
|
173
|
-
onDismiss: () =>
|
|
175
|
+
ref: g,
|
|
176
|
+
onDismiss: () => p.onOpenChange(!1)
|
|
174
177
|
}
|
|
175
178
|
);
|
|
176
179
|
}
|
|
177
|
-
),
|
|
180
|
+
), b = "DialogTitle", w = i.forwardRef(
|
|
178
181
|
(o, n) => {
|
|
179
|
-
const { __scopeDialog: r, ...s } = o, e = l(
|
|
180
|
-
return /* @__PURE__ */
|
|
182
|
+
const { __scopeDialog: r, ...s } = o, e = l(b, r);
|
|
183
|
+
return /* @__PURE__ */ c(d.h2, { id: e.titleId, ...s, ref: n });
|
|
181
184
|
}
|
|
182
185
|
);
|
|
183
|
-
|
|
184
|
-
const
|
|
186
|
+
w.displayName = b;
|
|
187
|
+
const k = "DialogDescription", oo = i.forwardRef(
|
|
185
188
|
(o, n) => {
|
|
186
|
-
const { __scopeDialog: r, ...s } = o, e = l(
|
|
187
|
-
return /* @__PURE__ */
|
|
189
|
+
const { __scopeDialog: r, ...s } = o, e = l(k, r);
|
|
190
|
+
return /* @__PURE__ */ c(d.p, { id: e.descriptionId, ...s, ref: n });
|
|
188
191
|
}
|
|
189
192
|
);
|
|
190
|
-
oo.displayName =
|
|
191
|
-
const
|
|
193
|
+
oo.displayName = k;
|
|
194
|
+
const F = "DialogClose", S = i.forwardRef(
|
|
192
195
|
(o, n) => {
|
|
193
|
-
const { __scopeDialog: r, ...s } = o, e = l(
|
|
194
|
-
return /* @__PURE__ */
|
|
196
|
+
const { __scopeDialog: r, ...s } = o, e = l(F, r);
|
|
197
|
+
return /* @__PURE__ */ c(
|
|
195
198
|
d.button,
|
|
196
199
|
{
|
|
197
200
|
type: "button",
|
|
198
201
|
...s,
|
|
199
202
|
ref: n,
|
|
200
|
-
onClick:
|
|
203
|
+
onClick: D(o.onClick, () => e.onOpenChange(!1))
|
|
201
204
|
}
|
|
202
205
|
);
|
|
203
206
|
}
|
|
204
207
|
);
|
|
205
|
-
|
|
208
|
+
S.displayName = F;
|
|
206
209
|
function y(o) {
|
|
207
210
|
return o ? "open" : "closed";
|
|
208
211
|
}
|
|
209
|
-
const _o =
|
|
212
|
+
const _o = I, Oo = N, Po = M, ho = T, yo = w, Eo = S;
|
|
210
213
|
export {
|
|
211
214
|
Eo as Close,
|
|
212
215
|
ho as Content,
|
|
213
|
-
|
|
214
|
-
|
|
216
|
+
I as Dialog,
|
|
217
|
+
S as DialogClose,
|
|
215
218
|
T as DialogContent,
|
|
216
219
|
oo as DialogDescription,
|
|
217
220
|
M as DialogOverlay,
|
|
218
221
|
N as DialogPortal,
|
|
219
|
-
|
|
220
|
-
|
|
222
|
+
w as DialogTitle,
|
|
223
|
+
z as DialogTrigger,
|
|
221
224
|
Po as Overlay,
|
|
222
225
|
Oo as Portal,
|
|
223
226
|
_o as Root,
|
|
@@ -1,3 +1,3 @@
|
|
|
1
|
-
"use client";"use strict";Object.defineProperty(exports,Symbol.toStringTag,{value:"Module"});const
|
|
1
|
+
"use client";"use strict";Object.defineProperty(exports,Symbol.toStringTag,{value:"Module"});const G=require("@ai-sdk/react"),X=require("ai"),t=require("react"),Y=require("../../providers/config-provider.cjs"),Z=require("../../hooks/use-media-query.cjs"),ee=require("../../utils/generate-uid.cjs"),te=require("../../providers/base-events-provider.cjs"),se=require("../../providers/chat-form-provider.cjs"),ne=require("../../providers/widget-provider.cjs"),re=require("@radix-ui/react-use-controllable-state"),ae=require("../../hooks/use-streaming-events.cjs"),oe=()=>{const{baseSettings:h,aiChatSettings:o}=Y.useInkeepConfig(),[n="",f]=re.useControllableState({prop:o.conversationId,defaultProp:o.conversationId??""}),{logEvent:i}=te.useBaseEvents(),{setConversationId:_,emitStreamError:k}=ae.useStreamingEvents(),[a,u]=t.useState(""),F=e=>u(e.target.value),{filters:v}=h,{onInputMessageChange:P,filters:S,graphUrl:x,context:N,headers:D,apiKey:C}=o,A=e=>{switch(e.code){case 400:return e.message;case 403:return`There seems to be a configuration error. Please contact ${h.organizationDisplayName??"Administrator"}`;default:return`Hmm..
|
|
2
2
|
|
|
3
|
-
It seems I might be having some issues right now. Please clear the chat and try again.`}},[
|
|
3
|
+
It seems I might be having some issues right now. Please clear the chat and try again.`}},[B,R]=t.useState({}),[U,l]=t.useState([]),[K,I]=t.useState(null),{messages:g,sendMessage:T,status:b,setMessages:y,stop:W,error:d}=G.useChat({transport:new X.DefaultChatTransport({api:x,headers:{...C?{Authorization:`Bearer ${C}`}:{},...D},body:{requestContext:N}}),async onFinish(){await i({eventName:"assistant_message_received",properties:{conversationId:n}}),i({eventName:"assistant_answer_displayed",properties:{conversationId:n}})},onError(e){console.log("onError",e.message),k(e.message,void 0,e.code?.toString()),y(c=>{const r=[...c],s=r[r.length-1];return s&&(s.parts=[{type:"text",text:A(e)}]),r})}}),E=b==="submitted",$=b==="streaming",z=g.length===0,m=!a.trim()||E,H=Z.useMediaQuery("(max-width: 768px)"),[O,w]=t.useState(null);t.useEffect(()=>{d&&w(d)},[d]);const Q=()=>w(null),M=t.useRef(null);t.useEffect(()=>{P?.(a)},[a]);const j=e=>{e.key==="Enter"&&!e.shiftKey&&!m&&!e.nativeEvent.isComposing&&(e.preventDefault(),p())},p=async(e=a)=>{if(m&&(!e||e.trim().length===0))return;l([]),u(""),await i({eventName:"user_message_submitted",properties:{conversationId:n}});const c=v||S?JSON.stringify({...v,...S}):void 0,r={};c&&(r["inkeep-filters"]=c);let s=n;s||(s=`conv_${ee.generateUid(16)}`,f(s)),_(s),T({text:e},{headers:r,body:{conversationId:s}})},J=()=>{W()},q=()=>{Q(),y([]),f(""),R({}),l([]),I(null),i({eventName:"chat_clear_button_clicked",properties:{conversationId:n}})},{openForm:L}=se.useChatForm(),V=ne.useWidget();return t.useImperativeHandle(o.chatFunctionsRef,()=>({submitMessage:p,updateInputMessage(e){u(e)},clearChat:q,openForm:e=>{V?.setView("chat"),L(e,void 0)},focusInput:()=>{M.current?.focus()}})),{messages:g,isLoading:E,isStreaming:$,error:O,isSubmitDisabled:m,input:a,handleInputChange:F,handleInputKeyDown:j,handleSubmit:p,stop:J,clear:q,messageButtons:B,isEmpty:g.length===0,inputRef:M,isMobile:H,messageAttachments:U,setMessageAttachments:l,selectedWorkflow:K,setSelectedWorkflow:I,isNewChat:z,conversationId:n}};exports.useInkeepChat=oe;
|
|
@@ -1,29 +1,30 @@
|
|
|
1
1
|
"use client";
|
|
2
|
-
import { useChat as
|
|
3
|
-
import { DefaultChatTransport as
|
|
4
|
-
import { useState as r, useEffect as x, useRef as
|
|
5
|
-
import { useInkeepConfig as
|
|
6
|
-
import { useMediaQuery as
|
|
7
|
-
import { generateUid as
|
|
8
|
-
import { useBaseEvents as
|
|
9
|
-
import { useChatForm as
|
|
10
|
-
import { useWidget as
|
|
11
|
-
import { useControllableState as
|
|
12
|
-
|
|
13
|
-
|
|
2
|
+
import { useChat as X } from "@ai-sdk/react";
|
|
3
|
+
import { DefaultChatTransport as Y } from "ai";
|
|
4
|
+
import { useState as r, useEffect as x, useRef as Z, useImperativeHandle as ee } from "react";
|
|
5
|
+
import { useInkeepConfig as te } from "../../providers/config-provider.js";
|
|
6
|
+
import { useMediaQuery as se } from "../../hooks/use-media-query.js";
|
|
7
|
+
import { generateUid as ne } from "../../utils/generate-uid.js";
|
|
8
|
+
import { useBaseEvents as oe } from "../../providers/base-events-provider.js";
|
|
9
|
+
import { useChatForm as re } from "../../providers/chat-form-provider.js";
|
|
10
|
+
import { useWidget as ae } from "../../providers/widget-provider.js";
|
|
11
|
+
import { useControllableState as ie } from "@radix-ui/react-use-controllable-state";
|
|
12
|
+
import { useStreamingEvents as ce } from "../../hooks/use-streaming-events.js";
|
|
13
|
+
const be = () => {
|
|
14
|
+
const { baseSettings: h, aiChatSettings: a } = te(), [s = "", f] = ie({
|
|
14
15
|
prop: a.conversationId,
|
|
15
16
|
defaultProp: a.conversationId ?? ""
|
|
16
|
-
}), { logEvent: i } =
|
|
17
|
+
}), { logEvent: i } = oe(), { setConversationId: k, emitStreamError: F } = ce(), [o, m] = r(""), N = (e) => m(e.target.value), {
|
|
17
18
|
/* shouldBypassCaptcha, */
|
|
18
19
|
filters: v
|
|
19
20
|
} = h, {
|
|
20
|
-
onInputMessageChange:
|
|
21
|
+
onInputMessageChange: D,
|
|
21
22
|
filters: I,
|
|
22
|
-
graphUrl:
|
|
23
|
-
context:
|
|
24
|
-
headers:
|
|
23
|
+
graphUrl: A,
|
|
24
|
+
context: B,
|
|
25
|
+
headers: K,
|
|
25
26
|
apiKey: C
|
|
26
|
-
} = a,
|
|
27
|
+
} = a, P = (e) => {
|
|
27
28
|
switch (e.code) {
|
|
28
29
|
case 400:
|
|
29
30
|
return e.message;
|
|
@@ -34,25 +35,25 @@ const fe = () => {
|
|
|
34
35
|
|
|
35
36
|
It seems I might be having some issues right now. Please clear the chat and try again.`;
|
|
36
37
|
}
|
|
37
|
-
}, [
|
|
38
|
+
}, [R, W] = r({}), [$, u] = r([]), [z, b] = r(null), {
|
|
38
39
|
messages: l,
|
|
39
|
-
sendMessage:
|
|
40
|
+
sendMessage: H,
|
|
40
41
|
status: y,
|
|
41
42
|
setMessages: w,
|
|
42
|
-
stop:
|
|
43
|
+
stop: T,
|
|
43
44
|
error: p
|
|
44
|
-
} =
|
|
45
|
-
transport: new
|
|
46
|
-
api:
|
|
45
|
+
} = X({
|
|
46
|
+
transport: new Y({
|
|
47
|
+
api: A,
|
|
47
48
|
headers: {
|
|
48
49
|
...C ? { Authorization: `Bearer ${C}` } : {},
|
|
49
|
-
...
|
|
50
|
+
...K
|
|
50
51
|
},
|
|
51
52
|
body: {
|
|
52
|
-
requestContext:
|
|
53
|
+
requestContext: B
|
|
53
54
|
}
|
|
54
55
|
}),
|
|
55
|
-
async onFinish(
|
|
56
|
+
async onFinish() {
|
|
56
57
|
await i({
|
|
57
58
|
eventName: "assistant_message_received",
|
|
58
59
|
properties: {
|
|
@@ -66,20 +67,20 @@ It seems I might be having some issues right now. Please clear the chat and try
|
|
|
66
67
|
});
|
|
67
68
|
},
|
|
68
69
|
onError(e) {
|
|
69
|
-
console.log("onError", e.message), w((c) => {
|
|
70
|
+
console.log("onError", e.message), F(e.message, void 0, e.code?.toString()), w((c) => {
|
|
70
71
|
const n = [...c], t = n[n.length - 1];
|
|
71
|
-
return t && (t.parts = [{ type: "text", text:
|
|
72
|
+
return t && (t.parts = [{ type: "text", text: P(e) }]), n;
|
|
72
73
|
});
|
|
73
74
|
}
|
|
74
|
-
}), E = y === "submitted",
|
|
75
|
+
}), E = y === "submitted", U = y === "streaming", q = l.length === 0, g = !o.trim() || E, J = se("(max-width: 768px)"), [L, S] = r(null);
|
|
75
76
|
x(() => {
|
|
76
|
-
p &&
|
|
77
|
+
p && S(p);
|
|
77
78
|
}, [p]);
|
|
78
|
-
const
|
|
79
|
+
const O = () => S(null), M = Z(null);
|
|
79
80
|
x(() => {
|
|
80
|
-
|
|
81
|
+
D?.(o);
|
|
81
82
|
}, [o]);
|
|
82
|
-
const
|
|
83
|
+
const Q = (e) => {
|
|
83
84
|
e.key === "Enter" && !e.shiftKey && !g && !e.nativeEvent.isComposing && (e.preventDefault(), d());
|
|
84
85
|
}, d = async (e = o) => {
|
|
85
86
|
if (g && (!e || e.trim().length === 0)) return;
|
|
@@ -95,7 +96,7 @@ It seems I might be having some issues right now. Please clear the chat and try
|
|
|
95
96
|
}) : void 0, n = {};
|
|
96
97
|
c && (n["inkeep-filters"] = c);
|
|
97
98
|
let t = s;
|
|
98
|
-
t || (t = `conv_${
|
|
99
|
+
t || (t = `conv_${ne(16)}`, f(t)), k(t), H(
|
|
99
100
|
// { ...userMessage, files },
|
|
100
101
|
// { ...userMessage, },
|
|
101
102
|
{
|
|
@@ -108,53 +109,53 @@ It seems I might be having some issues right now. Please clear the chat and try
|
|
|
108
109
|
}
|
|
109
110
|
}
|
|
110
111
|
);
|
|
111
|
-
},
|
|
112
|
-
|
|
112
|
+
}, V = () => {
|
|
113
|
+
T();
|
|
113
114
|
}, _ = () => {
|
|
114
|
-
|
|
115
|
+
O(), w([]), f(""), W({}), u([]), b(null), i({
|
|
115
116
|
eventName: "chat_clear_button_clicked",
|
|
116
117
|
properties: {
|
|
117
118
|
conversationId: s
|
|
118
119
|
}
|
|
119
120
|
});
|
|
120
|
-
}, { openForm:
|
|
121
|
-
return
|
|
121
|
+
}, { openForm: j } = re(), G = ae();
|
|
122
|
+
return ee(a.chatFunctionsRef, () => ({
|
|
122
123
|
submitMessage: d,
|
|
123
124
|
updateInputMessage(e) {
|
|
124
125
|
m(e);
|
|
125
126
|
},
|
|
126
127
|
clearChat: _,
|
|
127
128
|
openForm: (e) => {
|
|
128
|
-
|
|
129
|
+
G?.setView("chat"), j(e, void 0);
|
|
129
130
|
},
|
|
130
131
|
focusInput: () => {
|
|
131
|
-
|
|
132
|
+
M.current?.focus();
|
|
132
133
|
}
|
|
133
134
|
})), {
|
|
134
135
|
messages: l,
|
|
135
136
|
isLoading: E,
|
|
136
|
-
isStreaming:
|
|
137
|
-
error:
|
|
137
|
+
isStreaming: U,
|
|
138
|
+
error: L,
|
|
138
139
|
isSubmitDisabled: g,
|
|
139
140
|
input: o,
|
|
140
|
-
handleInputChange:
|
|
141
|
-
handleInputKeyDown:
|
|
141
|
+
handleInputChange: N,
|
|
142
|
+
handleInputKeyDown: Q,
|
|
142
143
|
handleSubmit: d,
|
|
143
|
-
stop:
|
|
144
|
+
stop: V,
|
|
144
145
|
clear: _,
|
|
145
|
-
messageButtons:
|
|
146
|
+
messageButtons: R,
|
|
146
147
|
isEmpty: l.length === 0,
|
|
147
|
-
inputRef:
|
|
148
|
-
isMobile:
|
|
148
|
+
inputRef: M,
|
|
149
|
+
isMobile: J,
|
|
149
150
|
// Additional state for attachments and workflow
|
|
150
|
-
messageAttachments:
|
|
151
|
+
messageAttachments: $,
|
|
151
152
|
setMessageAttachments: u,
|
|
152
|
-
selectedWorkflow:
|
|
153
|
+
selectedWorkflow: z,
|
|
153
154
|
setSelectedWorkflow: b,
|
|
154
|
-
isNewChat:
|
|
155
|
+
isNewChat: q,
|
|
155
156
|
conversationId: s
|
|
156
157
|
};
|
|
157
158
|
};
|
|
158
159
|
export {
|
|
159
|
-
|
|
160
|
+
be as useInkeepChat
|
|
160
161
|
};
|
|
@@ -1 +1 @@
|
|
|
1
|
-
"use client";"use strict";Object.defineProperty(exports,Symbol.toStringTag,{value:"Module"});const
|
|
1
|
+
"use client";"use strict";Object.defineProperty(exports,Symbol.toStringTag,{value:"Module"});const a=require("react"),b=require("../../../types/message.cjs"),L=require("../../hooks/use-streaming-events.cjs");function E(r,c){const[u,A]=a.useState([]),[p,D]=a.useState(new Map),[d,P]=a.useState(Date.now()),[R,g]=a.useState(!1),h=a.useRef(0),y=a.useRef(0),w=a.useRef([]),l=a.useRef(p);l.current=p;const{emitArtifactSaved:S,emitCompletion:x,emitAgentInitializing:k,emitTextDelta:C}=L.useStreamingEvents(),T=a.useCallback(()=>{const n=[];let e="",o=[];r.length>h.current&&(P(Date.now()),h.current=r.length),y.current=0;const i=new Map,m=(t=!1)=>{if(o.length>0){const s=`group-${y.current++}`,f=l.current.get(s);f?i.set(s,{...f,isCompleted:t}):i.set(s,{isCompleted:t}),n.push({type:"summary-group",summaries:[...o],groupKey:s}),o=[]}};for(const t of r)if(t.type==="text")m(!0),t.text&&c&&C(t.text),e+=t.text||"";else if(t.type==="data-summary")e.trim()&&(n.push({type:"text",text:e}),e=""),o.push(t.data);else if(t.type==="data-operation"){const s=t.data;if(s?.type)switch(s.type){case"completion":x("unknown",1),m(!0);break;case"agent_initializing":k("unknown","unknown");break;case"error":console.warn("Data operation error:",s.ctx);break;case"agent_thinking":case"agent_ready":console.log("Agent state:",s.type,s.ctx);break}}else if(t.type==="data-artifact")if(t.data?.type?.toLowerCase()===b.CITATION_ARTIFACT_TYPE){const s=t.data,f=s.artifactSummary||{title:s.name};e+=` ^${f?.title||s.name}^`}else e.trim()&&(n.push({type:"text",text:e}),e=""),n.push(t),t.data&&S(t.data.artifactId||"unknown",t.data.taskId||"unknown","unknown",t.data.artifactType||"unknown",t.data.artifactSummary||{},{},{name:t.data.name,description:t.data.description});else t.type==="data-component"&&(e.trim()&&(n.push({type:"text",text:e}),e=""),n.push(t));return m(!c),e.trim()&&n.push({type:"text",text:e}),{processed:n,newTimings:i}},[r,c,S,x,k,C]);a.useEffect(()=>{if(w.current===r)return;w.current=r;const{processed:n,newTimings:e}=T();A(n),(e.size!==l.current.size||Array.from(e.entries()).some(([i,m])=>{const t=l.current.get(i);return!t||t.isCompleted!==m.isCompleted}))&&D(e)},[T,r]);const v=a.useCallback(()=>{const n=Date.now()-d,e=Array.from(l.current.values()).some(i=>!i.isCompleted),o=n>1e3&&!e;g(o)},[d]);a.useEffect(()=>{if(!c){g(!1);return}if(!(u.length>0)){g(!1);return}const e=setInterval(v,200);return()=>clearInterval(e)},[c,v,u.length]);const I=a.useMemo(()=>!(u.length>0),[u.length]);return{processedParts:u,summaryTimings:p,shouldShowInitialLoading:I,shouldShowStreamDelayLoading:R}}exports.useStreamProcessor=E;
|