@inkeep/agents-ui 0.14.11 → 0.14.13
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/index.d.cts +14 -1
- package/dist/index.d.ts +14 -1
- package/dist/primitives/components/embedded-chat/use-inkeep-chat.cjs +2 -2
- package/dist/primitives/components/embedded-chat/use-inkeep-chat.js +59 -54
- package/dist/primitives/components/embedded-chat/use-stream-processor.cjs +1 -1
- package/dist/primitives/components/embedded-chat/use-stream-processor.js +80 -100
- package/dist/primitives/components/embedded-search/use-search-filter.cjs +1 -1
- package/dist/primitives/components/embedded-search/use-search-filter.js +1 -1
- package/dist/primitives/hooks/use-streaming-events.cjs +1 -1
- package/dist/primitives/hooks/use-streaming-events.js +19 -126
- package/dist/primitives/providers/base-events-provider.cjs +1 -1
- package/dist/primitives/providers/base-events-provider.js +1 -1
- package/dist/react/embedded-chat.cjs +1 -1
- package/dist/react/embedded-chat.js +123 -120
- package/dist/styled/components/data-summary-group.cjs +1 -1
- package/dist/styled/components/data-summary-group.js +44 -34
- package/dist/styled/components/embedded-search.cjs +1 -1
- package/dist/styled/components/embedded-search.js +1 -1
- package/dist/styled/components/message.cjs +1 -1
- package/dist/styled/components/message.js +39 -39
- package/dist/styled/inkeep.css.cjs +2 -9
- package/dist/styled/inkeep.css.js +2 -9
- package/dist/types/types.d.cts +6 -4
- package/dist/types/types.d.ts +6 -4
- package/package.json +1 -1
package/dist/index.d.cts
CHANGED
|
@@ -1225,8 +1225,20 @@ export declare const dataAttr: (guard: boolean | undefined) => Booleanish;
|
|
|
1225
1225
|
|
|
1226
1226
|
declare type DataParts = {
|
|
1227
1227
|
operation: {
|
|
1228
|
-
type:
|
|
1228
|
+
type:
|
|
1229
|
+
| 'error'
|
|
1230
|
+
| 'agent_initializing'
|
|
1231
|
+
| 'completion'
|
|
1232
|
+
| 'agent_generate'
|
|
1233
|
+
| 'agent_reasoning'
|
|
1234
|
+
| 'tool_execution'
|
|
1235
|
+
| 'transfer'
|
|
1236
|
+
| 'delegation_sent'
|
|
1237
|
+
| 'delegation_returned'
|
|
1238
|
+
| 'artifact_saved'
|
|
1229
1239
|
ctx: Record<string, unknown>
|
|
1240
|
+
message?: string
|
|
1241
|
+
label?: string
|
|
1230
1242
|
}
|
|
1231
1243
|
summary: {
|
|
1232
1244
|
type: string
|
|
@@ -4908,6 +4920,7 @@ declare const useInkeepChat: () => {
|
|
|
4908
4920
|
isLoading: boolean;
|
|
4909
4921
|
isStreaming: boolean;
|
|
4910
4922
|
error: Error | null;
|
|
4923
|
+
setError: Dispatch<SetStateAction<Error | null>>;
|
|
4911
4924
|
isSubmitDisabled: boolean;
|
|
4912
4925
|
input: string;
|
|
4913
4926
|
handleInputChange: (e: React.ChangeEvent<HTMLTextAreaElement>) => void;
|
package/dist/index.d.ts
CHANGED
|
@@ -1225,8 +1225,20 @@ export declare const dataAttr: (guard: boolean | undefined) => Booleanish;
|
|
|
1225
1225
|
|
|
1226
1226
|
declare type DataParts = {
|
|
1227
1227
|
operation: {
|
|
1228
|
-
type:
|
|
1228
|
+
type:
|
|
1229
|
+
| 'error'
|
|
1230
|
+
| 'agent_initializing'
|
|
1231
|
+
| 'completion'
|
|
1232
|
+
| 'agent_generate'
|
|
1233
|
+
| 'agent_reasoning'
|
|
1234
|
+
| 'tool_execution'
|
|
1235
|
+
| 'transfer'
|
|
1236
|
+
| 'delegation_sent'
|
|
1237
|
+
| 'delegation_returned'
|
|
1238
|
+
| 'artifact_saved'
|
|
1229
1239
|
ctx: Record<string, unknown>
|
|
1240
|
+
message?: string
|
|
1241
|
+
label?: string
|
|
1230
1242
|
}
|
|
1231
1243
|
summary: {
|
|
1232
1244
|
type: string
|
|
@@ -4908,6 +4920,7 @@ declare const useInkeepChat: () => {
|
|
|
4908
4920
|
isLoading: boolean;
|
|
4909
4921
|
isStreaming: boolean;
|
|
4910
4922
|
error: Error | null;
|
|
4923
|
+
setError: Dispatch<SetStateAction<Error | null>>;
|
|
4911
4924
|
isSubmitDisabled: boolean;
|
|
4912
4925
|
input: string;
|
|
4913
4926
|
handleInputChange: (e: React.ChangeEvent<HTMLTextAreaElement>) => void;
|
|
@@ -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 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"),q=`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.`,ie=()=>{const{baseSettings:f,aiChatSettings:o}=Z.useInkeepConfig(),[n="",v]=ae.useControllableState({prop:o.conversationId,defaultProp:o.conversationId??""}),{logEvent:i}=se.useBaseEvents(),{setConversationId:F,emitToParent:R}=oe.useStreamingEvents(),[a,u]=t.useState(""),P=e=>u(e.target.value),{filters:E}=f,{onInputMessageChange:k,filters:S,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 ${f.organizationDisplayName??"Administrator"}`;default:return q}},[T,U]=t.useState({}),[B,l]=t.useState([]),[O,I]=t.useState(null),{messages:g,sendMessage:K,status:b,setMessages:y,stop:L,error:d}=X.useChat({transport:new Y.DefaultChatTransport({api:A,headers:{...C?{Authorization:`Bearer ${C}`}:{},...x},body:{requestContext:D}}),onData(e){R(e.type,e.data)},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),y(c=>{const r=[...c],s=r[r.length-1];return s&&(s.parts=[{type:"text",text:N(e)}]),r})}}),w=b==="submitted",W=b==="streaming",$=g.length===0,m=!a.trim()||w,z=ee.useMediaQuery("(max-width: 768px)"),[G,p]=t.useState(null);t.useEffect(()=>{d&&p(d)},[d]);const H=()=>p(null),M=t.useRef(null);t.useEffect(()=>{k?.(a)},[a]);const Q=e=>{e.key==="Enter"&&!e.shiftKey&&!m&&!e.nativeEvent.isComposing&&(e.preventDefault(),h())},h=async(e=a)=>{if(m&&(!e||e.trim().length===0))return;l([]),u(""),await i({eventName:"user_message_submitted",properties:{conversationId:n}});const c=E||S?JSON.stringify({...E,...S}):void 0,r={};c&&(r["inkeep-filters"]=c);let s=n;s||(s=`conv_${te.generateUid(16)}`,v(s)),F(s),K({text:e},{headers:r,body:{conversationId:s}})},j=()=>{L()},_=()=>{H(),y([]),v(""),U({}),l([]),I(null),i({eventName:"chat_clear_button_clicked",properties:{conversationId:n}})},{openForm:J}=ne.useChatForm(),V=re.useWidget();return t.useImperativeHandle(o.chatFunctionsRef,()=>({submitMessage:h,updateInputMessage(e){u(e)},clearChat:_,openForm:e=>{V?.setView("chat"),J(e,void 0)},focusInput:()=>{M.current?.focus()}})),{messages:g,isLoading:w,isStreaming:W,error:G,setError:p,isSubmitDisabled:m,input:a,handleInputChange:P,handleInputKeyDown:Q,handleSubmit:h,stop:j,clear:_,messageButtons:T,isEmpty:g.length===0,inputRef:M,isMobile:z,messageAttachments:B,setMessageAttachments:l,selectedWorkflow:O,setSelectedWorkflow:I,isNewChat:$,conversationId:n}};exports.DEFAULT_ERROR_MESSAGE=q;exports.useInkeepChat=ie;
|
|
@@ -10,49 +10,52 @@ import { useChatForm as re } from "../../providers/chat-form-provider.js";
|
|
|
10
10
|
import { useWidget as ae } from "../../providers/widget-provider.js";
|
|
11
11
|
import { useControllableState as ie } from "@radix-ui/react-use-controllable-state";
|
|
12
12
|
import { useStreamingEvents as ce } from "../../hooks/use-streaming-events.js";
|
|
13
|
-
const
|
|
14
|
-
|
|
13
|
+
const me = `Hmm..
|
|
14
|
+
|
|
15
|
+
It seems I might be having some issues right now. Please clear the chat and try again.`, ye = () => {
|
|
16
|
+
const { baseSettings: f, aiChatSettings: a } = te(), [s = "", v] = ie({
|
|
15
17
|
prop: a.conversationId,
|
|
16
18
|
defaultProp: a.conversationId ?? ""
|
|
17
|
-
}), { logEvent: i } = oe(), { setConversationId:
|
|
19
|
+
}), { logEvent: i } = oe(), { setConversationId: F, emitToParent: k } = ce(), [o, m] = r(""), D = (e) => m(e.target.value), {
|
|
18
20
|
/* shouldBypassCaptcha, */
|
|
19
|
-
filters:
|
|
20
|
-
} =
|
|
21
|
-
onInputMessageChange:
|
|
22
|
-
filters:
|
|
23
|
-
|
|
24
|
-
context:
|
|
25
|
-
headers:
|
|
26
|
-
apiKey:
|
|
21
|
+
filters: I
|
|
22
|
+
} = f, {
|
|
23
|
+
onInputMessageChange: N,
|
|
24
|
+
filters: C,
|
|
25
|
+
agentUrl: A,
|
|
26
|
+
context: R,
|
|
27
|
+
headers: B,
|
|
28
|
+
apiKey: E
|
|
27
29
|
} = a, P = (e) => {
|
|
28
30
|
switch (e.code) {
|
|
29
31
|
case 400:
|
|
30
32
|
return e.message;
|
|
31
33
|
case 403:
|
|
32
|
-
return `There seems to be a configuration error. Please contact ${
|
|
34
|
+
return `There seems to be a configuration error. Please contact ${f.organizationDisplayName ?? "Administrator"}`;
|
|
33
35
|
default:
|
|
34
|
-
return
|
|
35
|
-
|
|
36
|
-
It seems I might be having some issues right now. Please clear the chat and try again.`;
|
|
36
|
+
return me;
|
|
37
37
|
}
|
|
38
|
-
}, [
|
|
38
|
+
}, [T, K] = r({}), [U, u] = r([]), [W, y] = r(null), {
|
|
39
39
|
messages: l,
|
|
40
|
-
sendMessage:
|
|
41
|
-
status:
|
|
40
|
+
sendMessage: $,
|
|
41
|
+
status: b,
|
|
42
42
|
setMessages: w,
|
|
43
|
-
stop:
|
|
43
|
+
stop: z,
|
|
44
44
|
error: p
|
|
45
45
|
} = X({
|
|
46
46
|
transport: new Y({
|
|
47
47
|
api: A,
|
|
48
48
|
headers: {
|
|
49
|
-
...
|
|
50
|
-
...
|
|
49
|
+
...E ? { Authorization: `Bearer ${E}` } : {},
|
|
50
|
+
...B
|
|
51
51
|
},
|
|
52
52
|
body: {
|
|
53
|
-
requestContext:
|
|
53
|
+
requestContext: R
|
|
54
54
|
}
|
|
55
55
|
}),
|
|
56
|
+
onData(e) {
|
|
57
|
+
k(e.type, e.data);
|
|
58
|
+
},
|
|
56
59
|
async onFinish() {
|
|
57
60
|
await i({
|
|
58
61
|
eventName: "assistant_message_received",
|
|
@@ -67,22 +70,22 @@ It seems I might be having some issues right now. Please clear the chat and try
|
|
|
67
70
|
});
|
|
68
71
|
},
|
|
69
72
|
onError(e) {
|
|
70
|
-
console.log("onError", e.message),
|
|
73
|
+
console.log("onError", e.message), w((c) => {
|
|
71
74
|
const n = [...c], t = n[n.length - 1];
|
|
72
75
|
return t && (t.parts = [{ type: "text", text: P(e) }]), n;
|
|
73
76
|
});
|
|
74
77
|
}
|
|
75
|
-
}),
|
|
78
|
+
}), S = b === "submitted", H = b === "streaming", L = l.length === 0, g = !o.trim() || S, O = se("(max-width: 768px)"), [q, d] = r(null);
|
|
76
79
|
x(() => {
|
|
77
|
-
p &&
|
|
80
|
+
p && d(p);
|
|
78
81
|
}, [p]);
|
|
79
|
-
const
|
|
82
|
+
const G = () => d(null), M = Z(null);
|
|
80
83
|
x(() => {
|
|
81
|
-
|
|
84
|
+
N?.(o);
|
|
82
85
|
}, [o]);
|
|
83
|
-
const
|
|
84
|
-
e.key === "Enter" && !e.shiftKey && !g && !e.nativeEvent.isComposing && (e.preventDefault(),
|
|
85
|
-
},
|
|
86
|
+
const J = (e) => {
|
|
87
|
+
e.key === "Enter" && !e.shiftKey && !g && !e.nativeEvent.isComposing && (e.preventDefault(), h());
|
|
88
|
+
}, h = async (e = o) => {
|
|
86
89
|
if (g && (!e || e.trim().length === 0)) return;
|
|
87
90
|
u([]), m(""), await i({
|
|
88
91
|
eventName: "user_message_submitted",
|
|
@@ -90,13 +93,13 @@ It seems I might be having some issues right now. Please clear the chat and try
|
|
|
90
93
|
conversationId: s
|
|
91
94
|
}
|
|
92
95
|
});
|
|
93
|
-
const c =
|
|
94
|
-
...
|
|
95
|
-
...
|
|
96
|
+
const c = I || C ? JSON.stringify({
|
|
97
|
+
...I,
|
|
98
|
+
...C
|
|
96
99
|
}) : void 0, n = {};
|
|
97
100
|
c && (n["inkeep-filters"] = c);
|
|
98
101
|
let t = s;
|
|
99
|
-
t || (t = `conv_${ne(16)}`,
|
|
102
|
+
t || (t = `conv_${ne(16)}`, v(t)), F(t), $(
|
|
100
103
|
// { ...userMessage, files },
|
|
101
104
|
// { ...userMessage, },
|
|
102
105
|
{
|
|
@@ -109,53 +112,55 @@ It seems I might be having some issues right now. Please clear the chat and try
|
|
|
109
112
|
}
|
|
110
113
|
}
|
|
111
114
|
);
|
|
112
|
-
},
|
|
113
|
-
|
|
115
|
+
}, Q = () => {
|
|
116
|
+
z();
|
|
114
117
|
}, _ = () => {
|
|
115
|
-
|
|
118
|
+
G(), w([]), v(""), K({}), u([]), y(null), i({
|
|
116
119
|
eventName: "chat_clear_button_clicked",
|
|
117
120
|
properties: {
|
|
118
121
|
conversationId: s
|
|
119
122
|
}
|
|
120
123
|
});
|
|
121
|
-
}, { openForm:
|
|
124
|
+
}, { openForm: V } = re(), j = ae();
|
|
122
125
|
return ee(a.chatFunctionsRef, () => ({
|
|
123
|
-
submitMessage:
|
|
126
|
+
submitMessage: h,
|
|
124
127
|
updateInputMessage(e) {
|
|
125
128
|
m(e);
|
|
126
129
|
},
|
|
127
130
|
clearChat: _,
|
|
128
131
|
openForm: (e) => {
|
|
129
|
-
|
|
132
|
+
j?.setView("chat"), V(e, void 0);
|
|
130
133
|
},
|
|
131
134
|
focusInput: () => {
|
|
132
135
|
M.current?.focus();
|
|
133
136
|
}
|
|
134
137
|
})), {
|
|
135
138
|
messages: l,
|
|
136
|
-
isLoading:
|
|
137
|
-
isStreaming:
|
|
138
|
-
error:
|
|
139
|
+
isLoading: S,
|
|
140
|
+
isStreaming: H,
|
|
141
|
+
error: q,
|
|
142
|
+
setError: d,
|
|
139
143
|
isSubmitDisabled: g,
|
|
140
144
|
input: o,
|
|
141
|
-
handleInputChange:
|
|
142
|
-
handleInputKeyDown:
|
|
143
|
-
handleSubmit:
|
|
144
|
-
stop:
|
|
145
|
+
handleInputChange: D,
|
|
146
|
+
handleInputKeyDown: J,
|
|
147
|
+
handleSubmit: h,
|
|
148
|
+
stop: Q,
|
|
145
149
|
clear: _,
|
|
146
|
-
messageButtons:
|
|
150
|
+
messageButtons: T,
|
|
147
151
|
isEmpty: l.length === 0,
|
|
148
152
|
inputRef: M,
|
|
149
|
-
isMobile:
|
|
153
|
+
isMobile: O,
|
|
150
154
|
// Additional state for attachments and workflow
|
|
151
|
-
messageAttachments:
|
|
155
|
+
messageAttachments: U,
|
|
152
156
|
setMessageAttachments: u,
|
|
153
|
-
selectedWorkflow:
|
|
154
|
-
setSelectedWorkflow:
|
|
155
|
-
isNewChat:
|
|
157
|
+
selectedWorkflow: W,
|
|
158
|
+
setSelectedWorkflow: y,
|
|
159
|
+
isNewChat: L,
|
|
156
160
|
conversationId: s
|
|
157
161
|
};
|
|
158
162
|
};
|
|
159
163
|
export {
|
|
160
|
-
|
|
164
|
+
me as DEFAULT_ERROR_MESSAGE,
|
|
165
|
+
ye as useInkeepChat
|
|
161
166
|
};
|
|
@@ -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 n=require("react"),b=require("./use-inkeep-chat.cjs"),E=require("../../../types/message.cjs");function L(i,p,g){const[l,R]=n.useState([]),[h,A]=n.useState(new Map),[d,D]=n.useState(Date.now()),[P,y]=n.useState(!1),S=n.useRef(0),x=n.useRef(0),w=n.useRef([]),f=n.useRef(h);f.current=h;const C=n.useCallback(()=>{const t=[];let e="",o=[],c=!1;i.length>S.current&&(D(Date.now()),S.current=i.length),x.current=0;const m=new Map,u=(s=!1)=>{if(o.length>0){const r=`group-${x.current++}`,a=f.current.get(r);a?m.set(r,{...a,isCompleted:s}):m.set(r,{isCompleted:s}),t.push({type:"summary-group",summaries:[...o],groupKey:r}),o=[]}};for(const s of i)if(s.type==="text")u(!0),e+=s.text||"";else if(s.type==="data-summary")e.trim()&&(t.push({type:"text",text:e}),e=""),o.push(s.data);else if(s.type==="data-operation"){e.trim()&&(t.push({type:"text",text:e}),e="");const r=s.data;if(r?.type)switch(r.type){case"completion":u(!0);break;case"error":{u(!0);const a=r.message||"Unknown error";console.warn("Data operation error:",a),g(new Error(a)),c||(t.push({type:"text",text:b.DEFAULT_ERROR_MESSAGE}),c=!0);break}default:{const{type:a,label:v}=r;o.push({type:a,label:v});break}}}else if(s.type==="data-artifact")if(s.data?.type?.toLowerCase()===E.CITATION_ARTIFACT_TYPE){const r=s.data,a=r.artifactSummary||{title:r.name};e+=` ^${a?.title||r.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=""),u(!0),t.push(s));return u(!p),e.trim()&&t.push({type:"text",text:e}),{processed:t,newTimings:m}},[i,p,g]);n.useEffect(()=>{if(w.current===i)return;w.current=i;const{processed:t,newTimings:e}=C();R(t),(e.size!==f.current.size||Array.from(e.entries()).some(([c,m])=>{const u=f.current.get(c);return!u||u.isCompleted!==m.isCompleted}))&&A(e)},[C,i]);const T=n.useCallback(()=>{const t=Date.now()-d,e=Array.from(f.current.values()).some(c=>!c.isCompleted),o=t>1e3&&!e;y(o)},[d]);n.useEffect(()=>{if(!p){y(!1);return}if(!(l.length>0)){y(!1);return}const e=setInterval(T,200);return()=>clearInterval(e)},[p,T,l.length]);const k=n.useMemo(()=>!(l.length>0),[l.length]);return{processedParts:l,summaryTimings:h,shouldShowInitialLoading:k,shouldShowStreamDelayLoading:P}}exports.useStreamProcessor=L;
|
|
@@ -1,121 +1,101 @@
|
|
|
1
1
|
"use client";
|
|
2
|
-
import { useState as
|
|
3
|
-
import {
|
|
4
|
-
import {
|
|
5
|
-
function
|
|
6
|
-
const [
|
|
7
|
-
|
|
8
|
-
const
|
|
9
|
-
const
|
|
10
|
-
let
|
|
11
|
-
|
|
12
|
-
const
|
|
13
|
-
if (
|
|
14
|
-
const
|
|
15
|
-
|
|
16
|
-
...
|
|
17
|
-
isCompleted:
|
|
18
|
-
}) :
|
|
19
|
-
isCompleted:
|
|
20
|
-
}),
|
|
2
|
+
import { useState as p, useRef as h, useCallback as D, useEffect as R, useMemo as M } from "react";
|
|
3
|
+
import { DEFAULT_ERROR_MESSAGE as b } from "./use-inkeep-chat.js";
|
|
4
|
+
import { CITATION_ARTIFACT_TYPE as _ } from "../../../types/message.js";
|
|
5
|
+
function z(i, f, d) {
|
|
6
|
+
const [u, v] = p([]), [y, L] = p(/* @__PURE__ */ new Map()), [x, P] = p(Date.now()), [k, g] = p(!1), w = h(0), C = h(0), S = h([]), m = h(y);
|
|
7
|
+
m.current = y;
|
|
8
|
+
const T = D(() => {
|
|
9
|
+
const e = [];
|
|
10
|
+
let t = "", o = [], c = !1;
|
|
11
|
+
i.length > w.current && (P(Date.now()), w.current = i.length), C.current = 0;
|
|
12
|
+
const l = /* @__PURE__ */ new Map(), a = (r = !1) => {
|
|
13
|
+
if (o.length > 0) {
|
|
14
|
+
const s = `group-${C.current++}`, n = m.current.get(s);
|
|
15
|
+
n ? l.set(s, {
|
|
16
|
+
...n,
|
|
17
|
+
isCompleted: r
|
|
18
|
+
}) : l.set(s, {
|
|
19
|
+
isCompleted: r
|
|
20
|
+
}), e.push({
|
|
21
21
|
type: "summary-group",
|
|
22
|
-
summaries: [...
|
|
23
|
-
groupKey:
|
|
24
|
-
}),
|
|
22
|
+
summaries: [...o],
|
|
23
|
+
groupKey: s
|
|
24
|
+
}), o = [];
|
|
25
25
|
}
|
|
26
26
|
};
|
|
27
|
-
for (const
|
|
28
|
-
if (
|
|
29
|
-
|
|
30
|
-
else if (
|
|
31
|
-
|
|
32
|
-
else if (
|
|
33
|
-
|
|
34
|
-
|
|
35
|
-
|
|
27
|
+
for (const r of i)
|
|
28
|
+
if (r.type === "text")
|
|
29
|
+
a(!0), t += r.text || "";
|
|
30
|
+
else if (r.type === "data-summary")
|
|
31
|
+
t.trim() && (e.push({ type: "text", text: t }), t = ""), o.push(r.data);
|
|
32
|
+
else if (r.type === "data-operation") {
|
|
33
|
+
t.trim() && (e.push({ type: "text", text: t }), t = "");
|
|
34
|
+
const s = r.data;
|
|
35
|
+
if (s?.type)
|
|
36
|
+
switch (s.type) {
|
|
36
37
|
case "completion":
|
|
37
|
-
|
|
38
|
-
"unknown",
|
|
39
|
-
// No agent ID available in current structure
|
|
40
|
-
1
|
|
41
|
-
// No iteration available in current structure
|
|
42
|
-
), m(!0);
|
|
38
|
+
a(!0);
|
|
43
39
|
break;
|
|
44
|
-
case "
|
|
45
|
-
|
|
46
|
-
|
|
47
|
-
|
|
48
|
-
"unknown"
|
|
49
|
-
// No graph ID available in current structure
|
|
50
|
-
);
|
|
40
|
+
case "error": {
|
|
41
|
+
a(!0);
|
|
42
|
+
const n = s.message || "Unknown error";
|
|
43
|
+
console.warn("Data operation error:", n), d(new Error(n)), c || (e.push({ type: "text", text: b }), c = !0);
|
|
51
44
|
break;
|
|
52
|
-
|
|
53
|
-
|
|
54
|
-
|
|
55
|
-
|
|
56
|
-
case "agent_ready":
|
|
57
|
-
console.log("Agent state:", a.type, a.ctx);
|
|
45
|
+
}
|
|
46
|
+
default: {
|
|
47
|
+
const { type: n, label: I } = s;
|
|
48
|
+
o.push({ type: n, label: I });
|
|
58
49
|
break;
|
|
50
|
+
}
|
|
59
51
|
}
|
|
60
|
-
} else if (
|
|
61
|
-
if (
|
|
62
|
-
const
|
|
63
|
-
title:
|
|
52
|
+
} else if (r.type === "data-artifact")
|
|
53
|
+
if (r.data?.type?.toLowerCase() === _) {
|
|
54
|
+
const s = r.data, n = s.artifactSummary || {
|
|
55
|
+
title: s.name
|
|
64
56
|
};
|
|
65
|
-
|
|
57
|
+
t += ` ^${n?.title || s.name}^`;
|
|
66
58
|
} else
|
|
67
|
-
|
|
68
|
-
|
|
69
|
-
|
|
70
|
-
|
|
71
|
-
|
|
72
|
-
|
|
73
|
-
t.data.artifactSummary || {},
|
|
74
|
-
// Use artifactSummary as summaryData
|
|
75
|
-
{},
|
|
76
|
-
// fullData not available in current structure
|
|
77
|
-
{ name: t.data.name, description: t.data.description }
|
|
78
|
-
// Use available fields as metadata
|
|
79
|
-
);
|
|
80
|
-
else t.type === "data-component" && (e.trim() && (n.push({ type: "text", text: e }), e = ""), n.push(t));
|
|
81
|
-
return m(!i), e.trim() && n.push({ type: "text", text: e }), { processed: n, newTimings: o };
|
|
82
|
-
}, [r, i, k, C, T, S]);
|
|
83
|
-
I(() => {
|
|
84
|
-
if (x.current === r)
|
|
59
|
+
t.trim() && (e.push({ type: "text", text: t }), t = ""), e.push(r);
|
|
60
|
+
else r.type === "data-component" && (t.trim() && (e.push({ type: "text", text: t }), t = ""), a(!0), e.push(r));
|
|
61
|
+
return a(!f), t.trim() && e.push({ type: "text", text: t }), { processed: e, newTimings: l };
|
|
62
|
+
}, [i, f, d]);
|
|
63
|
+
R(() => {
|
|
64
|
+
if (S.current === i)
|
|
85
65
|
return;
|
|
86
|
-
|
|
87
|
-
const { processed:
|
|
88
|
-
|
|
89
|
-
const
|
|
90
|
-
return !
|
|
91
|
-
})) && L(
|
|
92
|
-
}, [
|
|
93
|
-
const
|
|
94
|
-
const
|
|
95
|
-
(
|
|
96
|
-
),
|
|
97
|
-
|
|
98
|
-
}, [
|
|
99
|
-
|
|
100
|
-
if (!
|
|
101
|
-
|
|
66
|
+
S.current = i;
|
|
67
|
+
const { processed: e, newTimings: t } = T();
|
|
68
|
+
v(e), (t.size !== m.current.size || Array.from(t.entries()).some(([c, l]) => {
|
|
69
|
+
const a = m.current.get(c);
|
|
70
|
+
return !a || a.isCompleted !== l.isCompleted;
|
|
71
|
+
})) && L(t);
|
|
72
|
+
}, [T, i]);
|
|
73
|
+
const A = D(() => {
|
|
74
|
+
const e = Date.now() - x, t = Array.from(m.current.values()).some(
|
|
75
|
+
(c) => !c.isCompleted
|
|
76
|
+
), o = e > 1e3 && !t;
|
|
77
|
+
g(o);
|
|
78
|
+
}, [x]);
|
|
79
|
+
R(() => {
|
|
80
|
+
if (!f) {
|
|
81
|
+
g(!1);
|
|
102
82
|
return;
|
|
103
83
|
}
|
|
104
|
-
if (!(
|
|
105
|
-
|
|
84
|
+
if (!(u.length > 0)) {
|
|
85
|
+
g(!1);
|
|
106
86
|
return;
|
|
107
87
|
}
|
|
108
|
-
const
|
|
109
|
-
return () => clearInterval(
|
|
110
|
-
}, [
|
|
111
|
-
const
|
|
88
|
+
const t = setInterval(A, 200);
|
|
89
|
+
return () => clearInterval(t);
|
|
90
|
+
}, [f, A, u.length]);
|
|
91
|
+
const E = M(() => !(u.length > 0), [u.length]);
|
|
112
92
|
return {
|
|
113
|
-
processedParts:
|
|
114
|
-
summaryTimings:
|
|
115
|
-
shouldShowInitialLoading:
|
|
116
|
-
shouldShowStreamDelayLoading:
|
|
93
|
+
processedParts: u,
|
|
94
|
+
summaryTimings: y,
|
|
95
|
+
shouldShowInitialLoading: E,
|
|
96
|
+
shouldShowStreamDelayLoading: k
|
|
117
97
|
};
|
|
118
98
|
}
|
|
119
99
|
export {
|
|
120
|
-
|
|
100
|
+
z as useStreamProcessor
|
|
121
101
|
};
|
|
@@ -1 +1 @@
|
|
|
1
|
-
"use client";"use strict";Object.defineProperty(exports,Symbol.toStringTag,{value:"Module"});const r=require("react"),T=require("../../atoms/cmdk/index.cjs"),C=require("../../providers/search-events-provider.cjs"),E=require("../../providers/config-provider.cjs"),_=require("./search-provider.cjs"),k=
|
|
1
|
+
"use client";"use strict";Object.defineProperty(exports,Symbol.toStringTag,{value:"Module"});const r=require("react"),T=require("../../atoms/cmdk/index.cjs"),C=require("../../providers/search-events-provider.cjs"),E=require("../../providers/config-provider.cjs"),_=require("./search-provider.cjs"),k=250,P=()=>{const{setResultsList:t,setLoading:n,showSearchResults:i,setShowSearchResults:h}=_.useSearch(),{searchSettings:p}=E.useInkeepConfig(),{debounceTimeMs:b,onQueryChange:w,onSearch:f}=p,{logEvent:u}=C.useSearchEvents(),a=r.useRef({}),S=r.useRef(null),d=r.useRef(null),v=r.useCallback(async e=>{if(!f){console.warn("No search implementation provided. Please provide onSearch callback in searchSettings."),t([]);return}const s=new AbortController;S.current=s;try{n(!0);const o=await f(e,s.signal);a.current[e]=o,t(o)}catch(o){if(o.name==="AbortError")return;console.error("Search implementation failed:",o),t([])}finally{n(!1)}},[f,n,t]),R=r.useCallback(e=>{const s=a.current[e];u({eventName:"search_query_response_received",properties:{searchQuery:e,totalResults:s?.length}})},[u]),m=r.useCallback(()=>{S.current&&(S.current.abort(),n(!1))},[n]),g=r.useCallback(e=>{if(d.current&&window.clearTimeout(d.current),!e){m(),t([]);return}d.current=window.setTimeout(()=>{m(),u({eventName:"search_query_submitted",properties:{searchQuery:e}}),a.current[e]?(t(a.current[e]),R(e)):v(e).then(()=>{R(e)})},b)},[b,v,R,m,u,t]),c=T.useCommandState(e=>e.search),l=r.useRef(null);r.useEffect(()=>{const e=()=>{l.current!==null&&(window.clearTimeout(l.current),l.current=null)},s=!!c;return s&&!i?(e(),l.current=window.setTimeout(()=>{h(!0)},k)):!s&&i&&(e(),h(!1)),e},[c,i,h]),r.useEffect(()=>{w?.(c),g(c)},[g,c,w])};exports.useSearchFetch=P;
|
|
@@ -4,7 +4,7 @@ import { useCommandState as _ } from "../../atoms/cmdk/index.js";
|
|
|
4
4
|
import { useSearchEvents as E } from "../../providers/search-events-provider.js";
|
|
5
5
|
import { useInkeepConfig as k } from "../../providers/config-provider.js";
|
|
6
6
|
import { useSearch as L } from "./search-provider.js";
|
|
7
|
-
const A =
|
|
7
|
+
const A = 250, O = () => {
|
|
8
8
|
const { setResultsList: t, setLoading: s, showSearchResults: h, setShowSearchResults: m } = L(), { searchSettings: C } = k(), { debounceTimeMs: w, onQueryChange: T, onSearch: f } = C, { logEvent: c } = E(), a = u({}), S = u(null), d = u(null), b = i(
|
|
9
9
|
async (e) => {
|
|
10
10
|
if (!f) {
|
|
@@ -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 n=require("react"),u=require("../atoms/shadow/context.cjs");function i(){const e=u.useShadow()?.shadowHost,s=n.useRef(""),o=n.useCallback(t=>{s.current=t},[]),r=n.useCallback((t,a)=>{if(!e){console.warn("useStreamingEvents: No host element available for parent event emission");return}const c=new CustomEvent(`ikp-${t}`,{detail:{...a,conversationId:s.current,timestamp:Date.now()},bubbles:!0,composed:!0});e.dispatchEvent(c)},[e]);return{setConversationId:o,emitToParent:r}}exports.useStreamingEvents=i;
|