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