@inkeep/agents-ui 0.14.12 → 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/primitives/components/embedded-chat/use-inkeep-chat.cjs +1 -1
- package/dist/primitives/components/embedded-chat/use-inkeep-chat.js +21 -18
- package/dist/primitives/components/embedded-chat/use-stream-processor.cjs +1 -1
- package/dist/primitives/components/embedded-chat/use-stream-processor.js +72 -106
- 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/types/types.d.cts +1 -1
- package/dist/types/types.d.ts +1 -1
- 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"),q=`Hmm..
|
|
2
2
|
|
|
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,
|
|
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;
|
|
@@ -12,21 +12,21 @@ 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.`,
|
|
15
|
+
It seems I might be having some issues right now. Please clear the chat and try again.`, ye = () => {
|
|
16
16
|
const { baseSettings: f, aiChatSettings: a } = te(), [s = "", v] = ie({
|
|
17
17
|
prop: a.conversationId,
|
|
18
18
|
defaultProp: a.conversationId ?? ""
|
|
19
|
-
}), { logEvent: i } = oe(), { setConversationId: F,
|
|
19
|
+
}), { logEvent: i } = oe(), { setConversationId: F, emitToParent: k } = ce(), [o, m] = r(""), D = (e) => m(e.target.value), {
|
|
20
20
|
/* shouldBypassCaptcha, */
|
|
21
21
|
filters: I
|
|
22
22
|
} = f, {
|
|
23
|
-
onInputMessageChange:
|
|
23
|
+
onInputMessageChange: N,
|
|
24
24
|
filters: C,
|
|
25
|
-
agentUrl:
|
|
25
|
+
agentUrl: A,
|
|
26
26
|
context: R,
|
|
27
27
|
headers: B,
|
|
28
28
|
apiKey: E
|
|
29
|
-
} = a,
|
|
29
|
+
} = a, P = (e) => {
|
|
30
30
|
switch (e.code) {
|
|
31
31
|
case 400:
|
|
32
32
|
return e.message;
|
|
@@ -35,16 +35,16 @@ It seems I might be having some issues right now. Please clear the chat and try
|
|
|
35
35
|
default:
|
|
36
36
|
return me;
|
|
37
37
|
}
|
|
38
|
-
}, [
|
|
38
|
+
}, [T, K] = r({}), [U, u] = r([]), [W, y] = r(null), {
|
|
39
39
|
messages: l,
|
|
40
40
|
sendMessage: $,
|
|
41
41
|
status: b,
|
|
42
|
-
setMessages:
|
|
42
|
+
setMessages: w,
|
|
43
43
|
stop: z,
|
|
44
44
|
error: p
|
|
45
45
|
} = X({
|
|
46
46
|
transport: new Y({
|
|
47
|
-
api:
|
|
47
|
+
api: A,
|
|
48
48
|
headers: {
|
|
49
49
|
...E ? { Authorization: `Bearer ${E}` } : {},
|
|
50
50
|
...B
|
|
@@ -53,6 +53,9 @@ It seems I might be having some issues right now. Please clear the chat and try
|
|
|
53
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,18 +70,18 @@ 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
|
-
return t && (t.parts = [{ type: "text", text:
|
|
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
80
|
p && d(p);
|
|
78
81
|
}, [p]);
|
|
79
82
|
const G = () => d(null), M = Z(null);
|
|
80
83
|
x(() => {
|
|
81
|
-
|
|
84
|
+
N?.(o);
|
|
82
85
|
}, [o]);
|
|
83
86
|
const J = (e) => {
|
|
84
87
|
e.key === "Enter" && !e.shiftKey && !g && !e.nativeEvent.isComposing && (e.preventDefault(), h());
|
|
@@ -112,7 +115,7 @@ It seems I might be having some issues right now. Please clear the chat and try
|
|
|
112
115
|
}, Q = () => {
|
|
113
116
|
z();
|
|
114
117
|
}, _ = () => {
|
|
115
|
-
G(),
|
|
118
|
+
G(), w([]), v(""), K({}), u([]), y(null), i({
|
|
116
119
|
eventName: "chat_clear_button_clicked",
|
|
117
120
|
properties: {
|
|
118
121
|
conversationId: s
|
|
@@ -133,18 +136,18 @@ It seems I might be having some issues right now. Please clear the chat and try
|
|
|
133
136
|
}
|
|
134
137
|
})), {
|
|
135
138
|
messages: l,
|
|
136
|
-
isLoading:
|
|
139
|
+
isLoading: S,
|
|
137
140
|
isStreaming: H,
|
|
138
141
|
error: q,
|
|
139
142
|
setError: d,
|
|
140
143
|
isSubmitDisabled: g,
|
|
141
144
|
input: o,
|
|
142
|
-
handleInputChange:
|
|
145
|
+
handleInputChange: D,
|
|
143
146
|
handleInputKeyDown: J,
|
|
144
147
|
handleSubmit: h,
|
|
145
148
|
stop: Q,
|
|
146
149
|
clear: _,
|
|
147
|
-
messageButtons:
|
|
150
|
+
messageButtons: T,
|
|
148
151
|
isEmpty: l.length === 0,
|
|
149
152
|
inputRef: M,
|
|
150
153
|
isMobile: O,
|
|
@@ -152,12 +155,12 @@ It seems I might be having some issues right now. Please clear the chat and try
|
|
|
152
155
|
messageAttachments: U,
|
|
153
156
|
setMessageAttachments: u,
|
|
154
157
|
selectedWorkflow: W,
|
|
155
|
-
setSelectedWorkflow:
|
|
158
|
+
setSelectedWorkflow: y,
|
|
156
159
|
isNewChat: L,
|
|
157
160
|
conversationId: s
|
|
158
161
|
};
|
|
159
162
|
};
|
|
160
163
|
export {
|
|
161
164
|
me as DEFAULT_ERROR_MESSAGE,
|
|
162
|
-
|
|
165
|
+
ye as useInkeepChat
|
|
163
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,135 +1,101 @@
|
|
|
1
1
|
"use client";
|
|
2
|
-
import { useState as p, useRef as
|
|
3
|
-
import { DEFAULT_ERROR_MESSAGE as
|
|
4
|
-
import {
|
|
5
|
-
|
|
6
|
-
|
|
7
|
-
|
|
8
|
-
|
|
9
|
-
|
|
10
|
-
|
|
11
|
-
|
|
12
|
-
|
|
13
|
-
|
|
14
|
-
|
|
15
|
-
|
|
16
|
-
|
|
17
|
-
|
|
18
|
-
|
|
19
|
-
|
|
20
|
-
|
|
21
|
-
}), n.push({
|
|
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({
|
|
22
21
|
type: "summary-group",
|
|
23
|
-
summaries: [...
|
|
24
|
-
groupKey:
|
|
25
|
-
}),
|
|
22
|
+
summaries: [...o],
|
|
23
|
+
groupKey: s
|
|
24
|
+
}), o = [];
|
|
26
25
|
}
|
|
27
26
|
};
|
|
28
|
-
for (const
|
|
29
|
-
if (
|
|
30
|
-
|
|
31
|
-
else if (
|
|
32
|
-
t.trim() && (
|
|
33
|
-
else if (
|
|
34
|
-
t.trim() && (
|
|
35
|
-
const
|
|
36
|
-
if (
|
|
37
|
-
switch (
|
|
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) {
|
|
38
37
|
case "completion":
|
|
39
|
-
|
|
40
|
-
"unknown",
|
|
41
|
-
// No agent ID available in current structure
|
|
42
|
-
1
|
|
43
|
-
// No iteration available in current structure
|
|
44
|
-
), o(!0);
|
|
45
|
-
break;
|
|
46
|
-
case "agent_initializing":
|
|
47
|
-
A(
|
|
48
|
-
"unknown",
|
|
49
|
-
// No session ID available in current structure
|
|
50
|
-
"unknown"
|
|
51
|
-
// No graph ID available in current structure
|
|
52
|
-
);
|
|
38
|
+
a(!0);
|
|
53
39
|
break;
|
|
54
40
|
case "error": {
|
|
55
|
-
|
|
56
|
-
const
|
|
57
|
-
console.warn("Data operation 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);
|
|
58
44
|
break;
|
|
59
45
|
}
|
|
60
46
|
default: {
|
|
61
|
-
const { type:
|
|
62
|
-
|
|
47
|
+
const { type: n, label: I } = s;
|
|
48
|
+
o.push({ type: n, label: I });
|
|
63
49
|
break;
|
|
64
50
|
}
|
|
65
51
|
}
|
|
66
|
-
} else if (
|
|
67
|
-
if (
|
|
68
|
-
const
|
|
69
|
-
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
|
|
70
56
|
};
|
|
71
|
-
t += ` ^${
|
|
57
|
+
t += ` ^${n?.title || s.name}^`;
|
|
72
58
|
} else
|
|
73
|
-
t.trim() && (
|
|
74
|
-
|
|
75
|
-
|
|
76
|
-
|
|
77
|
-
|
|
78
|
-
e.data.artifactType || "unknown",
|
|
79
|
-
e.data.artifactSummary || {},
|
|
80
|
-
// Use artifactSummary as summaryData
|
|
81
|
-
{},
|
|
82
|
-
// fullData not available in current structure
|
|
83
|
-
{ name: e.data.name, description: e.data.description }
|
|
84
|
-
// Use available fields as metadata
|
|
85
|
-
);
|
|
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(() => {
|
|
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(() => {
|
|
98
64
|
if (S.current === i)
|
|
99
65
|
return;
|
|
100
66
|
S.current = i;
|
|
101
|
-
const { processed:
|
|
102
|
-
|
|
103
|
-
const
|
|
104
|
-
return !
|
|
105
|
-
})) &&
|
|
106
|
-
}, [
|
|
107
|
-
const
|
|
108
|
-
const
|
|
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(
|
|
109
75
|
(c) => !c.isCompleted
|
|
110
|
-
),
|
|
111
|
-
|
|
112
|
-
}, [
|
|
113
|
-
|
|
114
|
-
if (!
|
|
115
|
-
|
|
76
|
+
), o = e > 1e3 && !t;
|
|
77
|
+
g(o);
|
|
78
|
+
}, [x]);
|
|
79
|
+
R(() => {
|
|
80
|
+
if (!f) {
|
|
81
|
+
g(!1);
|
|
116
82
|
return;
|
|
117
83
|
}
|
|
118
|
-
if (!(
|
|
119
|
-
|
|
84
|
+
if (!(u.length > 0)) {
|
|
85
|
+
g(!1);
|
|
120
86
|
return;
|
|
121
87
|
}
|
|
122
|
-
const t = setInterval(
|
|
88
|
+
const t = setInterval(A, 200);
|
|
123
89
|
return () => clearInterval(t);
|
|
124
|
-
}, [
|
|
125
|
-
const
|
|
90
|
+
}, [f, A, u.length]);
|
|
91
|
+
const E = M(() => !(u.length > 0), [u.length]);
|
|
126
92
|
return {
|
|
127
|
-
processedParts:
|
|
128
|
-
summaryTimings:
|
|
129
|
-
shouldShowInitialLoading:
|
|
130
|
-
shouldShowStreamDelayLoading:
|
|
93
|
+
processedParts: u,
|
|
94
|
+
summaryTimings: y,
|
|
95
|
+
shouldShowInitialLoading: E,
|
|
96
|
+
shouldShowStreamDelayLoading: k
|
|
131
97
|
};
|
|
132
98
|
}
|
|
133
99
|
export {
|
|
134
|
-
|
|
100
|
+
z as useStreamProcessor
|
|
135
101
|
};
|
|
@@ -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;
|
|
@@ -1,140 +1,33 @@
|
|
|
1
1
|
"use client";
|
|
2
|
-
import { useRef as
|
|
3
|
-
import { useShadow as
|
|
4
|
-
function
|
|
5
|
-
const
|
|
6
|
-
|
|
7
|
-
|
|
8
|
-
|
|
2
|
+
import { useRef as c, useCallback as o } from "react";
|
|
3
|
+
import { useShadow as u } from "../atoms/shadow/context.js";
|
|
4
|
+
function v() {
|
|
5
|
+
const e = u()?.shadowHost, n = c(""), s = o((t) => {
|
|
6
|
+
n.current = t;
|
|
7
|
+
}, []), r = o(
|
|
8
|
+
(t, a) => {
|
|
9
|
+
if (!e) {
|
|
10
|
+
console.warn("useStreamingEvents: No host element available for parent event emission");
|
|
9
11
|
return;
|
|
10
12
|
}
|
|
11
|
-
const
|
|
12
|
-
|
|
13
|
-
|
|
14
|
-
|
|
15
|
-
|
|
16
|
-
|
|
13
|
+
const i = new CustomEvent(`ikp-${t}`, {
|
|
14
|
+
detail: {
|
|
15
|
+
...a,
|
|
16
|
+
conversationId: n.current,
|
|
17
|
+
timestamp: Date.now()
|
|
18
|
+
},
|
|
17
19
|
bubbles: !0,
|
|
18
|
-
// Allow event to bubble up
|
|
19
20
|
composed: !0
|
|
20
|
-
// Allow event to escape Shadow DOM boundary
|
|
21
|
-
});
|
|
22
|
-
r.dispatchEvent(a);
|
|
23
|
-
},
|
|
24
|
-
[r]
|
|
25
|
-
), m = o((t) => {
|
|
26
|
-
c.current = t;
|
|
27
|
-
}, []), l = o(
|
|
28
|
-
(t) => {
|
|
29
|
-
e({
|
|
30
|
-
kind: "text:delta",
|
|
31
|
-
data: { text: t }
|
|
32
|
-
});
|
|
33
|
-
},
|
|
34
|
-
[e]
|
|
35
|
-
), u = o(
|
|
36
|
-
(t, n, a) => {
|
|
37
|
-
e({
|
|
38
|
-
kind: "stream:error",
|
|
39
|
-
data: {
|
|
40
|
-
message: t,
|
|
41
|
-
agent: n,
|
|
42
|
-
severity: "error",
|
|
43
|
-
code: a
|
|
44
|
-
}
|
|
45
|
-
});
|
|
46
|
-
},
|
|
47
|
-
[e]
|
|
48
|
-
), g = o(
|
|
49
|
-
(t, n) => {
|
|
50
|
-
e({
|
|
51
|
-
kind: "agent:reasoning",
|
|
52
|
-
data: { agentId: t, parts: n }
|
|
53
|
-
});
|
|
54
|
-
},
|
|
55
|
-
[e]
|
|
56
|
-
), v = o(
|
|
57
|
-
(t, n, a) => {
|
|
58
|
-
e({
|
|
59
|
-
kind: "agent:generate",
|
|
60
|
-
data: { agentId: t, parts: n, generationType: a }
|
|
61
|
-
});
|
|
62
|
-
},
|
|
63
|
-
[e]
|
|
64
|
-
), f = o(
|
|
65
|
-
(t, n, a, i, s, d) => {
|
|
66
|
-
e({
|
|
67
|
-
kind: "tool:execution",
|
|
68
|
-
data: { agentId: t, toolName: n, args: a, result: i, toolId: s, duration: d }
|
|
69
|
-
});
|
|
70
|
-
},
|
|
71
|
-
[e]
|
|
72
|
-
), k = o(
|
|
73
|
-
(t, n, a, i) => {
|
|
74
|
-
e({
|
|
75
|
-
kind: "agent:transfer",
|
|
76
|
-
data: { fromAgent: t, targetAgent: n, reason: a, context: i }
|
|
77
|
-
});
|
|
78
|
-
},
|
|
79
|
-
[e]
|
|
80
|
-
), E = o(
|
|
81
|
-
(t, n, a, i, s) => {
|
|
82
|
-
e({
|
|
83
|
-
kind: "delegation:sent",
|
|
84
|
-
data: { delegationId: t, fromAgent: n, targetAgent: a, taskDescription: i, context: s }
|
|
85
|
-
});
|
|
86
|
-
},
|
|
87
|
-
[e]
|
|
88
|
-
), p = o(
|
|
89
|
-
(t, n, a, i) => {
|
|
90
|
-
e({
|
|
91
|
-
kind: "delegation:returned",
|
|
92
|
-
data: { delegationId: t, fromAgent: n, targetAgent: a, result: i }
|
|
93
|
-
});
|
|
94
|
-
},
|
|
95
|
-
[e]
|
|
96
|
-
), h = o(
|
|
97
|
-
(t, n, a, i, s, d, b) => {
|
|
98
|
-
e({
|
|
99
|
-
kind: "artifact:saved",
|
|
100
|
-
data: { artifactId: t, taskId: n, toolCallId: a, artifactType: i, summaryData: s, fullData: d, metadata: b }
|
|
101
|
-
});
|
|
102
|
-
},
|
|
103
|
-
[e]
|
|
104
|
-
), w = o(
|
|
105
|
-
(t, n) => {
|
|
106
|
-
e({
|
|
107
|
-
kind: "completion",
|
|
108
|
-
data: { agent: t, iteration: n }
|
|
109
|
-
});
|
|
110
|
-
},
|
|
111
|
-
[e]
|
|
112
|
-
), S = o(
|
|
113
|
-
(t, n) => {
|
|
114
|
-
e({
|
|
115
|
-
kind: "agent:initializing",
|
|
116
|
-
data: { sessionId: t, graphId: n }
|
|
117
21
|
});
|
|
22
|
+
e.dispatchEvent(i);
|
|
118
23
|
},
|
|
119
24
|
[e]
|
|
120
25
|
);
|
|
121
26
|
return {
|
|
122
|
-
|
|
123
|
-
|
|
124
|
-
// Convenience methods
|
|
125
|
-
emitTextDelta: l,
|
|
126
|
-
emitStreamError: u,
|
|
127
|
-
emitAgentReasoning: g,
|
|
128
|
-
emitAgentGenerate: v,
|
|
129
|
-
emitToolExecution: f,
|
|
130
|
-
emitAgentTransfer: k,
|
|
131
|
-
emitDelegationSent: E,
|
|
132
|
-
emitDelegationReturned: p,
|
|
133
|
-
emitArtifactSaved: h,
|
|
134
|
-
emitCompletion: w,
|
|
135
|
-
emitAgentInitializing: S
|
|
27
|
+
setConversationId: s,
|
|
28
|
+
emitToParent: r
|
|
136
29
|
};
|
|
137
30
|
}
|
|
138
31
|
export {
|
|
139
|
-
|
|
32
|
+
v as useStreamingEvents
|
|
140
33
|
};
|
|
@@ -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.11",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.11",
|
|
9
9
|
componentType: o,
|
|
10
10
|
tags: s
|
|
11
11
|
}),
|
package/dist/types/types.d.cts
CHANGED
package/dist/types/types.d.ts
CHANGED