@inkeep/agents-ui 0.14.11 → 0.14.12
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 -57
- package/dist/primitives/components/embedded-chat/use-stream-processor.cjs +1 -1
- package/dist/primitives/components/embedded-chat/use-stream-processor.js +89 -75
- 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/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 +5 -3
- package/dist/types/types.d.ts +5 -3
- 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,emitStreamError:R}=oe.useStreamingEvents(),[a,u]=t.useState(""),k=e=>u(e.target.value),{filters:S}=f,{onInputMessageChange:A,filters:E,agentUrl:P,context:x,headers:D,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}},[U,T]=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:P,headers:{...C?{Authorization:`Bearer ${C}`}:{},...D},body:{requestContext:x}}),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),R(e.message,void 0,e.code?.toString()),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(()=>{A?.(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=S||E?JSON.stringify({...S,...E}):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(""),T({}),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:k,handleInputKeyDown:Q,handleSubmit:h,stop:j,clear:_,messageButtons:U,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,47 +10,47 @@ 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.`, Se = () => {
|
|
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, emitStreamError: k } = ce(), [o, m] = r(""), N = (e) => m(e.target.value), {
|
|
18
20
|
/* shouldBypassCaptcha, */
|
|
19
|
-
filters:
|
|
20
|
-
} =
|
|
21
|
-
onInputMessageChange:
|
|
22
|
-
filters:
|
|
23
|
-
|
|
24
|
-
context:
|
|
25
|
-
headers:
|
|
26
|
-
apiKey:
|
|
27
|
-
} = a,
|
|
21
|
+
filters: I
|
|
22
|
+
} = f, {
|
|
23
|
+
onInputMessageChange: A,
|
|
24
|
+
filters: C,
|
|
25
|
+
agentUrl: D,
|
|
26
|
+
context: R,
|
|
27
|
+
headers: B,
|
|
28
|
+
apiKey: E
|
|
29
|
+
} = a, K = (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
|
+
}, [P, T] = r({}), [U, u] = r([]), [W, S] = r(null), {
|
|
39
39
|
messages: l,
|
|
40
|
-
sendMessage:
|
|
41
|
-
status:
|
|
42
|
-
setMessages:
|
|
43
|
-
stop:
|
|
40
|
+
sendMessage: $,
|
|
41
|
+
status: b,
|
|
42
|
+
setMessages: y,
|
|
43
|
+
stop: z,
|
|
44
44
|
error: p
|
|
45
45
|
} = X({
|
|
46
46
|
transport: new Y({
|
|
47
|
-
api:
|
|
47
|
+
api: D,
|
|
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
56
|
async onFinish() {
|
|
@@ -67,22 +67,22 @@ It seems I might be having some issues right now. Please clear the chat and try
|
|
|
67
67
|
});
|
|
68
68
|
},
|
|
69
69
|
onError(e) {
|
|
70
|
-
console.log("onError", e.message),
|
|
70
|
+
console.log("onError", e.message), k(e.message, void 0, e.code?.toString()), y((c) => {
|
|
71
71
|
const n = [...c], t = n[n.length - 1];
|
|
72
|
-
return t && (t.parts = [{ type: "text", text:
|
|
72
|
+
return t && (t.parts = [{ type: "text", text: K(e) }]), n;
|
|
73
73
|
});
|
|
74
74
|
}
|
|
75
|
-
}),
|
|
75
|
+
}), w = b === "submitted", H = b === "streaming", L = l.length === 0, g = !o.trim() || w, O = se("(max-width: 768px)"), [q, d] = r(null);
|
|
76
76
|
x(() => {
|
|
77
|
-
p &&
|
|
77
|
+
p && d(p);
|
|
78
78
|
}, [p]);
|
|
79
|
-
const
|
|
79
|
+
const G = () => d(null), M = Z(null);
|
|
80
80
|
x(() => {
|
|
81
|
-
|
|
81
|
+
A?.(o);
|
|
82
82
|
}, [o]);
|
|
83
|
-
const
|
|
84
|
-
e.key === "Enter" && !e.shiftKey && !g && !e.nativeEvent.isComposing && (e.preventDefault(),
|
|
85
|
-
},
|
|
83
|
+
const J = (e) => {
|
|
84
|
+
e.key === "Enter" && !e.shiftKey && !g && !e.nativeEvent.isComposing && (e.preventDefault(), h());
|
|
85
|
+
}, h = async (e = o) => {
|
|
86
86
|
if (g && (!e || e.trim().length === 0)) return;
|
|
87
87
|
u([]), m(""), await i({
|
|
88
88
|
eventName: "user_message_submitted",
|
|
@@ -90,13 +90,13 @@ It seems I might be having some issues right now. Please clear the chat and try
|
|
|
90
90
|
conversationId: s
|
|
91
91
|
}
|
|
92
92
|
});
|
|
93
|
-
const c =
|
|
94
|
-
...
|
|
95
|
-
...
|
|
93
|
+
const c = I || C ? JSON.stringify({
|
|
94
|
+
...I,
|
|
95
|
+
...C
|
|
96
96
|
}) : void 0, n = {};
|
|
97
97
|
c && (n["inkeep-filters"] = c);
|
|
98
98
|
let t = s;
|
|
99
|
-
t || (t = `conv_${ne(16)}`,
|
|
99
|
+
t || (t = `conv_${ne(16)}`, v(t)), F(t), $(
|
|
100
100
|
// { ...userMessage, files },
|
|
101
101
|
// { ...userMessage, },
|
|
102
102
|
{
|
|
@@ -109,53 +109,55 @@ It seems I might be having some issues right now. Please clear the chat and try
|
|
|
109
109
|
}
|
|
110
110
|
}
|
|
111
111
|
);
|
|
112
|
-
},
|
|
113
|
-
|
|
112
|
+
}, Q = () => {
|
|
113
|
+
z();
|
|
114
114
|
}, _ = () => {
|
|
115
|
-
|
|
115
|
+
G(), y([]), v(""), T({}), u([]), S(null), i({
|
|
116
116
|
eventName: "chat_clear_button_clicked",
|
|
117
117
|
properties: {
|
|
118
118
|
conversationId: s
|
|
119
119
|
}
|
|
120
120
|
});
|
|
121
|
-
}, { openForm:
|
|
121
|
+
}, { openForm: V } = re(), j = ae();
|
|
122
122
|
return ee(a.chatFunctionsRef, () => ({
|
|
123
|
-
submitMessage:
|
|
123
|
+
submitMessage: h,
|
|
124
124
|
updateInputMessage(e) {
|
|
125
125
|
m(e);
|
|
126
126
|
},
|
|
127
127
|
clearChat: _,
|
|
128
128
|
openForm: (e) => {
|
|
129
|
-
|
|
129
|
+
j?.setView("chat"), V(e, void 0);
|
|
130
130
|
},
|
|
131
131
|
focusInput: () => {
|
|
132
132
|
M.current?.focus();
|
|
133
133
|
}
|
|
134
134
|
})), {
|
|
135
135
|
messages: l,
|
|
136
|
-
isLoading:
|
|
137
|
-
isStreaming:
|
|
138
|
-
error:
|
|
136
|
+
isLoading: w,
|
|
137
|
+
isStreaming: H,
|
|
138
|
+
error: q,
|
|
139
|
+
setError: d,
|
|
139
140
|
isSubmitDisabled: g,
|
|
140
141
|
input: o,
|
|
141
142
|
handleInputChange: N,
|
|
142
|
-
handleInputKeyDown:
|
|
143
|
-
handleSubmit:
|
|
144
|
-
stop:
|
|
143
|
+
handleInputKeyDown: J,
|
|
144
|
+
handleSubmit: h,
|
|
145
|
+
stop: Q,
|
|
145
146
|
clear: _,
|
|
146
|
-
messageButtons:
|
|
147
|
+
messageButtons: P,
|
|
147
148
|
isEmpty: l.length === 0,
|
|
148
149
|
inputRef: M,
|
|
149
|
-
isMobile:
|
|
150
|
+
isMobile: O,
|
|
150
151
|
// Additional state for attachments and workflow
|
|
151
|
-
messageAttachments:
|
|
152
|
+
messageAttachments: U,
|
|
152
153
|
setMessageAttachments: u,
|
|
153
|
-
selectedWorkflow:
|
|
154
|
-
setSelectedWorkflow:
|
|
155
|
-
isNewChat:
|
|
154
|
+
selectedWorkflow: W,
|
|
155
|
+
setSelectedWorkflow: S,
|
|
156
|
+
isNewChat: L,
|
|
156
157
|
conversationId: s
|
|
157
158
|
};
|
|
158
159
|
};
|
|
159
160
|
export {
|
|
160
|
-
|
|
161
|
+
me as DEFAULT_ERROR_MESSAGE,
|
|
162
|
+
Se as useInkeepChat
|
|
161
163
|
};
|
|
@@ -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"),M=require("./use-inkeep-chat.cjs"),_=require("../../hooks/use-streaming-events.cjs"),q=require("../../../types/message.cjs");function z(u,l,g){const[m,D]=r.useState([]),[d,E]=r.useState(new Map),[y,I]=r.useState(Date.now()),[P,h]=r.useState(!1),w=r.useRef(0),S=r.useRef(0),x=r.useRef([]),f=r.useRef(d);f.current=d;const{emitArtifactSaved:k,emitCompletion:C,emitAgentInitializing:T,emitTextDelta:A}=_.useStreamingEvents(),R=r.useCallback(()=>{const n=[];let e="",o=[],c=!1;u.length>w.current&&(I(Date.now()),w.current=u.length),S.current=0;const p=new Map,i=(t=!1)=>{if(o.length>0){const s=`group-${S.current++}`,a=f.current.get(s);a?p.set(s,{...a,isCompleted:t}):p.set(s,{isCompleted:t}),n.push({type:"summary-group",summaries:[...o],groupKey:s}),o=[]}};for(const t of u)if(t.type==="text")i(!0),t.text&&l&&A(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"){e.trim()&&(n.push({type:"text",text:e}),e="");const s=t.data;if(s?.type)switch(s.type){case"completion":C("unknown",1),i(!0);break;case"agent_initializing":T("unknown","unknown");break;case"error":{i(!0);const a=s.message||"Unknown error";console.warn("Data operation error:",a),g(new Error(a)),c||(n.push({type:"text",text:M.DEFAULT_ERROR_MESSAGE}),c=!0);break}default:{const{type:a,label:L}=s;o.push({type:a,label:L});break}}}else if(t.type==="data-artifact")if(t.data?.type?.toLowerCase()===q.CITATION_ARTIFACT_TYPE){const s=t.data,a=s.artifactSummary||{title:s.name};e+=` ^${a?.title||s.name}^`}else e.trim()&&(n.push({type:"text",text:e}),e=""),n.push(t),t.data&&k(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=""),i(!0),n.push(t));return i(!l),e.trim()&&n.push({type:"text",text:e}),{processed:n,newTimings:p}},[u,l,k,C,T,A,g]);r.useEffect(()=>{if(x.current===u)return;x.current=u;const{processed:n,newTimings:e}=R();D(n),(e.size!==f.current.size||Array.from(e.entries()).some(([c,p])=>{const i=f.current.get(c);return!i||i.isCompleted!==p.isCompleted}))&&E(e)},[R,u]);const v=r.useCallback(()=>{const n=Date.now()-y,e=Array.from(f.current.values()).some(c=>!c.isCompleted),o=n>1e3&&!e;h(o)},[y]);r.useEffect(()=>{if(!l){h(!1);return}if(!(m.length>0)){h(!1);return}const e=setInterval(v,200);return()=>clearInterval(e)},[l,v,m.length]);const b=r.useMemo(()=>!(m.length>0),[m.length]);return{processedParts:m,summaryTimings:d,shouldShowInitialLoading:b,shouldShowStreamDelayLoading:P}}exports.useStreamProcessor=z;
|
|
@@ -1,121 +1,135 @@
|
|
|
1
1
|
"use client";
|
|
2
|
-
import { useState as
|
|
3
|
-
import {
|
|
4
|
-
import { useStreamingEvents as
|
|
5
|
-
|
|
6
|
-
|
|
7
|
-
|
|
8
|
-
|
|
2
|
+
import { useState as p, useRef as d, useCallback as R, useEffect as E, useMemo as F } from "react";
|
|
3
|
+
import { DEFAULT_ERROR_MESSAGE as G } from "./use-inkeep-chat.js";
|
|
4
|
+
import { useStreamingEvents as O } from "../../hooks/use-streaming-events.js";
|
|
5
|
+
import { CITATION_ARTIFACT_TYPE as U } from "../../../types/message.js";
|
|
6
|
+
function j(i, u, g) {
|
|
7
|
+
const [m, L] = p([]), [h, P] = p(/* @__PURE__ */ new Map()), [w, b] = p(Date.now()), [M, y] = p(!1), x = d(0), k = d(0), S = d([]), f = d(h);
|
|
8
|
+
f.current = h;
|
|
9
|
+
const { emitArtifactSaved: T, emitCompletion: C, emitAgentInitializing: A, emitTextDelta: D } = O(), v = R(() => {
|
|
9
10
|
const n = [];
|
|
10
|
-
let
|
|
11
|
-
|
|
12
|
-
const
|
|
11
|
+
let t = "", s = [], c = !1;
|
|
12
|
+
i.length > x.current && (b(Date.now()), x.current = i.length), k.current = 0;
|
|
13
|
+
const l = /* @__PURE__ */ new Map(), o = (e = !1) => {
|
|
13
14
|
if (s.length > 0) {
|
|
14
|
-
const
|
|
15
|
-
|
|
16
|
-
...
|
|
17
|
-
isCompleted:
|
|
18
|
-
}) :
|
|
19
|
-
isCompleted:
|
|
15
|
+
const r = `group-${k.current++}`, a = f.current.get(r);
|
|
16
|
+
a ? l.set(r, {
|
|
17
|
+
...a,
|
|
18
|
+
isCompleted: e
|
|
19
|
+
}) : l.set(r, {
|
|
20
|
+
isCompleted: e
|
|
20
21
|
}), n.push({
|
|
21
22
|
type: "summary-group",
|
|
22
23
|
summaries: [...s],
|
|
23
|
-
groupKey:
|
|
24
|
+
groupKey: r
|
|
24
25
|
}), s = [];
|
|
25
26
|
}
|
|
26
27
|
};
|
|
27
|
-
for (const
|
|
28
|
-
if (
|
|
29
|
-
|
|
30
|
-
else if (
|
|
31
|
-
|
|
32
|
-
else if (
|
|
33
|
-
|
|
34
|
-
|
|
35
|
-
|
|
28
|
+
for (const e of i)
|
|
29
|
+
if (e.type === "text")
|
|
30
|
+
o(!0), e.text && u && D(e.text), t += e.text || "";
|
|
31
|
+
else if (e.type === "data-summary")
|
|
32
|
+
t.trim() && (n.push({ type: "text", text: t }), t = ""), s.push(e.data);
|
|
33
|
+
else if (e.type === "data-operation") {
|
|
34
|
+
t.trim() && (n.push({ type: "text", text: t }), t = "");
|
|
35
|
+
const r = e.data;
|
|
36
|
+
if (r?.type)
|
|
37
|
+
switch (r.type) {
|
|
36
38
|
case "completion":
|
|
37
39
|
C(
|
|
38
40
|
"unknown",
|
|
39
41
|
// No agent ID available in current structure
|
|
40
42
|
1
|
|
41
43
|
// No iteration available in current structure
|
|
42
|
-
),
|
|
44
|
+
), o(!0);
|
|
43
45
|
break;
|
|
44
46
|
case "agent_initializing":
|
|
45
|
-
|
|
47
|
+
A(
|
|
46
48
|
"unknown",
|
|
47
49
|
// No session ID available in current structure
|
|
48
50
|
"unknown"
|
|
49
51
|
// No graph ID available in current structure
|
|
50
52
|
);
|
|
51
53
|
break;
|
|
52
|
-
case "error":
|
|
53
|
-
|
|
54
|
+
case "error": {
|
|
55
|
+
o(!0);
|
|
56
|
+
const a = r.message || "Unknown error";
|
|
57
|
+
console.warn("Data operation error:", a), g(new Error(a)), c || (n.push({ type: "text", text: G }), c = !0);
|
|
54
58
|
break;
|
|
55
|
-
|
|
56
|
-
|
|
57
|
-
|
|
59
|
+
}
|
|
60
|
+
default: {
|
|
61
|
+
const { type: a, label: z } = r;
|
|
62
|
+
s.push({ type: a, label: z });
|
|
58
63
|
break;
|
|
64
|
+
}
|
|
59
65
|
}
|
|
60
|
-
} else if (
|
|
61
|
-
if (
|
|
62
|
-
const
|
|
63
|
-
title:
|
|
66
|
+
} else if (e.type === "data-artifact")
|
|
67
|
+
if (e.data?.type?.toLowerCase() === U) {
|
|
68
|
+
const r = e.data, a = r.artifactSummary || {
|
|
69
|
+
title: r.name
|
|
64
70
|
};
|
|
65
|
-
|
|
71
|
+
t += ` ^${a?.title || r.name}^`;
|
|
66
72
|
} else
|
|
67
|
-
|
|
68
|
-
|
|
69
|
-
|
|
73
|
+
t.trim() && (n.push({ type: "text", text: t }), t = ""), n.push(e), e.data && T(
|
|
74
|
+
e.data.artifactId || "unknown",
|
|
75
|
+
e.data.taskId || "unknown",
|
|
70
76
|
"unknown",
|
|
71
77
|
// toolCallId not available in current structure
|
|
72
|
-
|
|
73
|
-
|
|
78
|
+
e.data.artifactType || "unknown",
|
|
79
|
+
e.data.artifactSummary || {},
|
|
74
80
|
// Use artifactSummary as summaryData
|
|
75
81
|
{},
|
|
76
82
|
// fullData not available in current structure
|
|
77
|
-
{ name:
|
|
83
|
+
{ name: e.data.name, description: e.data.description }
|
|
78
84
|
// Use available fields as metadata
|
|
79
85
|
);
|
|
80
|
-
else
|
|
81
|
-
return
|
|
82
|
-
}, [
|
|
83
|
-
|
|
84
|
-
|
|
86
|
+
else e.type === "data-component" && (t.trim() && (n.push({ type: "text", text: t }), t = ""), o(!0), n.push(e));
|
|
87
|
+
return o(!u), t.trim() && n.push({ type: "text", text: t }), { processed: n, newTimings: l };
|
|
88
|
+
}, [
|
|
89
|
+
i,
|
|
90
|
+
u,
|
|
91
|
+
T,
|
|
92
|
+
C,
|
|
93
|
+
A,
|
|
94
|
+
D,
|
|
95
|
+
g
|
|
96
|
+
]);
|
|
97
|
+
E(() => {
|
|
98
|
+
if (S.current === i)
|
|
85
99
|
return;
|
|
86
|
-
|
|
87
|
-
const { processed: n, newTimings:
|
|
88
|
-
|
|
89
|
-
const
|
|
90
|
-
return !
|
|
91
|
-
})) &&
|
|
92
|
-
}, [
|
|
93
|
-
const
|
|
94
|
-
const n = Date.now() -
|
|
95
|
-
(
|
|
96
|
-
), s = n > 1e3 && !
|
|
97
|
-
|
|
98
|
-
}, [
|
|
99
|
-
|
|
100
|
-
if (!
|
|
101
|
-
|
|
100
|
+
S.current = i;
|
|
101
|
+
const { processed: n, newTimings: t } = v();
|
|
102
|
+
L(n), (t.size !== f.current.size || Array.from(t.entries()).some(([c, l]) => {
|
|
103
|
+
const o = f.current.get(c);
|
|
104
|
+
return !o || o.isCompleted !== l.isCompleted;
|
|
105
|
+
})) && P(t);
|
|
106
|
+
}, [v, i]);
|
|
107
|
+
const I = R(() => {
|
|
108
|
+
const n = Date.now() - w, t = Array.from(f.current.values()).some(
|
|
109
|
+
(c) => !c.isCompleted
|
|
110
|
+
), s = n > 1e3 && !t;
|
|
111
|
+
y(s);
|
|
112
|
+
}, [w]);
|
|
113
|
+
E(() => {
|
|
114
|
+
if (!u) {
|
|
115
|
+
y(!1);
|
|
102
116
|
return;
|
|
103
117
|
}
|
|
104
|
-
if (!(
|
|
105
|
-
|
|
118
|
+
if (!(m.length > 0)) {
|
|
119
|
+
y(!1);
|
|
106
120
|
return;
|
|
107
121
|
}
|
|
108
|
-
const
|
|
109
|
-
return () => clearInterval(
|
|
110
|
-
}, [
|
|
111
|
-
const _ =
|
|
122
|
+
const t = setInterval(I, 200);
|
|
123
|
+
return () => clearInterval(t);
|
|
124
|
+
}, [u, I, m.length]);
|
|
125
|
+
const _ = F(() => !(m.length > 0), [m.length]);
|
|
112
126
|
return {
|
|
113
|
-
processedParts:
|
|
114
|
-
summaryTimings:
|
|
127
|
+
processedParts: m,
|
|
128
|
+
summaryTimings: h,
|
|
115
129
|
shouldShowInitialLoading: _,
|
|
116
|
-
shouldShowStreamDelayLoading:
|
|
130
|
+
shouldShowStreamDelayLoading: M
|
|
117
131
|
};
|
|
118
132
|
}
|
|
119
133
|
export {
|
|
120
|
-
|
|
134
|
+
j as useStreamProcessor
|
|
121
135
|
};
|
|
@@ -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 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.12",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.12",
|
|
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"),x=require("react"),s=require("../styled/components/embedded-chat.cjs"),h=require("../styled/components/modal.cjs"),M=require("../styled/components/shadow.cjs"),g=require("../styled/components/message.cjs"),p=require("../primitives/providers/config-provider.cjs"),C=require("../primitives/providers/root-provider.cjs"),k=require("../primitives/providers/widget-provider.cjs"),T=require("../primitives/components/modal/modal-provider.cjs"),F=require("../primitives/utils/misc.cjs"),j=require("../primitives/atoms/portal-with-theme.cjs"),B=require("../primitives/atoms/error-boundary.cjs"),S=require("./modal.cjs"),v=require("./widget-toggle.cjs");function w(n){const{baseSettings:t,aiChatSettings:r}=n;return e.jsx(B.ErrorBoundary,{children:e.jsx(M.Shadow,{wrapperStyles:{height:"inherit",width:"inherit"},children:e.jsx(C.RootProvider,{config:{baseSettings:t,aiChatSettings:r},componentType:p.WebWidgetInteractionType.EmbeddedChat,children:e.jsx(b,{...n})})})})}function A(n){const{children:t,onToggleView:r,isHidden:a,shouldAutoFocusInput:o=!r}=n;return e.jsx(s.Provider,{isHidden:a,shouldAutoFocusInput:o,children:t})}function b(n){return e.jsx(A,{...n,children:e.jsx(I,{...n})})}function I(n){const{onToggleView:t,variant:r,header:a=y}=n,o=T.useModal(),i=k.useWidget(),c=o&&!i?S.ModalContent:x.Fragment;return e.jsx(c,{children:e.jsxs(s.Wrapper,{variant:r??(t?"no-shadow":"container-with-shadow"),"data-composite":F.dataAttr(!!n.onToggleView||o?.isOpen),children:[e.jsxs(s.Root,{children:[a&&e.jsx(a,{...n}),e.jsx(f,{}),e.jsx(W,{})]}),e.jsx(V,{}),e.jsx(O,{})]})})}const y=n=>{const{onToggleView:t,askAILabel:r,searchLabel:a}=n,o=!!t;return e.jsx(s.Header,{"data-show-toolbar":F.dataAttr(o),children:o?e.jsxs(s.HeaderToolbar,{children:[e.jsxs(s.HeaderToolbarWrapper,{children:[e.jsx(s.ToolbarHeader,{}),e.jsxs(s.Disclaimer,{children:[e.jsx(s.DisclaimerTrigger,{}),e.jsxs(s.DisclaimerContent,{side:"bottom",align:"start",children:[e.jsx(s.DisclaimerText,{}),e.jsx(s.DisclaimerArrow,{})]})]})]}),e.jsx(v.WidgetToggle,{onToggleView:t,askAILabel:r,searchLabel:a,view:"chat"}),e.jsx(h.Close,{})]}):e.jsx(h.Close,{})})};function f(){return e.jsx(s.Content,{children:e.jsxs(s.ContentScrollArea,{children:[e.jsx(s.ContentScrollAreaViewport,{children:e.jsx(E,{})}),e.jsx(s.ContentScrollAreaScrollbar,{children:e.jsx(s.ContentScrollAreaThumb,{})}),e.jsx(s.ContentScrollAreaCorner,{})]})})}function E(){const{aiChatSettings:{components:n}}=p.useInkeepConfig();return e.jsx(s.Messages,{children:({messages:t,isLoading:r})=>{const a=t.at(-1),o=(c,m)=>{const d=n?.[c];if(!d)return console.warn(`Component "${c}" not found in components config`),null;try{if(typeof d=="function"&&d.length<=1)return x.createElement(d,m);const l=d(m,document.createElement("div"),null);return x.isValidElement(l)||typeof l=="string"?l:null}catch(l){return console.error(`🔍 [renderComponent] Error rendering component "${c}":`,l),null}},i=c=>e.jsx(s.Markdown,{text:c});return e.jsxs(e.Fragment,{children:[e.jsx(H,{}),t.map(c=>e.jsxs(s.MessageWrapper,{message:c,children:[e.jsx(u,{}),e.jsxs(s.MessageContentWrapper,{children:[e.jsx(s.MessageContent,{children:n?.IkpMessage?e.jsx(s.DynamicComponent,{name:"IkpMessage",props:{message:c,renderComponent:o,renderMarkdown:i},componentDef:n.IkpMessage}):e.jsxs(e.Fragment,{children:[e.jsx(g.EmbeddedChatMessagePart,{isLast:a?.id===c.id}),e.jsx(L,{})]})}),e.jsx(D,{}),e.jsx(P,{})]})]},c.id)),r&&a?.parts.length&&e.jsx(s.MessageWrapper,{message:{id:"___loader___",role:"assistant",parts:[{type:"text",text:"Thinking..."}]},children:e.jsx(u,{})})]})}})}function H(){return e.jsxs(s.IntroMessageWrapper,{children:[e.jsxs(s.MessageHeader,{children:[e.jsx(s.MessageAvatar,{children:e.jsxs(s.MessageAvatarContent,{children:[e.jsx(s.MessageAvatarFallback,{}),e.jsx(s.MessageAvatarImage,{})]})}),e.jsx(s.MessageName,{})]}),e.jsxs(s.MessageContentWrapper,{children:[e.jsx(s.MessageContent,{children:e.jsx(g.EmbeddedChatMessagePart,{isLast:!1})}),e.jsxs(s.Disclaimer,{children:[e.jsx(s.DisclaimerLabel,{}),e.jsx(s.DisclaimerTrigger,{}),e.jsxs(s.DisclaimerContent,{children:[e.jsx(s.DisclaimerText,{}),e.jsx(s.DisclaimerArrow,{})]})]}),e.jsxs(s.ExampleQuestions,{children:[e.jsx(s.ExampleQuestionsLabel,{}),e.jsx(s.ExampleQuestionsList,{children:n=>n.map(t=>e.jsx(s.ExampleQuestion,{children:e.jsx(s.ExampleQuestionButton,{question:t})},t))})]})]})]})}function u(){return e.jsxs(s.MessageHeader,{children:[e.jsx(s.MessageAvatar,{children:e.jsxs(s.MessageAvatarContent,{children:[e.jsx(s.MessageAvatarFallback,{}),e.jsx(s.MessageAvatarImage,{})]})}),e.jsx(s.MessageName,{})]})}function D(){return e.jsxs(s.MessageAttachments,{children:[e.jsx(s.MessageAttachmentsList,{children:n=>n.map(t=>e.jsxs(s.MessageAttachmentsItem,{attachment:t,children:[e.jsx(s.MessageAttachmentsItemIcon,{}),e.jsx(s.MessageAttachmentsItemTitle,{})]},t.id))}),e.jsx(s.MessageAttachmentsPreview,{children:e.jsx(j.PortalWithTheme,{children:e.jsx(s.MessageAttachmentsPreviewOverlay,{children:e.jsxs(s.MessageAttachmentsPreviewContent,{children:[e.jsx(s.MessageAttachmentsPreviewHeader,{}),e.jsx(s.MessageAttachmentsPreviewClose,{}),e.jsx(s.MessageAttachmentsPreviewBody,{})]})})})})]})}function P(){return e.jsxs(s.MessageToolbar,{children:[e.jsx(s.MessageAnnotationActions,{children:n=>n.map((t,r)=>e.jsx(s.MessageAnnotationAction,{action:t},`action-${r}`))}),e.jsx(s.MessageAction,{action:"copy"}),e.jsx(s.MessageAction,{action:"upvote"}),e.jsx(s.MessageAction,{action:"downvote"})]})}function L(){return e.jsxs(s.MessageSources,{children:[e.jsx(s.MessageSourcesHeader,{}),e.jsx(s.MessageSourcesList,{children:n=>n.map((t,r)=>e.jsxs(s.MessageSourceItem,{href:t.url,source:t,children:[e.jsx(s.MessageSourceItemBreadcrumbs,{children:t.breadcrumbs?.map(a=>e.jsxs(x.Fragment,{children:[a,e.jsx(s.MessageSourceItemBreadcrumbIcon,{})]},a))}),e.jsx(s.MessageSourceItemIcon,{}),e.jsx(s.MessageSourceItemTitle,{}),e.jsx(s.MessageSourceItemTag,{}),e.jsx(s.MessageSourceItemDescription,{children:a=>a.map((o,i)=>e.jsx(s.MessageSourceItemDescriptionPart,{part:o},`part-${i}`))}),e.jsx(s.MessageSourceItemIndicator,{})]},r))})]})}function W(){return e.jsxs(s.Footer,{children:[e.jsx(q,{}),e.jsx(_,{})]})}function q(){return e.jsxs(s.InputFieldset,{children:[e.jsxs(s.InputGroup,{children:[e.jsx(s.Input,{}),e.jsx(s.SendButton,{children:e.jsx(s.SendButtonIcon,{})})]}),e.jsxs(s.AttachmentsBar,{children:[e.jsx(s.AttachmentsBarList,{children:n=>n.map(t=>e.jsxs(s.AttachmentsBarAttachment,{attachment:t,children:[e.jsx(s.AttachmentsBarAttachmentIcon,{}),e.jsx(s.AttachmentsBarAttachmentTitle,{}),e.jsx(s.AttachmentsBarAttachmentDelete,{})]},t.id))}),e.jsxs(s.AttachmentsBarActions,{children:[e.jsxs(s.AttachmentsBarInfoTip,{children:[e.jsx(s.AttachmentsBarInfoTipIcon,{}),e.jsx(s.AttachmentsBarInfoTipText,{})]}),e.jsx(s.AttachmentsBarInputs,{children:n=>n.map(t=>e.jsx(s.AttachmentsBarInput,{input:t,children:t.displayName},t.id))})]}),e.jsx(j.PortalWithTheme,{children:e.jsx(s.AttachmentsBarModal,{children:e.jsx(s.AttachmentsBarModalOverlay,{children:e.jsxs(s.AttachmentsBarModalContent,{children:[e.jsxs(s.AttachmentsBarModalHeader,{children:[e.jsx(s.AttachmentsBarModalHeading,{}),e.jsx(s.AttachmentsBarModalDescription,{}),e.jsx(s.AttachmentsBarModalHelp,{})]}),e.jsx(s.AttachmentsBarModalClose,{}),e.jsx(s.AttachmentsBarModalBody,{children:e.jsxs(s.AttachmentsBarForm,{children:[e.jsxs(s.AttachmentsBarFormTitle,{children:[e.jsx(s.AttachmentsBarFormTitleLabel,{}),e.jsx(s.AttachmentsBarFormTitleInput,{}),e.jsx(s.AttachmentsBarFormTitleError,{})]}),e.jsxs(s.AttachmentsBarFormContent,{children:[e.jsx(s.AttachmentsBarFormContentLabel,{}),e.jsx(s.AttachmentsBarFormContentInput,{}),e.jsx(s.AttachmentsBarFormContentError,{})]}),e.jsx(s.AttachmentsBarFormSubmitButton,{})]})})]})})})})]})]})}function _(){return e.jsxs(s.ActionBar,{children:[e.jsxs(s.TaglineContainer,{children:[e.jsx(s.TaglineText,{}),e.jsx(s.TaglineLogo,{}),e.jsx(s.TaglineBrandName,{})]}),e.jsxs(s.Actions,{children:[e.jsx(s.HelpActions,{children:({pinned:n,unpinned:t})=>e.jsxs(e.Fragment,{children:[n.map(r=>e.jsx(s.HelpAction,{action:r},r.name)),t.length>0&&e.jsx(s.HelpActionsTrigger,{}),e.jsxs(s.HelpActionsMenu,{children:[e.jsx(s.HelpActionsMenuArrow,{}),t.map(r=>e.jsxs(s.HelpActionsMenuItem,{action:r,children:[e.jsx(s.HelpActionsMenuItemIcon,{action:r}),r.name]},r.name))]})]})}),e.jsxs(s.ChatAction,{action:"copy",children:[e.jsx(s.ChatActionLabel,{action:"copy"}),e.jsx(s.ChatActionFeedback,{action:"copy"})]}),e.jsx(s.ChatAction,{action:"clear"}),e.jsx(s.ChatAction,{action:"stop"})]})]})}function V(){return e.jsx(j.PortalWithTheme,{children:e.jsx(s.FeedbackModal,{children:e.jsx(s.FeedbackModalOverlay,{children:e.jsxs(s.FeedbackModalContent,{children:[e.jsx(s.FeedbackModalHeader,{}),e.jsx(s.FeedbackModalClose,{}),e.jsx(s.FeedbackModalBody,{children:e.jsxs(s.FeedbackForm,{children:[e.jsxs(s.FeedbackItem,{name:"unrelated_response",children:[e.jsx(s.FeedbackItemCheckbox,{children:e.jsx(s.FeedbackItemCheckboxIndicator,{})}),e.jsx(s.FeedbackItemLabel,{}),e.jsx(s.FeedbackItemDescription,{})]}),e.jsxs(s.FeedbackItem,{name:"inaccurate_statement",children:[e.jsx(s.FeedbackItemCheckbox,{children:e.jsx(s.FeedbackItemCheckboxIndicator,{})}),e.jsx(s.FeedbackItemLabel,{}),e.jsx(s.FeedbackItemDescription,{})]}),e.jsxs(s.FeedbackItem,{name:"inaccurate_code_snippet",children:[e.jsx(s.FeedbackItemCheckbox,{children:e.jsx(s.FeedbackItemCheckboxIndicator,{})}),e.jsx(s.FeedbackItemLabel,{}),e.jsx(s.FeedbackItemDescription,{})]}),e.jsxs(s.FeedbackItem,{name:"irrelevant_citations",children:[e.jsx(s.FeedbackItemCheckbox,{children:e.jsx(s.FeedbackItemCheckboxIndicator,{})}),e.jsx(s.FeedbackItemLabel,{})]}),e.jsx(s.FeedbackSubmitButton,{})]})})]})})})})}function O(){return e.jsxs(s.FormWrapper,{children:[e.jsx(s.FormClose,{}),e.jsxs(s.Form,{children:[e.jsxs(s.FormHeader,{children:[e.jsx(s.FormHeading,{}),e.jsx(s.FormDescription,{})]}),e.jsx(s.FormContent,{children:n=>e.jsxs(e.Fragment,{children:[n.map((t,r)=>e.jsxs(s.FormField,{field:t,autoFocus:r===0,children:[e.jsx(s.FormFieldLabel,{}),t.inputType==="text"&&e.jsx(s.FormFieldText,{}),t.inputType==="email"&&e.jsx(s.FormFieldEmail,{}),t.inputType==="file"&&e.jsx(s.FormFieldFile,{}),t.inputType==="textarea"&&e.jsx(s.FormFieldTextArea,{}),t.inputType==="checkbox"&&e.jsx(s.FormFieldCheckbox,{children:e.jsx(s.FormFieldCheckboxIndicator,{})}),t.inputType==="select"&&e.jsxs(s.FormFieldSelect,{children:[e.jsxs(s.FormFieldSelectTrigger,{children:[e.jsx(s.FormFieldSelectValue,{}),e.jsx(s.FormFieldSelectIcon,{})]}),e.jsx(s.FormFieldSelectContent,{children:e.jsx(s.FormFieldSelectViewport,{children:t.items.map(a=>e.jsxs(s.FormFieldSelectItem,{value:a.value,children:[e.jsx(s.FormFieldSelectItemText,{children:a.label}),e.jsx(s.FormFieldSelectItemIndicator,{})]},a.value))})})]}),e.jsx(s.FormFieldError,{})]},t.name)),e.jsx(s.FormError,{})]})}),e.jsxs(s.FormFooter,{children:[e.jsx(s.FormCancel,{}),e.jsx(s.FormSubmit,{})]})]}),e.jsxs(s.FormSuccess,{children:[e.jsx(s.FormSuccessHeading,{}),e.jsx(s.FormSuccessMessage,{}),e.jsx(s.FormSuccessButton,{})]})]})}exports.InkeepEmbeddedChat=w;exports.InkeepEmbeddedChatImpl=b;exports.InkeepEmbeddedChatImplContent=I;exports.InkeepEmbeddedChatProvider=A;
|
|
1
|
+
"use client";"use strict";Object.defineProperty(exports,Symbol.toStringTag,{value:"Module"});const e=require("react/jsx-runtime"),x=require("react"),s=require("../styled/components/embedded-chat.cjs"),h=require("../styled/components/modal.cjs"),M=require("../styled/components/shadow.cjs"),g=require("../styled/components/message.cjs"),p=require("../primitives/providers/config-provider.cjs"),C=require("../primitives/providers/root-provider.cjs"),k=require("../primitives/providers/widget-provider.cjs"),T=require("../primitives/components/modal/modal-provider.cjs"),F=require("../primitives/utils/misc.cjs"),j=require("../primitives/atoms/portal-with-theme.cjs"),B=require("../primitives/atoms/error-boundary.cjs"),S=require("./modal.cjs"),v=require("./widget-toggle.cjs");function w(n){const{baseSettings:t,aiChatSettings:r}=n;return e.jsx(B.ErrorBoundary,{children:e.jsx(M.Shadow,{wrapperStyles:{height:"inherit",width:"inherit"},children:e.jsx(C.RootProvider,{config:{baseSettings:t,aiChatSettings:r},componentType:p.WebWidgetInteractionType.EmbeddedChat,children:e.jsx(b,{...n})})})})}function A(n){const{children:t,onToggleView:r,isHidden:a,shouldAutoFocusInput:o=!r}=n;return e.jsx(s.Provider,{isHidden:a,shouldAutoFocusInput:o,children:t})}function b(n){return e.jsx(A,{...n,children:e.jsx(I,{...n})})}function I(n){const{onToggleView:t,variant:r,header:a=y}=n,o=T.useModal(),i=k.useWidget(),c=o&&!i?S.ModalContent:x.Fragment;return e.jsx(c,{children:e.jsxs(s.Wrapper,{variant:r??(t?"no-shadow":"container-with-shadow"),"data-composite":F.dataAttr(!!n.onToggleView||o?.isOpen),children:[e.jsxs(s.Root,{children:[a&&e.jsx(a,{...n}),e.jsx(f,{}),e.jsx(W,{})]}),e.jsx(V,{}),e.jsx(O,{})]})})}const y=n=>{const{onToggleView:t,askAILabel:r,searchLabel:a}=n,o=!!t;return e.jsx(s.Header,{"data-show-toolbar":F.dataAttr(o),children:o?e.jsxs(s.HeaderToolbar,{children:[e.jsxs(s.HeaderToolbarWrapper,{children:[e.jsx(s.ToolbarHeader,{}),e.jsxs(s.Disclaimer,{children:[e.jsx(s.DisclaimerTrigger,{}),e.jsxs(s.DisclaimerContent,{side:"bottom",align:"start",children:[e.jsx(s.DisclaimerText,{}),e.jsx(s.DisclaimerArrow,{})]})]})]}),e.jsx(v.WidgetToggle,{onToggleView:t,askAILabel:r,searchLabel:a,view:"chat"}),e.jsx(h.Close,{})]}):e.jsx(h.Close,{})})};function f(){return e.jsx(s.Content,{children:e.jsxs(s.ContentScrollArea,{children:[e.jsx(s.ContentScrollAreaViewport,{children:e.jsx(E,{})}),e.jsx(s.ContentScrollAreaScrollbar,{children:e.jsx(s.ContentScrollAreaThumb,{})}),e.jsx(s.ContentScrollAreaCorner,{})]})})}function E(){const{aiChatSettings:{components:n}}=p.useInkeepConfig();return e.jsx(s.Messages,{children:({messages:t,isLoading:r})=>{const a=t.at(-1),o=(c,m)=>{const d=n?.[c];if(!d)return console.warn(`Component "${c}" not found in components config`),null;try{if(typeof d=="function"&&d.length<=1)return x.createElement(d,m);const l=d(m,document.createElement("div"),null);return x.isValidElement(l)||typeof l=="string"?l:null}catch(l){return console.error(`🔍 [renderComponent] Error rendering component "${c}":`,l),null}},i=c=>e.jsx(s.Markdown,{text:c});return e.jsxs(e.Fragment,{children:[e.jsx(H,{}),t.map(c=>e.jsxs(s.MessageWrapper,{message:c,children:[e.jsx(u,{}),e.jsxs(s.MessageContentWrapper,{children:[e.jsx(s.MessageContent,{children:n?.IkpMessage?e.jsx(s.DynamicComponent,{name:"IkpMessage",props:{message:c,renderComponent:o,renderMarkdown:i},componentDef:n.IkpMessage}):e.jsxs(e.Fragment,{children:[e.jsx(g.EmbeddedChatMessagePart,{isLast:a?.id===c.id}),e.jsx(L,{})]})}),e.jsx(D,{}),e.jsx(P,{})]})]},c.id)),r&&a?.parts.length&&e.jsxs(s.MessageWrapper,{message:{id:"___loader___",role:"assistant",parts:[{type:"text",text:"Thinking..."}]},children:[e.jsx(u,{}),e.jsx(s.MessageLoading,{})]})]})}})}function H(){return e.jsxs(s.IntroMessageWrapper,{children:[e.jsxs(s.MessageHeader,{children:[e.jsx(s.MessageAvatar,{children:e.jsxs(s.MessageAvatarContent,{children:[e.jsx(s.MessageAvatarFallback,{}),e.jsx(s.MessageAvatarImage,{})]})}),e.jsx(s.MessageName,{})]}),e.jsxs(s.MessageContentWrapper,{children:[e.jsx(s.MessageContent,{children:e.jsx(g.EmbeddedChatMessagePart,{isLast:!1})}),e.jsxs(s.Disclaimer,{children:[e.jsx(s.DisclaimerLabel,{}),e.jsx(s.DisclaimerTrigger,{}),e.jsxs(s.DisclaimerContent,{children:[e.jsx(s.DisclaimerText,{}),e.jsx(s.DisclaimerArrow,{})]})]}),e.jsxs(s.ExampleQuestions,{children:[e.jsx(s.ExampleQuestionsLabel,{}),e.jsx(s.ExampleQuestionsList,{children:n=>n.map(t=>e.jsx(s.ExampleQuestion,{children:e.jsx(s.ExampleQuestionButton,{question:t})},t))})]})]})]})}function u(){return e.jsxs(s.MessageHeader,{children:[e.jsx(s.MessageAvatar,{children:e.jsxs(s.MessageAvatarContent,{children:[e.jsx(s.MessageAvatarFallback,{}),e.jsx(s.MessageAvatarImage,{})]})}),e.jsx(s.MessageName,{})]})}function D(){return e.jsxs(s.MessageAttachments,{children:[e.jsx(s.MessageAttachmentsList,{children:n=>n.map(t=>e.jsxs(s.MessageAttachmentsItem,{attachment:t,children:[e.jsx(s.MessageAttachmentsItemIcon,{}),e.jsx(s.MessageAttachmentsItemTitle,{})]},t.id))}),e.jsx(s.MessageAttachmentsPreview,{children:e.jsx(j.PortalWithTheme,{children:e.jsx(s.MessageAttachmentsPreviewOverlay,{children:e.jsxs(s.MessageAttachmentsPreviewContent,{children:[e.jsx(s.MessageAttachmentsPreviewHeader,{}),e.jsx(s.MessageAttachmentsPreviewClose,{}),e.jsx(s.MessageAttachmentsPreviewBody,{})]})})})})]})}function P(){return e.jsxs(s.MessageToolbar,{children:[e.jsx(s.MessageAnnotationActions,{children:n=>n.map((t,r)=>e.jsx(s.MessageAnnotationAction,{action:t},`action-${r}`))}),e.jsx(s.MessageAction,{action:"copy"}),e.jsx(s.MessageAction,{action:"upvote"}),e.jsx(s.MessageAction,{action:"downvote"})]})}function L(){return e.jsxs(s.MessageSources,{children:[e.jsx(s.MessageSourcesHeader,{}),e.jsx(s.MessageSourcesList,{children:n=>n.map((t,r)=>e.jsxs(s.MessageSourceItem,{href:t.url,source:t,children:[e.jsx(s.MessageSourceItemBreadcrumbs,{children:t.breadcrumbs?.map(a=>e.jsxs(x.Fragment,{children:[a,e.jsx(s.MessageSourceItemBreadcrumbIcon,{})]},a))}),e.jsx(s.MessageSourceItemIcon,{}),e.jsx(s.MessageSourceItemTitle,{}),e.jsx(s.MessageSourceItemTag,{}),e.jsx(s.MessageSourceItemDescription,{children:a=>a.map((o,i)=>e.jsx(s.MessageSourceItemDescriptionPart,{part:o},`part-${i}`))}),e.jsx(s.MessageSourceItemIndicator,{})]},r))})]})}function W(){return e.jsxs(s.Footer,{children:[e.jsx(q,{}),e.jsx(_,{})]})}function q(){return e.jsxs(s.InputFieldset,{children:[e.jsxs(s.InputGroup,{children:[e.jsx(s.Input,{}),e.jsx(s.SendButton,{children:e.jsx(s.SendButtonIcon,{})})]}),e.jsxs(s.AttachmentsBar,{children:[e.jsx(s.AttachmentsBarList,{children:n=>n.map(t=>e.jsxs(s.AttachmentsBarAttachment,{attachment:t,children:[e.jsx(s.AttachmentsBarAttachmentIcon,{}),e.jsx(s.AttachmentsBarAttachmentTitle,{}),e.jsx(s.AttachmentsBarAttachmentDelete,{})]},t.id))}),e.jsxs(s.AttachmentsBarActions,{children:[e.jsxs(s.AttachmentsBarInfoTip,{children:[e.jsx(s.AttachmentsBarInfoTipIcon,{}),e.jsx(s.AttachmentsBarInfoTipText,{})]}),e.jsx(s.AttachmentsBarInputs,{children:n=>n.map(t=>e.jsx(s.AttachmentsBarInput,{input:t,children:t.displayName},t.id))})]}),e.jsx(j.PortalWithTheme,{children:e.jsx(s.AttachmentsBarModal,{children:e.jsx(s.AttachmentsBarModalOverlay,{children:e.jsxs(s.AttachmentsBarModalContent,{children:[e.jsxs(s.AttachmentsBarModalHeader,{children:[e.jsx(s.AttachmentsBarModalHeading,{}),e.jsx(s.AttachmentsBarModalDescription,{}),e.jsx(s.AttachmentsBarModalHelp,{})]}),e.jsx(s.AttachmentsBarModalClose,{}),e.jsx(s.AttachmentsBarModalBody,{children:e.jsxs(s.AttachmentsBarForm,{children:[e.jsxs(s.AttachmentsBarFormTitle,{children:[e.jsx(s.AttachmentsBarFormTitleLabel,{}),e.jsx(s.AttachmentsBarFormTitleInput,{}),e.jsx(s.AttachmentsBarFormTitleError,{})]}),e.jsxs(s.AttachmentsBarFormContent,{children:[e.jsx(s.AttachmentsBarFormContentLabel,{}),e.jsx(s.AttachmentsBarFormContentInput,{}),e.jsx(s.AttachmentsBarFormContentError,{})]}),e.jsx(s.AttachmentsBarFormSubmitButton,{})]})})]})})})})]})]})}function _(){return e.jsxs(s.ActionBar,{children:[e.jsxs(s.TaglineContainer,{children:[e.jsx(s.TaglineText,{}),e.jsx(s.TaglineLogo,{}),e.jsx(s.TaglineBrandName,{})]}),e.jsxs(s.Actions,{children:[e.jsx(s.HelpActions,{children:({pinned:n,unpinned:t})=>e.jsxs(e.Fragment,{children:[n.map(r=>e.jsx(s.HelpAction,{action:r},r.name)),t.length>0&&e.jsx(s.HelpActionsTrigger,{}),e.jsxs(s.HelpActionsMenu,{children:[e.jsx(s.HelpActionsMenuArrow,{}),t.map(r=>e.jsxs(s.HelpActionsMenuItem,{action:r,children:[e.jsx(s.HelpActionsMenuItemIcon,{action:r}),r.name]},r.name))]})]})}),e.jsxs(s.ChatAction,{action:"copy",children:[e.jsx(s.ChatActionLabel,{action:"copy"}),e.jsx(s.ChatActionFeedback,{action:"copy"})]}),e.jsx(s.ChatAction,{action:"clear"}),e.jsx(s.ChatAction,{action:"stop"})]})]})}function V(){return e.jsx(j.PortalWithTheme,{children:e.jsx(s.FeedbackModal,{children:e.jsx(s.FeedbackModalOverlay,{children:e.jsxs(s.FeedbackModalContent,{children:[e.jsx(s.FeedbackModalHeader,{}),e.jsx(s.FeedbackModalClose,{}),e.jsx(s.FeedbackModalBody,{children:e.jsxs(s.FeedbackForm,{children:[e.jsxs(s.FeedbackItem,{name:"unrelated_response",children:[e.jsx(s.FeedbackItemCheckbox,{children:e.jsx(s.FeedbackItemCheckboxIndicator,{})}),e.jsx(s.FeedbackItemLabel,{}),e.jsx(s.FeedbackItemDescription,{})]}),e.jsxs(s.FeedbackItem,{name:"inaccurate_statement",children:[e.jsx(s.FeedbackItemCheckbox,{children:e.jsx(s.FeedbackItemCheckboxIndicator,{})}),e.jsx(s.FeedbackItemLabel,{}),e.jsx(s.FeedbackItemDescription,{})]}),e.jsxs(s.FeedbackItem,{name:"inaccurate_code_snippet",children:[e.jsx(s.FeedbackItemCheckbox,{children:e.jsx(s.FeedbackItemCheckboxIndicator,{})}),e.jsx(s.FeedbackItemLabel,{}),e.jsx(s.FeedbackItemDescription,{})]}),e.jsxs(s.FeedbackItem,{name:"irrelevant_citations",children:[e.jsx(s.FeedbackItemCheckbox,{children:e.jsx(s.FeedbackItemCheckboxIndicator,{})}),e.jsx(s.FeedbackItemLabel,{})]}),e.jsx(s.FeedbackSubmitButton,{})]})})]})})})})}function O(){return e.jsxs(s.FormWrapper,{children:[e.jsx(s.FormClose,{}),e.jsxs(s.Form,{children:[e.jsxs(s.FormHeader,{children:[e.jsx(s.FormHeading,{}),e.jsx(s.FormDescription,{})]}),e.jsx(s.FormContent,{children:n=>e.jsxs(e.Fragment,{children:[n.map((t,r)=>e.jsxs(s.FormField,{field:t,autoFocus:r===0,children:[e.jsx(s.FormFieldLabel,{}),t.inputType==="text"&&e.jsx(s.FormFieldText,{}),t.inputType==="email"&&e.jsx(s.FormFieldEmail,{}),t.inputType==="file"&&e.jsx(s.FormFieldFile,{}),t.inputType==="textarea"&&e.jsx(s.FormFieldTextArea,{}),t.inputType==="checkbox"&&e.jsx(s.FormFieldCheckbox,{children:e.jsx(s.FormFieldCheckboxIndicator,{})}),t.inputType==="select"&&e.jsxs(s.FormFieldSelect,{children:[e.jsxs(s.FormFieldSelectTrigger,{children:[e.jsx(s.FormFieldSelectValue,{}),e.jsx(s.FormFieldSelectIcon,{})]}),e.jsx(s.FormFieldSelectContent,{children:e.jsx(s.FormFieldSelectViewport,{children:t.items.map(a=>e.jsxs(s.FormFieldSelectItem,{value:a.value,children:[e.jsx(s.FormFieldSelectItemText,{children:a.label}),e.jsx(s.FormFieldSelectItemIndicator,{})]},a.value))})})]}),e.jsx(s.FormFieldError,{})]},t.name)),e.jsx(s.FormError,{})]})}),e.jsxs(s.FormFooter,{children:[e.jsx(s.FormCancel,{}),e.jsx(s.FormSubmit,{})]})]}),e.jsxs(s.FormSuccess,{children:[e.jsx(s.FormSuccessHeading,{}),e.jsx(s.FormSuccessMessage,{}),e.jsx(s.FormSuccessButton,{})]})]})}exports.InkeepEmbeddedChat=w;exports.InkeepEmbeddedChatImpl=b;exports.InkeepEmbeddedChatImplContent=I;exports.InkeepEmbeddedChatProvider=A;
|