@inkeep/agents-ui 0.15.1 → 0.15.2
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/components/embedded-chat/use-inkeep-chat.cjs +2 -2
- package/dist/primitives/components/embedded-chat/use-inkeep-chat.js +80 -72
- package/dist/primitives/providers/base-events-provider.cjs +1 -1
- package/dist/primitives/providers/base-events-provider.js +1 -1
- package/dist/styled/components/data-summary-group.cjs +1 -1
- package/dist/styled/components/data-summary-group.js +13 -13
- package/dist/styled/components/message.cjs +1 -1
- package/dist/styled/components/message.js +33 -33
- package/package.json +1 -1
|
@@ -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 Z=require("@ai-sdk/react"),ee=require("ai"),s=require("react"),te=require("../../providers/config-provider.cjs"),se=require("../../hooks/use-media-query.cjs"),R=require("../../utils/generate-uid.cjs"),ne=require("../../providers/base-events-provider.cjs"),re=require("../../providers/chat-form-provider.cjs"),ae=require("../../providers/widget-provider.cjs"),oe=require("@radix-ui/react-use-controllable-state"),ie=require("../../hooks/use-streaming-events.cjs"),x=`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.`,ce=()=>{const{baseSettings:v,aiChatSettings:o}=te.useInkeepConfig(),[n="",E]=oe.useControllableState({prop:o.conversationId,defaultProp:o.conversationId??""}),{logEvent:i}=ne.useBaseEvents(),{setConversationId:P,emitToParent:u}=ie.useStreamingEvents(),[a,l]=s.useState(""),k=e=>l(e.target.value),{filters:S}=v,{onInputMessageChange:A,filters:b,agentUrl:D,context:N,headers:U,apiKey:y}=o,T=e=>{switch(e.code){case 400:return e.message;case 403:return`There seems to be a configuration error. Please contact ${v.organizationDisplayName??"Administrator"}`;default:return x}},[B,O]=s.useState({}),[K,d]=s.useState([]),[L,C]=s.useState(null),{messages:g,sendMessage:W,status:I,setMessages:M,stop:$,error:p}=Z.useChat({transport:new ee.DefaultChatTransport({api:D,headers:{...y?{Authorization:`Bearer ${y}`}:{},...U},body:{requestContext:N}}),onData(e){u(e.type,e.data)},async onFinish(){u("completion",{conversationId:n}),await i({eventName:"assistant_message_received",properties:{conversationId:n}}),i({eventName:"assistant_answer_displayed",properties:{conversationId:n}})},onError(e){console.log("onError",e.message),M(c=>{const r=[...c],t=r[r.length-1];if(t){const F=T(e);t.role==="user"?r.push({id:R.generateUid(16),role:"assistant",parts:[{type:"text",text:F}]}):t.parts=[{type:"text",text:F}]}return r})}}),w=I==="submitted",z=I==="streaming",G=g.length===0,m=!a.trim()||w,H=se.useMediaQuery("(max-width: 768px)"),[Q,h]=s.useState(null);s.useEffect(()=>{p&&h(p)},[p]);const j=()=>h(null),_=s.useRef(null);s.useEffect(()=>{A?.(a)},[a]);const J=e=>{e.key==="Enter"&&!e.shiftKey&&!m&&!e.nativeEvent.isComposing&&(e.preventDefault(),f())},f=async(e=a)=>{if(m&&(!e||e.trim().length===0))return;d([]),l(""),await i({eventName:"user_message_submitted",properties:{conversationId:n}});const c=S||b?JSON.stringify({...S,...b}):void 0,r={};c&&(r["inkeep-filters"]=c);let t=n;t||(t=`conv_${R.generateUid(16)}`,E(t)),P(t),W({text:e},{headers:r,body:{conversationId:t}})},V=()=>{$().then(()=>{u("aborted",{conversationId:n})})},q=()=>{j(),M([]),E(""),O({}),d([]),C(null),i({eventName:"chat_clear_button_clicked",properties:{conversationId:n}})},{openForm:X}=re.useChatForm(),Y=ae.useWidget();return s.useImperativeHandle(o.chatFunctionsRef,()=>({submitMessage:f,updateInputMessage(e){l(e)},clearChat:q,openForm:e=>{Y?.setView("chat"),X(e,void 0)},focusInput:()=>{_.current?.focus()}})),{messages:g,isLoading:w,isStreaming:z,error:Q,setError:h,isSubmitDisabled:m,input:a,handleInputChange:k,handleInputKeyDown:J,handleSubmit:f,stop:V,clear:q,messageButtons:B,isEmpty:g.length===0,inputRef:_,isMobile:H,messageAttachments:K,setMessageAttachments:d,selectedWorkflow:L,setSelectedWorkflow:C,isNewChat:G,conversationId:n}};exports.DEFAULT_ERROR_MESSAGE=x;exports.useInkeepChat=ce;
|
|
@@ -1,105 +1,113 @@
|
|
|
1
1
|
"use client";
|
|
2
|
-
import { useChat as
|
|
3
|
-
import { DefaultChatTransport as
|
|
4
|
-
import { useState as r, useEffect 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
|
-
import { useStreamingEvents as
|
|
13
|
-
const
|
|
2
|
+
import { useChat as Z } from "@ai-sdk/react";
|
|
3
|
+
import { DefaultChatTransport as ee } from "ai";
|
|
4
|
+
import { useState as r, useEffect as k, useRef as te, useImperativeHandle as se } from "react";
|
|
5
|
+
import { useInkeepConfig as ne } from "../../providers/config-provider.js";
|
|
6
|
+
import { useMediaQuery as oe } from "../../hooks/use-media-query.js";
|
|
7
|
+
import { generateUid as D } from "../../utils/generate-uid.js";
|
|
8
|
+
import { useBaseEvents as re } from "../../providers/base-events-provider.js";
|
|
9
|
+
import { useChatForm as ae } from "../../providers/chat-form-provider.js";
|
|
10
|
+
import { useWidget as ie } from "../../providers/widget-provider.js";
|
|
11
|
+
import { useControllableState as ce } from "@radix-ui/react-use-controllable-state";
|
|
12
|
+
import { useStreamingEvents as me } from "../../hooks/use-streaming-events.js";
|
|
13
|
+
const le = `Hmm..
|
|
14
14
|
|
|
15
15
|
It seems I might be having some issues right now. Please clear the chat and try again.`, be = () => {
|
|
16
|
-
const { baseSettings: v, aiChatSettings: a } =
|
|
16
|
+
const { baseSettings: v, aiChatSettings: a } = ne(), [s = "", I] = ce({
|
|
17
17
|
prop: a.conversationId,
|
|
18
18
|
defaultProp: a.conversationId ?? ""
|
|
19
|
-
}), { logEvent: i } =
|
|
19
|
+
}), { logEvent: i } = re(), { setConversationId: N, emitToParent: m } = me(), [o, l] = r(""), A = (e) => l(e.target.value), {
|
|
20
20
|
/* shouldBypassCaptcha, */
|
|
21
21
|
filters: C
|
|
22
22
|
} = v, {
|
|
23
|
-
onInputMessageChange:
|
|
24
|
-
filters:
|
|
25
|
-
agentUrl:
|
|
26
|
-
context:
|
|
27
|
-
headers:
|
|
28
|
-
apiKey:
|
|
29
|
-
} = a,
|
|
23
|
+
onInputMessageChange: R,
|
|
24
|
+
filters: y,
|
|
25
|
+
agentUrl: B,
|
|
26
|
+
context: P,
|
|
27
|
+
headers: T,
|
|
28
|
+
apiKey: E
|
|
29
|
+
} = a, K = (e) => {
|
|
30
30
|
switch (e.code) {
|
|
31
31
|
case 400:
|
|
32
32
|
return e.message;
|
|
33
33
|
case 403:
|
|
34
34
|
return `There seems to be a configuration error. Please contact ${v.organizationDisplayName ?? "Administrator"}`;
|
|
35
35
|
default:
|
|
36
|
-
return
|
|
36
|
+
return le;
|
|
37
37
|
}
|
|
38
|
-
}, [
|
|
38
|
+
}, [U, W] = r({}), [$, u] = r([]), [z, b] = r(null), {
|
|
39
39
|
messages: p,
|
|
40
|
-
sendMessage:
|
|
40
|
+
sendMessage: H,
|
|
41
41
|
status: w,
|
|
42
42
|
setMessages: S,
|
|
43
|
-
stop:
|
|
43
|
+
stop: L,
|
|
44
44
|
error: g
|
|
45
|
-
} =
|
|
46
|
-
transport: new
|
|
47
|
-
api:
|
|
45
|
+
} = Z({
|
|
46
|
+
transport: new ee({
|
|
47
|
+
api: B,
|
|
48
48
|
headers: {
|
|
49
|
-
...
|
|
50
|
-
...
|
|
49
|
+
...E ? { Authorization: `Bearer ${E}` } : {},
|
|
50
|
+
...T
|
|
51
51
|
},
|
|
52
52
|
body: {
|
|
53
|
-
requestContext:
|
|
53
|
+
requestContext: P
|
|
54
54
|
}
|
|
55
55
|
}),
|
|
56
56
|
onData(e) {
|
|
57
57
|
m(e.type, e.data);
|
|
58
58
|
},
|
|
59
59
|
async onFinish() {
|
|
60
|
-
m("completion", { conversationId:
|
|
60
|
+
m("completion", { conversationId: s }), await i({
|
|
61
61
|
eventName: "assistant_message_received",
|
|
62
62
|
properties: {
|
|
63
|
-
conversationId:
|
|
63
|
+
conversationId: s
|
|
64
64
|
}
|
|
65
65
|
}), i({
|
|
66
66
|
eventName: "assistant_answer_displayed",
|
|
67
67
|
properties: {
|
|
68
|
-
conversationId:
|
|
68
|
+
conversationId: s
|
|
69
69
|
}
|
|
70
70
|
});
|
|
71
71
|
},
|
|
72
72
|
onError(e) {
|
|
73
73
|
console.log("onError", e.message), S((c) => {
|
|
74
|
-
const n = [...c],
|
|
75
|
-
|
|
74
|
+
const n = [...c], t = n[n.length - 1];
|
|
75
|
+
if (t) {
|
|
76
|
+
const F = K(e);
|
|
77
|
+
t.role === "user" ? n.push({
|
|
78
|
+
id: D(16),
|
|
79
|
+
role: "assistant",
|
|
80
|
+
parts: [{ type: "text", text: F }]
|
|
81
|
+
}) : t.parts = [{ type: "text", text: F }];
|
|
82
|
+
}
|
|
83
|
+
return n;
|
|
76
84
|
});
|
|
77
85
|
}
|
|
78
|
-
}), M = w === "submitted",
|
|
79
|
-
|
|
86
|
+
}), M = w === "submitted", O = w === "streaming", q = p.length === 0, d = !o.trim() || M, G = oe("(max-width: 768px)"), [J, h] = r(null);
|
|
87
|
+
k(() => {
|
|
80
88
|
g && h(g);
|
|
81
89
|
}, [g]);
|
|
82
|
-
const
|
|
83
|
-
|
|
84
|
-
|
|
90
|
+
const Q = () => h(null), _ = te(null);
|
|
91
|
+
k(() => {
|
|
92
|
+
R?.(o);
|
|
85
93
|
}, [o]);
|
|
86
|
-
const
|
|
94
|
+
const V = (e) => {
|
|
87
95
|
e.key === "Enter" && !e.shiftKey && !d && !e.nativeEvent.isComposing && (e.preventDefault(), f());
|
|
88
96
|
}, f = async (e = o) => {
|
|
89
97
|
if (d && (!e || e.trim().length === 0)) return;
|
|
90
|
-
|
|
98
|
+
u([]), l(""), await i({
|
|
91
99
|
eventName: "user_message_submitted",
|
|
92
100
|
properties: {
|
|
93
|
-
conversationId:
|
|
101
|
+
conversationId: s
|
|
94
102
|
}
|
|
95
103
|
});
|
|
96
|
-
const c = C ||
|
|
104
|
+
const c = C || y ? JSON.stringify({
|
|
97
105
|
...C,
|
|
98
|
-
...
|
|
106
|
+
...y
|
|
99
107
|
}) : void 0, n = {};
|
|
100
108
|
c && (n["inkeep-filters"] = c);
|
|
101
|
-
let
|
|
102
|
-
|
|
109
|
+
let t = s;
|
|
110
|
+
t || (t = `conv_${D(16)}`, I(t)), N(t), H(
|
|
103
111
|
// { ...userMessage, files },
|
|
104
112
|
// { ...userMessage, },
|
|
105
113
|
{
|
|
@@ -108,30 +116,30 @@ It seems I might be having some issues right now. Please clear the chat and try
|
|
|
108
116
|
{
|
|
109
117
|
headers: n,
|
|
110
118
|
body: {
|
|
111
|
-
conversationId:
|
|
119
|
+
conversationId: t
|
|
112
120
|
}
|
|
113
121
|
}
|
|
114
122
|
);
|
|
115
|
-
},
|
|
116
|
-
|
|
117
|
-
m("aborted", { conversationId:
|
|
123
|
+
}, j = () => {
|
|
124
|
+
L().then(() => {
|
|
125
|
+
m("aborted", { conversationId: s });
|
|
118
126
|
});
|
|
119
127
|
}, x = () => {
|
|
120
|
-
|
|
128
|
+
Q(), S([]), I(""), W({}), u([]), b(null), i({
|
|
121
129
|
eventName: "chat_clear_button_clicked",
|
|
122
130
|
properties: {
|
|
123
|
-
conversationId:
|
|
131
|
+
conversationId: s
|
|
124
132
|
}
|
|
125
133
|
});
|
|
126
|
-
}, { openForm:
|
|
127
|
-
return
|
|
134
|
+
}, { openForm: X } = ae(), Y = ie();
|
|
135
|
+
return se(a.chatFunctionsRef, () => ({
|
|
128
136
|
submitMessage: f,
|
|
129
137
|
updateInputMessage(e) {
|
|
130
|
-
|
|
138
|
+
l(e);
|
|
131
139
|
},
|
|
132
140
|
clearChat: x,
|
|
133
141
|
openForm: (e) => {
|
|
134
|
-
|
|
142
|
+
Y?.setView("chat"), X(e, void 0);
|
|
135
143
|
},
|
|
136
144
|
focusInput: () => {
|
|
137
145
|
_.current?.focus();
|
|
@@ -139,30 +147,30 @@ It seems I might be having some issues right now. Please clear the chat and try
|
|
|
139
147
|
})), {
|
|
140
148
|
messages: p,
|
|
141
149
|
isLoading: M,
|
|
142
|
-
isStreaming:
|
|
143
|
-
error:
|
|
150
|
+
isStreaming: O,
|
|
151
|
+
error: J,
|
|
144
152
|
setError: h,
|
|
145
153
|
isSubmitDisabled: d,
|
|
146
154
|
input: o,
|
|
147
|
-
handleInputChange:
|
|
148
|
-
handleInputKeyDown:
|
|
155
|
+
handleInputChange: A,
|
|
156
|
+
handleInputKeyDown: V,
|
|
149
157
|
handleSubmit: f,
|
|
150
|
-
stop:
|
|
158
|
+
stop: j,
|
|
151
159
|
clear: x,
|
|
152
|
-
messageButtons:
|
|
160
|
+
messageButtons: U,
|
|
153
161
|
isEmpty: p.length === 0,
|
|
154
162
|
inputRef: _,
|
|
155
|
-
isMobile:
|
|
163
|
+
isMobile: G,
|
|
156
164
|
// Additional state for attachments and workflow
|
|
157
|
-
messageAttachments:
|
|
158
|
-
setMessageAttachments:
|
|
159
|
-
selectedWorkflow:
|
|
160
|
-
setSelectedWorkflow:
|
|
161
|
-
isNewChat:
|
|
162
|
-
conversationId:
|
|
165
|
+
messageAttachments: $,
|
|
166
|
+
setMessageAttachments: u,
|
|
167
|
+
selectedWorkflow: z,
|
|
168
|
+
setSelectedWorkflow: b,
|
|
169
|
+
isNewChat: q,
|
|
170
|
+
conversationId: s
|
|
163
171
|
};
|
|
164
172
|
};
|
|
165
173
|
export {
|
|
166
|
-
|
|
174
|
+
le as DEFAULT_ERROR_MESSAGE,
|
|
167
175
|
be as useInkeepChat
|
|
168
176
|
};
|
|
@@ -1 +1 @@
|
|
|
1
|
-
"use client";"use strict";Object.defineProperty(exports,Symbol.toStringTag,{value:"Module"});const E=require("react/jsx-runtime"),t=require("react"),l=require("./config-provider.cjs"),a=t.createContext(void 0),p=({children:e})=>{const{baseSettings:s,componentType:n}=l.useInkeepConfig(),{tags:o,analyticsProperties:r}=s,i=t.useMemo(()=>({widgetLibraryVersion:"0.15.
|
|
1
|
+
"use client";"use strict";Object.defineProperty(exports,Symbol.toStringTag,{value:"Module"});const E=require("react/jsx-runtime"),t=require("react"),l=require("./config-provider.cjs"),a=t.createContext(void 0),p=({children:e})=>{const{baseSettings:s,componentType:n}=l.useInkeepConfig(),{tags:o,analyticsProperties:r}=s,i=t.useMemo(()=>({widgetLibraryVersion:"0.15.1",componentType:n,tags:o}),[n,o]),u={logEvent:t.useCallback(async c=>{const v={...i,...c.properties,...r},d={eventName:c.eventName,properties:v};return s.onEvent?.(d)},[s,i,r])};return E.jsx(a.Provider,{value:u,children:e})},g=()=>{const e=t.useContext(a);if(!e)throw new Error("useBaseEvents must be used within a BaseEventsProvider");return e};exports.BaseEventsProvider=p;exports.useBaseEvents=g;
|
|
@@ -5,7 +5,7 @@ import { useInkeepConfig as g } from "./config-provider.js";
|
|
|
5
5
|
const a = d(void 0), P = ({ children: e }) => {
|
|
6
6
|
const { baseSettings: t, componentType: o } = g(), { tags: s, analyticsProperties: n } = t, r = u(
|
|
7
7
|
() => ({
|
|
8
|
-
widgetLibraryVersion: "0.15.
|
|
8
|
+
widgetLibraryVersion: "0.15.1",
|
|
9
9
|
componentType: o,
|
|
10
10
|
tags: s
|
|
11
11
|
}),
|
|
@@ -1 +1 @@
|
|
|
1
|
-
"use client";"use strict";Object.defineProperty(exports,Symbol.toStringTag,{value:"Module"});const e=require("react/jsx-runtime"),n=require("react"),a=require("lucide-react"),r=require("../../primitives/components/data-summaries.cjs"),
|
|
1
|
+
"use client";"use strict";Object.defineProperty(exports,Symbol.toStringTag,{value:"Module"});const e=require("react/jsx-runtime"),n=require("react"),a=require("lucide-react"),r=require("../../primitives/components/data-summaries.cjs"),d=t=>{const{type:l,label:s}=t;return s||l.replace(/_/g," ").replace(/\b\w/g,i=>i.toUpperCase())},m={agent_generate:e.jsx(a.RefreshCw,{className:"w-3 h-3 text-gray-500 dark:text-white-alpha-500"}),agent_reasoning:e.jsx(a.Brain,{className:"w-3 h-3 text-gray-500 dark:text-white-alpha-500"}),tool_call:e.jsx(a.Hammer,{className:"w-3 h-3 text-gray-500 dark:text-white-alpha-500"}),tool_result:e.jsx(a.Hammer,{className:"w-3 h-3 text-gray-500 dark:text-white-alpha-500"}),transfer:e.jsx(a.ArrowRight,{className:"w-3 h-3 text-gray-500 dark:text-white-alpha-500"}),delegation_sent:e.jsx(a.Forward,{className:"w-3 h-3 text-gray-500 dark:text-white-alpha-500"}),delegation_returned:e.jsx(a.CheckCheck,{className:"w-3 h-3 text-gray-500 dark:text-white-alpha-500"}),artifact_saved:e.jsx(a.Download,{className:"w-3 h-3 text-gray-500 dark:text-white-alpha-500"}),error:e.jsx(a.TriangleAlert,{className:"w-3 h-3 text-gray-500 dark:text-white-alpha-500"}),agent_initializing:e.jsx(a.CircleDot,{className:"w-3 h-3 animate-spin"}),completion:e.jsx(a.CheckCheck,{className:"w-3 h-3 text-gray-500 dark:text-white-alpha-500"}),default:e.jsx(a.Dot,{className:"w-3 h-3 text-gray-500 dark:text-white-alpha-500"})},h={retrieve:e.jsx(a.Search,{className:"w-3 h-3 text-gray-500 dark:text-white-alpha-500"}),action:e.jsx(a.CheckCheck,{className:"w-3 h-3 text-gray-500 dark:text-white-alpha-500"}),...m},p=n.memo(({summary:t,showConnector:l})=>{const s=n.useMemo(()=>t.details&&Object.keys(t.details).length>0?JSON.stringify(t.details,null,2):null,[t.details]),i=n.useMemo(()=>d(t),[t]),c=n.useMemo(()=>h[t.type]||h.default,[t.type]);return e.jsxs(r.DataSummaryItem,{className:"flex items-start gap-2 text-xs relative",children:[l&&e.jsx(r.DataSummaryConnector,{className:"absolute left-1.5 top-4 bottom-0 w-px bg-gray-200 dark:bg-white-alpha-200 -mb-3"}),e.jsx(r.DataSummaryIconContainer,{className:"flex items-center justify-center w-3 h-3 relative z-10 mt-0.5",children:c}),e.jsxs(r.DataSummaryContent,{className:"flex-1",children:[e.jsx(r.DataSummaryLabel,{className:"text-gray-700 dark:text-white-alpha-600",children:i}),s&&e.jsx(r.DataSummaryDetails,{className:"mt-2 text-xs whitespace-pre-wrap font-mono bg-gray-50 dark:bg-gray-dark-900 p-2 rounded-md px-3 py-2",children:s})]})]})}),g=n.memo(({summaries:t,isCompleted:l})=>{const[s,i]=n.useState(!l);n.useEffect(()=>{let o;return l?o=setTimeout(()=>{i(!1)},1e3):i(!0),()=>{o&&clearTimeout(o)}},[l]);const c=n.useCallback(()=>{i(!s)},[s]);return e.jsxs(r.DataSummaryGroup,{className:"flex flex-col items-start mb-2.5 mt-2.5 first:mt-1 relative",children:[e.jsx(r.DataSummaryToggle,{type:"button",onClick:c,"data-expanded":s,className:"inline-flex items-center group gap-2 text-xs text-gray-500 dark:text-white-alpha-600 hover:text-gray-700 dark:hover:text-white-alpha-700 transition-colors cursor-pointer",children:l?e.jsxs(e.Fragment,{children:[e.jsx(a.Check,{className:"check-icon w-3 h-3 text-gray-500 dark:text-white-alpha-500 transition-all duration-200 absolute opacity-100 group-hover:opacity-0 group-data-[expanded=true]:opacity-0"}),e.jsx(a.ChevronRight,{className:"chevron-icon w-3 h-3 text-gray-500 dark:text-white-alpha-500 transition-all duration-200 transform opacity-0 rotate-0 group-hover:opacity-100 group-data-[expanded=true]:opacity-100 group-data-[expanded=true]:rotate-90"}),e.jsx(r.DataSummaryToggleText,{className:"font-medium",children:"Completed"})]}):e.jsxs(e.Fragment,{children:[e.jsx(a.LoaderCircle,{className:"w-3 h-3 animate-spin"}),e.jsx(r.DataSummaryToggleText,{className:"font-medium",children:"Thinking..."})]})}),e.jsx(r.DataSummaryCollapsible,{"data-expanded":s,className:"overflow-hidden transition-all duration-300 ease-in-out data-[expanded=true]:opacity-100 data-[expanded=false]:max-h-0 data-[expanded=false]:opacity-0 max-w-full",children:e.jsx(r.DataSummaryList,{className:"pb-2 mt-1.5 space-y-3 relative",children:t.map((o,x)=>e.jsx(p,{summary:o,showConnector:t.length>1&&x<t.length-1},`op-${o.type}-${x}`))})})]})});exports.DataSummaryGroup=g;
|
|
@@ -1,8 +1,8 @@
|
|
|
1
1
|
"use client";
|
|
2
2
|
import { jsxs as s, jsx as a, Fragment as h } from "react/jsx-runtime";
|
|
3
|
-
import { memo as g, useState as u, useEffect as y, useCallback as w, useMemo as
|
|
4
|
-
import { Check as f, ChevronRight as N, LoaderCircle as
|
|
5
|
-
import { DataSummaryGroup as A, DataSummaryToggle as L, DataSummaryToggleText as p, DataSummaryCollapsible as
|
|
3
|
+
import { memo as g, useState as u, useEffect as y, useCallback as w, useMemo as o } from "react";
|
|
4
|
+
import { Check as f, ChevronRight as N, LoaderCircle as k, CheckCheck as m, Search as D, Dot as S, CircleDot as v, TriangleAlert as b, Download as C, Forward as P, ArrowRight as _, Hammer as d, Brain as T, RefreshCw as I } from "lucide-react";
|
|
5
|
+
import { DataSummaryGroup as A, DataSummaryToggle as L, DataSummaryToggleText as p, DataSummaryCollapsible as O, DataSummaryList as E, DataSummaryItem as M, DataSummaryConnector as R, DataSummaryIconContainer as j, DataSummaryContent as G, DataSummaryLabel as z, DataSummaryDetails as F } from "../../primitives/components/data-summaries.js";
|
|
6
6
|
const U = (t) => {
|
|
7
7
|
const { type: r, label: e } = t;
|
|
8
8
|
return e || r.replace(/_/g, " ").replace(/\b\w/g, (i) => i.toUpperCase());
|
|
@@ -18,19 +18,19 @@ const U = (t) => {
|
|
|
18
18
|
error: /* @__PURE__ */ a(b, { className: "w-3 h-3 text-gray-500 dark:text-white-alpha-500" }),
|
|
19
19
|
agent_initializing: /* @__PURE__ */ a(v, { className: "w-3 h-3 animate-spin" }),
|
|
20
20
|
completion: /* @__PURE__ */ a(m, { className: "w-3 h-3 text-gray-500 dark:text-white-alpha-500" }),
|
|
21
|
-
default: /* @__PURE__ */ a(
|
|
21
|
+
default: /* @__PURE__ */ a(S, { className: "w-3 h-3 text-gray-500 dark:text-white-alpha-500" })
|
|
22
22
|
}, x = {
|
|
23
|
-
retrieve: /* @__PURE__ */ a(
|
|
23
|
+
retrieve: /* @__PURE__ */ a(D, { className: "w-3 h-3 text-gray-500 dark:text-white-alpha-500" }),
|
|
24
24
|
action: /* @__PURE__ */ a(m, { className: "w-3 h-3 text-gray-500 dark:text-white-alpha-500" }),
|
|
25
25
|
...$
|
|
26
26
|
}, B = g(({ summary: t, showConnector: r }) => {
|
|
27
|
-
const e =
|
|
27
|
+
const e = o(() => t.details && Object.keys(t.details).length > 0 ? JSON.stringify(t.details, null, 2) : null, [t.details]), i = o(() => U(t), [t]), n = o(
|
|
28
28
|
() => x[t.type] || x.default,
|
|
29
29
|
[t.type]
|
|
30
30
|
);
|
|
31
|
-
return /* @__PURE__ */ s(
|
|
31
|
+
return /* @__PURE__ */ s(M, { className: "flex items-start gap-2 text-xs relative", children: [
|
|
32
32
|
r && /* @__PURE__ */ a(R, { className: "absolute left-1.5 top-4 bottom-0 w-px bg-gray-200 dark:bg-white-alpha-200 -mb-3" }),
|
|
33
|
-
/* @__PURE__ */ a(j, { className: "flex items-center justify-center w-3 h-3 relative z-10 mt-0.5", children:
|
|
33
|
+
/* @__PURE__ */ a(j, { className: "flex items-center justify-center w-3 h-3 relative z-10 mt-0.5", children: n }),
|
|
34
34
|
/* @__PURE__ */ s(G, { className: "flex-1", children: [
|
|
35
35
|
/* @__PURE__ */ a(z, { className: "text-gray-700 dark:text-white-alpha-600", children: i }),
|
|
36
36
|
e && /* @__PURE__ */ a(F, { className: "mt-2 text-xs whitespace-pre-wrap font-mono bg-gray-50 dark:bg-gray-dark-900 p-2 rounded-md px-3 py-2", children: e })
|
|
@@ -46,7 +46,7 @@ const U = (t) => {
|
|
|
46
46
|
l && clearTimeout(l);
|
|
47
47
|
};
|
|
48
48
|
}, [r]);
|
|
49
|
-
const
|
|
49
|
+
const n = w(() => {
|
|
50
50
|
i(!e);
|
|
51
51
|
}, [e]);
|
|
52
52
|
return /* @__PURE__ */ s(A, { className: "flex flex-col items-start mb-2.5 mt-2.5 first:mt-1 relative", children: [
|
|
@@ -54,7 +54,7 @@ const U = (t) => {
|
|
|
54
54
|
L,
|
|
55
55
|
{
|
|
56
56
|
type: "button",
|
|
57
|
-
onClick:
|
|
57
|
+
onClick: n,
|
|
58
58
|
"data-expanded": e,
|
|
59
59
|
className: "inline-flex items-center group gap-2 text-xs text-gray-500 dark:text-white-alpha-600 hover:text-gray-700 dark:hover:text-white-alpha-700 transition-colors cursor-pointer",
|
|
60
60
|
children: r ? /* @__PURE__ */ s(h, { children: [
|
|
@@ -62,17 +62,17 @@ const U = (t) => {
|
|
|
62
62
|
/* @__PURE__ */ a(N, { className: "chevron-icon w-3 h-3 text-gray-500 dark:text-white-alpha-500 transition-all duration-200 transform opacity-0 rotate-0 group-hover:opacity-100 group-data-[expanded=true]:opacity-100 group-data-[expanded=true]:rotate-90" }),
|
|
63
63
|
/* @__PURE__ */ a(p, { className: "font-medium", children: "Completed" })
|
|
64
64
|
] }) : /* @__PURE__ */ s(h, { children: [
|
|
65
|
-
/* @__PURE__ */ a(
|
|
65
|
+
/* @__PURE__ */ a(k, { className: "w-3 h-3 animate-spin" }),
|
|
66
66
|
/* @__PURE__ */ a(p, { className: "font-medium", children: "Thinking..." })
|
|
67
67
|
] })
|
|
68
68
|
}
|
|
69
69
|
),
|
|
70
70
|
/* @__PURE__ */ a(
|
|
71
|
-
|
|
71
|
+
O,
|
|
72
72
|
{
|
|
73
73
|
"data-expanded": e,
|
|
74
74
|
className: "overflow-hidden transition-all duration-300 ease-in-out data-[expanded=true]:opacity-100 data-[expanded=false]:max-h-0 data-[expanded=false]:opacity-0 max-w-full",
|
|
75
|
-
children: /* @__PURE__ */ a(
|
|
75
|
+
children: /* @__PURE__ */ a(E, { className: "pb-2 mt-1.5 space-y-3 relative", children: t.map((l, c) => /* @__PURE__ */ a(
|
|
76
76
|
B,
|
|
77
77
|
{
|
|
78
78
|
summary: l,
|
|
@@ -1 +1 @@
|
|
|
1
|
-
"use client";"use strict";Object.defineProperty(exports,Symbol.toStringTag,{value:"Module"});const e=require("react/jsx-runtime"),
|
|
1
|
+
"use client";"use strict";Object.defineProperty(exports,Symbol.toStringTag,{value:"Module"});const e=require("react/jsx-runtime"),G=require("../../primitives/providers/base-events-provider.cjs"),K=require("../../primitives/providers/config-provider.cjs"),O=require("../../primitives/providers/message-provider.cjs"),r=require("../../primitives/components/embedded-chat.cjs"),B=require("../../primitives/components/embedded-chat/chat-provider.cjs"),F=require("merge-anything"),J=require("../utils.cjs"),U=require("./ui/markdown-styles.cjs"),z=require("../../primitives/components/embedded-chat/use-stream-processor.cjs"),H=require("./data-summary-group.cjs"),c=require("react"),Q=require("./embedded-chat.cjs"),k=require("lucide-react"),V=()=>e.jsx("div",{className:"flex space-x-1",children:[0,1,2].map(s=>e.jsx("span",{className:"animate-bounce-dot opacity-30",style:{animationDelay:`${s*.2}s`},children:"."},s))}),w=({name:s,Icon:n,props:y,componentType:p})=>e.jsxs("div",{className:"border rounded-lg bg-gray-50 dark:bg-gray-dark-800 mb-3",children:[e.jsxs("div",{className:"flex justify-between px-4 py-2 text-xs",children:[e.jsxs("div",{className:"font-medium flex items-center gap-2",children:[e.jsx(n,{className:"w-3 h-3 text-gray-600 dark:text-white-alpha-600"}),e.jsx("span",{children:s})]}),e.jsx("div",{className:"flex items-center px-1.5 py-0.5 rounded-md text-2xs uppercase tracking-wider bg-gray-200 dark:bg-white-alpha-200 font-medium text-gray-700 dark:text-white-alpha-700 font-mono",children:p})]}),e.jsx("pre",{className:"whitespace-pre-wrap text-xs text-gray-700 dark:text-white-alpha-700 font-mono px-4 py-2",children:JSON.stringify(y,null,2)})]}),W=({name:s,props:n})=>e.jsx(w,{name:s,Icon:k.ComponentIcon,props:n,componentType:"component"}),X=({name:s,props:n})=>e.jsx(w,{name:s,Icon:k.Library,props:n,componentType:"artifact"}),Y=({className:s,componentStyles:n,children:y,isLast:p,...S})=>{const{message:o}=O.useMessage(),{logEvent:u}=G.useBaseEvents(),{conversationId:C,isStreaming:D,isLoading:M,setError:q}=B.useChat(),{aiChatSettings:{components:N,artifacts:E}}=K.useInkeepConfig(),L=o.role==="user",$=(D||M)&&p&&o.role==="assistant",{processedParts:_,summaryTimings:I,shouldShowInitialLoading:T,shouldShowStreamDelayLoading:R}=z.useStreamProcessor(o.parts,$,q),f=c.useMemo(()=>o.parts.filter(t=>t.type==="data-artifact"&&t.data?.type?.toLowerCase()==="citation"),[o.parts]),b=c.useMemo(()=>F.merge(U.markdownStyles,n??{}),[n]),j=c.useCallback((t,a)=>{u({eventName:"assistant_message_inline_link_opened",properties:{title:a?.toString(),url:t}})},[u]),v=c.useCallback((t,a)=>{u({eventName:"assistant_code_block_copied",properties:{conversationId:C,language:t,code:a}})},[u,C]),P=c.useCallback(t=>e.jsx(r.EmbeddedChatPrimitiveMarkdown,{text:t,componentStyles:b,onLinkClick:j,onCodeCopy:v,artifacts:f}),[b,j,v,f]),A=c.useMemo(()=>J.cn("data-[role=user]:whitespace-pre-wrap mb-3 data-[role=user]:mb-0 [&[data-role=user]>p]:mb-0 max-w-full",s),[s]);return e.jsxs(e.Fragment,{children:[_.map((t,a)=>{const m={"data-role":o.role,"data-type":t?.type==="data-component"?t.data.type:t?.type,...S,className:A};switch(t?.type){case"text":return e.jsx(r.PrimitiveMessagePart,{...m,children:L?t.text:P(t.text||"")},a);case"data-component":{const{type:d}=t.data;switch(d){case"text":return e.jsx("div",{...m,children:P(t.data.text||"")},a);default:{const g=t.data,{name:i,props:x}=g,l=N?.[i],h=l?r.EmbeddedChatPrimitiveDynamicComponent:W;return e.jsx(r.PrimitiveMessagePart,{...m,children:e.jsx(h,{name:i,props:x,componentDef:l})},`${i}-${a}`)}}}case"data-artifact":{const d=t.data,{name:g,type:i,artifactSummary:x}=d,l=E?.[i],h=l?r.EmbeddedChatPrimitiveDynamicComponent:X;return e.jsx(r.PrimitiveMessagePart,{...m,children:e.jsx(h,{name:i,props:x,componentDef:l})},`${g}-${a}`)}case"summary-group":{const d=I.get(t.groupKey)||{isCompleted:!1};return e.jsx(r.PrimitiveMessagePart,{...m,children:e.jsx(H.DataSummaryGroup,{summaries:t.summaries||[],isCompleted:d.isCompleted})},`${t.groupKey}-${a}`)}default:return null}}),T&&e.jsx(Q.MessageLoading,{}),R&&e.jsx(V,{})]})};exports.EmbeddedChatMessagePart=Y;
|
|
@@ -1,19 +1,19 @@
|
|
|
1
1
|
"use client";
|
|
2
|
-
import { jsx as t, jsxs as l, Fragment as
|
|
3
|
-
import { useBaseEvents as
|
|
4
|
-
import { useInkeepConfig as
|
|
2
|
+
import { jsx as t, jsxs as l, Fragment as J } from "react/jsx-runtime";
|
|
3
|
+
import { useBaseEvents as O } from "../../primitives/providers/base-events-provider.js";
|
|
4
|
+
import { useInkeepConfig as U } from "../../primitives/providers/config-provider.js";
|
|
5
5
|
import { useMessage as q } from "../../primitives/providers/message-provider.js";
|
|
6
6
|
import { EmbeddedChatPrimitiveMarkdown as z, PrimitiveMessagePart as d, EmbeddedChatPrimitiveDynamicComponent as S } from "../../primitives/components/embedded-chat.js";
|
|
7
7
|
import { useChat as H } from "../../primitives/components/embedded-chat/chat-provider.js";
|
|
8
8
|
import { merge as Q } from "merge-anything";
|
|
9
9
|
import { cn as R } from "../utils.js";
|
|
10
|
-
import { markdownStyles as
|
|
11
|
-
import { useStreamProcessor as
|
|
12
|
-
import { DataSummaryGroup as
|
|
10
|
+
import { markdownStyles as V } from "./ui/markdown-styles.js";
|
|
11
|
+
import { useStreamProcessor as W } from "../../primitives/components/embedded-chat/use-stream-processor.js";
|
|
12
|
+
import { DataSummaryGroup as X } from "./data-summary-group.js";
|
|
13
13
|
import { useMemo as h, useCallback as y } from "react";
|
|
14
|
-
import { MessageLoading as
|
|
15
|
-
import { Library as
|
|
16
|
-
const
|
|
14
|
+
import { MessageLoading as Y } from "./embedded-chat.js";
|
|
15
|
+
import { Library as Z, ComponentIcon as ee } from "lucide-react";
|
|
16
|
+
const te = () => /* @__PURE__ */ t("div", { className: "flex space-x-1", children: [0, 1, 2].map((a) => /* @__PURE__ */ t(
|
|
17
17
|
"span",
|
|
18
18
|
{
|
|
19
19
|
className: "animate-bounce-dot opacity-30",
|
|
@@ -32,22 +32,22 @@ const ee = () => /* @__PURE__ */ t("div", { className: "flex space-x-1", childre
|
|
|
32
32
|
/* @__PURE__ */ t("div", { className: "flex items-center px-1.5 py-0.5 rounded-md text-2xs uppercase tracking-wider bg-gray-200 dark:bg-white-alpha-200 font-medium text-gray-700 dark:text-white-alpha-700 font-mono", children: u })
|
|
33
33
|
] }),
|
|
34
34
|
/* @__PURE__ */ t("pre", { className: "whitespace-pre-wrap text-xs text-gray-700 dark:text-white-alpha-700 font-mono px-4 py-2", children: JSON.stringify(C, null, 2) })
|
|
35
|
-
] }),
|
|
35
|
+
] }), ae = ({ name: a, props: n }) => /* @__PURE__ */ t(N, { name: a, Icon: ee, props: n, componentType: "component" }), oe = ({ name: a, props: n }) => /* @__PURE__ */ t(N, { name: a, Icon: Z, props: n, componentType: "artifact" }), Ce = ({
|
|
36
36
|
className: a,
|
|
37
37
|
componentStyles: n,
|
|
38
38
|
children: C,
|
|
39
39
|
isLast: u,
|
|
40
40
|
...L
|
|
41
41
|
}) => {
|
|
42
|
-
const { message: s } = q(), { logEvent: p } =
|
|
42
|
+
const { message: s } = q(), { logEvent: p } = O(), { conversationId: x, isStreaming: M, isLoading: P, setError: E } = H(), {
|
|
43
43
|
aiChatSettings: { components: _, artifacts: $ }
|
|
44
|
-
} =
|
|
44
|
+
} = U(), I = s.role === "user", T = (M || P) && u && s.role === "assistant", { processedParts: j, summaryTimings: K, shouldShowInitialLoading: A, shouldShowStreamDelayLoading: B } = W(s.parts, T, E), w = h(
|
|
45
45
|
() => s.parts.filter(
|
|
46
46
|
(e) => e.type === "data-artifact" && e.data?.type?.toLowerCase() === "citation"
|
|
47
47
|
),
|
|
48
48
|
[s.parts]
|
|
49
49
|
), b = h(
|
|
50
|
-
() => Q(
|
|
50
|
+
() => Q(V, n ?? {}),
|
|
51
51
|
[n]
|
|
52
52
|
), k = y(
|
|
53
53
|
(e, o) => {
|
|
@@ -84,48 +84,48 @@ const ee = () => /* @__PURE__ */ t("div", { className: "flex space-x-1", childre
|
|
|
84
84
|
}
|
|
85
85
|
),
|
|
86
86
|
[b, k, D, w]
|
|
87
|
-
),
|
|
87
|
+
), F = h(
|
|
88
88
|
() => R(
|
|
89
89
|
"data-[role=user]:whitespace-pre-wrap mb-3 data-[role=user]:mb-0 [&[data-role=user]>p]:mb-0 max-w-full",
|
|
90
90
|
a
|
|
91
91
|
),
|
|
92
92
|
[a]
|
|
93
93
|
);
|
|
94
|
-
return /* @__PURE__ */ l(
|
|
95
|
-
|
|
96
|
-
const
|
|
94
|
+
return /* @__PURE__ */ l(J, { children: [
|
|
95
|
+
j.map((e, o) => {
|
|
96
|
+
const i = {
|
|
97
97
|
"data-role": s.role,
|
|
98
98
|
"data-type": e?.type === "data-component" ? e.data.type : e?.type,
|
|
99
99
|
...L,
|
|
100
|
-
className:
|
|
100
|
+
className: F
|
|
101
101
|
};
|
|
102
102
|
switch (e?.type) {
|
|
103
103
|
case "text":
|
|
104
|
-
return /* @__PURE__ */ t(d, { ...
|
|
104
|
+
return /* @__PURE__ */ t(d, { ...i, children: I ? e.text : v(e.text || "") }, o);
|
|
105
105
|
case "data-component": {
|
|
106
|
-
const { type:
|
|
107
|
-
switch (
|
|
106
|
+
const { type: m } = e.data;
|
|
107
|
+
switch (m) {
|
|
108
108
|
case "text":
|
|
109
|
-
return /* @__PURE__ */ t("div", { ...
|
|
109
|
+
return /* @__PURE__ */ t("div", { ...i, children: v(e.data.text || "") }, o);
|
|
110
110
|
default: {
|
|
111
|
-
const
|
|
112
|
-
return /* @__PURE__ */ t(d, { ...
|
|
111
|
+
const g = e.data, { name: r, props: f } = g, c = _?.[r];
|
|
112
|
+
return /* @__PURE__ */ t(d, { ...i, children: /* @__PURE__ */ t(c ? S : ae, { name: r, props: f, componentDef: c }) }, `${r}-${o}`);
|
|
113
113
|
}
|
|
114
114
|
}
|
|
115
115
|
}
|
|
116
116
|
case "data-artifact": {
|
|
117
|
-
const
|
|
118
|
-
return /* @__PURE__ */ t(d, { ...
|
|
117
|
+
const m = e.data, { name: g, type: r, artifactSummary: f } = m, c = $?.[r];
|
|
118
|
+
return /* @__PURE__ */ t(d, { ...i, children: /* @__PURE__ */ t(c ? S : oe, { name: r, props: f, componentDef: c }) }, `${g}-${o}`);
|
|
119
119
|
}
|
|
120
120
|
case "summary-group": {
|
|
121
|
-
const
|
|
121
|
+
const m = K.get(e.groupKey) || {
|
|
122
122
|
isCompleted: !1
|
|
123
123
|
};
|
|
124
|
-
return /* @__PURE__ */ t(d, { ...
|
|
125
|
-
|
|
124
|
+
return /* @__PURE__ */ t(d, { ...i, children: /* @__PURE__ */ t(
|
|
125
|
+
X,
|
|
126
126
|
{
|
|
127
127
|
summaries: e.summaries || [],
|
|
128
|
-
isCompleted:
|
|
128
|
+
isCompleted: m.isCompleted
|
|
129
129
|
}
|
|
130
130
|
) }, `${e.groupKey}-${o}`);
|
|
131
131
|
}
|
|
@@ -133,10 +133,10 @@ const ee = () => /* @__PURE__ */ t("div", { className: "flex space-x-1", childre
|
|
|
133
133
|
return null;
|
|
134
134
|
}
|
|
135
135
|
}),
|
|
136
|
-
|
|
137
|
-
|
|
136
|
+
A && /* @__PURE__ */ t(Y, {}),
|
|
137
|
+
B && /* @__PURE__ */ t(te, {})
|
|
138
138
|
] });
|
|
139
139
|
};
|
|
140
140
|
export {
|
|
141
|
-
|
|
141
|
+
Ce as EmbeddedChatMessagePart
|
|
142
142
|
};
|