@inkeep/agents-ui 0.0.0-dev-20260513213554 → 0.0.0-dev-20260528130902
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-captcha.cjs +1 -1
- package/dist/primitives/components/embedded-chat/use-captcha.d.ts +1 -22
- package/dist/primitives/components/embedded-chat/use-captcha.js +81 -60
- package/dist/primitives/components/embedded-chat/use-inkeep-chat.cjs +2 -2
- package/dist/primitives/components/embedded-chat/use-inkeep-chat.js +74 -76
- package/dist/primitives/components/embedded-chat.d.ts +1 -1
- package/dist/primitives/hooks/use-anonymous-session.cjs +1 -1
- package/dist/primitives/hooks/use-anonymous-session.js +70 -65
- package/dist/primitives/hooks/use-events-api.cjs +1 -1
- package/dist/primitives/hooks/use-events-api.d.ts +3 -1
- package/dist/primitives/hooks/use-events-api.js +30 -29
- package/dist/primitives/hooks/use-feedback-api.cjs +1 -1
- package/dist/primitives/hooks/use-feedback-api.d.ts +3 -1
- package/dist/primitives/hooks/use-feedback-api.js +27 -26
- package/dist/primitives/hooks/use-inkeep-api-client.cjs +1 -1
- package/dist/primitives/hooks/use-inkeep-api-client.js +29 -42
- package/dist/primitives/providers/base-events-provider.cjs +1 -1
- package/dist/primitives/providers/base-events-provider.js +1 -1
- package/dist/primitives/providers/chat-auth-provider.cjs +1 -1
- package/dist/primitives/providers/chat-auth-provider.js +24 -28
- package/dist/primitives/providers/chat-base-events-provider.cjs +1 -1
- package/dist/primitives/providers/chat-base-events-provider.js +33 -33
- package/dist/primitives/providers/feedback-provider.cjs +1 -1
- package/dist/primitives/providers/feedback-provider.js +19 -18
- package/package.json +1 -1
|
@@ -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 j=require("react/jsx-runtime"),u=require("react"),B=require("./config-provider.cjs"),O=require("./chat-auth-provider.cjs"),U=require("../hooks/use-events-api.cjs"),x=require("./base-events-provider.cjs"),M=({children:g})=>{const{baseSettings:n,aiChatSettings:h,componentType:i}=B.useInkeepConfig(),{tags:t,analyticsProperties:r,privacyPreferences:y,userProperties:o}=n,c="0.16.5",a=u.useMemo(()=>({widgetLibraryVersion:c,componentType:i}),[i,c]),{effectiveAuthToken:b,applicableRefreshSession:f,getCaptchaHeader:E,invalidateCaptcha:P}=O.useChatAuth(),{baseUrl:m,appId:A,analyticsApiBaseUrl:C,headers:I}=h,p=y?.optOutAllAnalytics??!1,{logEvent:l}=U.useEventsApi({baseUrl:C??m,appId:A,authToken:b,getCaptchaHeader:E,invalidateCaptcha:P,refreshSession:f,headers:I}),k={logEvent:u.useCallback(async s=>{const q={eventName:s.eventName,properties:{...a,...t?{tags:t}:{},...s.properties,...r}};if(!p){const e=s.properties??{},v=typeof e.conversationId=="string"?e.conversationId:void 0,d=typeof e.messageId=="string"?e.messageId:void 0,S=!!o&&Object.keys(o).length>0,w={...t?{tags:t}:{},...r??{}},T={...a,...s.properties};l({body:{type:s.eventName,...v?{conversationId:v}:{},...d?{messageId:d}:{},...S?{userProperties:o}:{},properties:w,metadata:T}})}try{return await n.onEvent?.(q)}catch(e){console.warn("[events] onEvent callback threw",e)}},[n,a,t,r,l,p,o])};return j.jsx(x.BaseEventsContext.Provider,{value:k,children:g})};exports.ChatBaseEventsProvider=M;
|
|
@@ -1,73 +1,73 @@
|
|
|
1
1
|
"use client";
|
|
2
|
-
import { jsx as
|
|
3
|
-
import { useMemo as
|
|
4
|
-
import { useInkeepConfig as
|
|
5
|
-
import { useChatAuth as
|
|
6
|
-
import { useEventsApi as
|
|
7
|
-
import { BaseEventsContext as
|
|
8
|
-
const
|
|
9
|
-
const { baseSettings:
|
|
2
|
+
import { jsx as U } from "react/jsx-runtime";
|
|
3
|
+
import { useMemo as x, useCallback as B } from "react";
|
|
4
|
+
import { useInkeepConfig as N } from "./config-provider.js";
|
|
5
|
+
import { useChatAuth as O } from "./chat-auth-provider.js";
|
|
6
|
+
import { useEventsApi as j } from "../hooks/use-events-api.js";
|
|
7
|
+
import { BaseEventsContext as M } from "./base-events-provider.js";
|
|
8
|
+
const F = ({ children: m }) => {
|
|
9
|
+
const { baseSettings: r, aiChatSettings: g, componentType: i } = N(), { tags: t, analyticsProperties: n, privacyPreferences: f, userProperties: o } = r, c = "0.16.5", a = x(
|
|
10
10
|
() => ({
|
|
11
|
-
widgetLibraryVersion:
|
|
12
|
-
componentType:
|
|
11
|
+
widgetLibraryVersion: c,
|
|
12
|
+
componentType: i
|
|
13
13
|
}),
|
|
14
|
-
[
|
|
15
|
-
), { effectiveAuthToken:
|
|
14
|
+
[i, c]
|
|
15
|
+
), { effectiveAuthToken: h, applicableRefreshSession: u, getCaptchaHeader: y, invalidateCaptcha: b } = O(), { baseUrl: A, appId: E, analyticsApiBaseUrl: C, headers: I } = g, p = f?.optOutAllAnalytics ?? !1, { logEvent: l } = j({
|
|
16
16
|
baseUrl: C ?? A,
|
|
17
17
|
appId: E,
|
|
18
|
-
authToken:
|
|
18
|
+
authToken: h,
|
|
19
19
|
getCaptchaHeader: y,
|
|
20
20
|
invalidateCaptcha: b,
|
|
21
|
-
refreshSession:
|
|
22
|
-
|
|
21
|
+
refreshSession: u,
|
|
22
|
+
headers: I
|
|
23
|
+
}), P = { logEvent: B(
|
|
23
24
|
async (s) => {
|
|
24
|
-
const
|
|
25
|
+
const k = {
|
|
25
26
|
eventName: s.eventName,
|
|
26
27
|
properties: {
|
|
27
28
|
...a,
|
|
28
29
|
...t ? { tags: t } : {},
|
|
29
30
|
...s.properties,
|
|
30
|
-
...
|
|
31
|
+
...n
|
|
31
32
|
}
|
|
32
33
|
};
|
|
33
|
-
if (!
|
|
34
|
-
const e = s.properties ?? {},
|
|
34
|
+
if (!p) {
|
|
35
|
+
const e = s.properties ?? {}, v = typeof e.conversationId == "string" ? e.conversationId : void 0, d = typeof e.messageId == "string" ? e.messageId : void 0, w = !!o && Object.keys(o).length > 0, S = {
|
|
35
36
|
...t ? { tags: t } : {},
|
|
36
|
-
...
|
|
37
|
-
},
|
|
37
|
+
...n ?? {}
|
|
38
|
+
}, T = {
|
|
38
39
|
...a,
|
|
39
40
|
...s.properties
|
|
40
41
|
};
|
|
41
|
-
|
|
42
|
+
l({
|
|
42
43
|
body: {
|
|
43
44
|
type: s.eventName,
|
|
44
|
-
...
|
|
45
|
+
...v ? { conversationId: v } : {},
|
|
45
46
|
...d ? { messageId: d } : {},
|
|
46
|
-
...
|
|
47
|
-
properties:
|
|
48
|
-
metadata:
|
|
47
|
+
...w ? { userProperties: o } : {},
|
|
48
|
+
properties: S,
|
|
49
|
+
metadata: T
|
|
49
50
|
}
|
|
50
51
|
});
|
|
51
52
|
}
|
|
52
53
|
try {
|
|
53
|
-
return await
|
|
54
|
+
return await r.onEvent?.(k);
|
|
54
55
|
} catch (e) {
|
|
55
56
|
console.warn("[events] onEvent callback threw", e);
|
|
56
57
|
}
|
|
57
58
|
},
|
|
58
59
|
[
|
|
59
|
-
|
|
60
|
+
r,
|
|
60
61
|
a,
|
|
61
62
|
t,
|
|
62
|
-
|
|
63
|
-
v,
|
|
63
|
+
n,
|
|
64
64
|
l,
|
|
65
|
-
|
|
65
|
+
p,
|
|
66
66
|
o
|
|
67
67
|
]
|
|
68
68
|
) };
|
|
69
|
-
return /* @__PURE__ */
|
|
69
|
+
return /* @__PURE__ */ U(M.Provider, { value: P, children: m });
|
|
70
70
|
};
|
|
71
71
|
export {
|
|
72
|
-
|
|
72
|
+
F as ChatBaseEventsProvider
|
|
73
73
|
};
|
|
@@ -1 +1 @@
|
|
|
1
|
-
"use client";"use strict";Object.defineProperty(exports,Symbol.toStringTag,{value:"Module"});const M=require("react/jsx-runtime"),a=require("react"),T=require("../components/embedded-chat/chat-provider.cjs"),F=require("../utils/misc.cjs"),A=require("./config-provider.cjs"),E=require("./base-events-provider.cjs"),j=require("../hooks/use-feedback-api.cjs"),l=a.createContext(void 0);function y(){const{baseSettings:t,aiChatSettings:c}=A.useInkeepConfig(),[p,g]=a.useState(null),[f,C]=a.useState({}),{conversationId:o,messages:r,authToken:h,getCaptchaHeader:m,invalidateCaptcha:P,refreshSession:q}=T.useChat(),{analyticsProperties:d}=t,{logEvent:b}=E.useBaseEvents(),{submitFeedback:k}=j.useFeedbackApi({baseUrl:c.baseUrl,appId:c.appId,authToken:h,getCaptchaHeader:m,invalidateCaptcha:P,refreshSession:q}),i=a.useCallback(async(e,s,u)=>{C(n=>({...n,[e]:{type:s,messageId:e,details:u}})),t.onFeedback?t.onFeedback({type:s,messageId:e,details:u,properties:d}).catch(n=>console.warn("[feedback] onFeedback error:",n)):k({conversationId:o,messageId:e,type:s,details:u}).catch(n=>console.warn("[feedback] submitFeedbackToApi error:",n));const v=r.findIndex(n=>n.id===e),x=r[v],S={conversationId:o,question:F.getMessageContent(r[v-1]),answer:F.getMessageContent(x),messageId:e,details:u};b({eventName:s==="positive"?"assistant_positive_feedback_submitted":"assistant_negative_feedback_submitted",properties:S}),s==="negative"&&b({eventName:"user_escalation_indicated",properties:{escalationType:"downvote",conversationId:o,messageId:e}})},[r,o,d,t,b,k]),_=a.useCallback(async e=>{i(e,"positive")},[i]),w=a.useCallback(async(e,s)=>{i(e,"negative",s)},[i]);return{feedback:f,currentFeedback:p,setCurrentFeedback:g,submitPositiveFeedback:_,submitNegativeFeedback:w}}const N=({children:t})=>{const c=y();return M.jsx(l.Provider,{value:c,children:t})},R=()=>{const t=a.useContext(l);if(!t)throw new Error("useFeedback must be used within a FeedbackProvider");return t};exports.FeedbackProvider=N;exports.useMessageFeedback=R;
|
|
1
|
+
"use client";"use strict";Object.defineProperty(exports,Symbol.toStringTag,{value:"Module"});const M=require("react/jsx-runtime"),a=require("react"),T=require("../components/embedded-chat/chat-provider.cjs"),F=require("../utils/misc.cjs"),A=require("./config-provider.cjs"),E=require("./base-events-provider.cjs"),j=require("../hooks/use-feedback-api.cjs"),l=a.createContext(void 0);function y(){const{baseSettings:t,aiChatSettings:c}=A.useInkeepConfig(),[p,g]=a.useState(null),[f,C]=a.useState({}),{conversationId:o,messages:r,authToken:h,getCaptchaHeader:m,invalidateCaptcha:P,refreshSession:q}=T.useChat(),{analyticsProperties:d}=t,{logEvent:b}=E.useBaseEvents(),{submitFeedback:k}=j.useFeedbackApi({baseUrl:c.baseUrl,appId:c.appId,authToken:h,getCaptchaHeader:m,invalidateCaptcha:P,refreshSession:q,headers:c.headers}),i=a.useCallback(async(e,s,u)=>{C(n=>({...n,[e]:{type:s,messageId:e,details:u}})),t.onFeedback?t.onFeedback({type:s,messageId:e,details:u,properties:d}).catch(n=>console.warn("[feedback] onFeedback error:",n)):k({conversationId:o,messageId:e,type:s,details:u}).catch(n=>console.warn("[feedback] submitFeedbackToApi error:",n));const v=r.findIndex(n=>n.id===e),x=r[v],S={conversationId:o,question:F.getMessageContent(r[v-1]),answer:F.getMessageContent(x),messageId:e,details:u};b({eventName:s==="positive"?"assistant_positive_feedback_submitted":"assistant_negative_feedback_submitted",properties:S}),s==="negative"&&b({eventName:"user_escalation_indicated",properties:{escalationType:"downvote",conversationId:o,messageId:e}})},[r,o,d,t,b,k]),_=a.useCallback(async e=>{i(e,"positive")},[i]),w=a.useCallback(async(e,s)=>{i(e,"negative",s)},[i]);return{feedback:f,currentFeedback:p,setCurrentFeedback:g,submitPositiveFeedback:_,submitNegativeFeedback:w}}const N=({children:t})=>{const c=y();return M.jsx(l.Provider,{value:c,children:t})},R=()=>{const t=a.useContext(l);if(!t)throw new Error("useFeedback must be used within a FeedbackProvider");return t};exports.FeedbackProvider=N;exports.useMessageFeedback=R;
|
|
@@ -8,9 +8,9 @@ import { useBaseEvents as q } from "./base-events-provider.js";
|
|
|
8
8
|
import { useFeedbackApi as y } from "../hooks/use-feedback-api.js";
|
|
9
9
|
const f = M(void 0);
|
|
10
10
|
function B() {
|
|
11
|
-
const { baseSettings: t, aiChatSettings: n } = j(), [F, l] = m(null), [
|
|
11
|
+
const { baseSettings: t, aiChatSettings: n } = j(), [F, l] = m(null), [h, C] = m({}), {
|
|
12
12
|
conversationId: a,
|
|
13
|
-
messages:
|
|
13
|
+
messages: r,
|
|
14
14
|
authToken: g,
|
|
15
15
|
getCaptchaHeader: _,
|
|
16
16
|
invalidateCaptcha: w,
|
|
@@ -21,23 +21,24 @@ function B() {
|
|
|
21
21
|
authToken: g,
|
|
22
22
|
getCaptchaHeader: _,
|
|
23
23
|
invalidateCaptcha: w,
|
|
24
|
-
refreshSession: x
|
|
25
|
-
|
|
26
|
-
|
|
27
|
-
|
|
28
|
-
|
|
24
|
+
refreshSession: x,
|
|
25
|
+
headers: n.headers
|
|
26
|
+
}), c = d(
|
|
27
|
+
async (e, s, i) => {
|
|
28
|
+
C((o) => ({ ...o, [e]: { type: s, messageId: e, details: i } })), t.onFeedback ? t.onFeedback({ type: s, messageId: e, details: i, properties: u }).catch((o) => console.warn("[feedback] onFeedback error:", o)) : k({ conversationId: a, messageId: e, type: s, details: i }).catch(
|
|
29
|
+
(o) => console.warn("[feedback] submitFeedbackToApi error:", o)
|
|
29
30
|
);
|
|
30
|
-
const p =
|
|
31
|
+
const p = r.findIndex((o) => o.id === e), T = r[p], A = {
|
|
31
32
|
conversationId: a,
|
|
32
|
-
question: v(
|
|
33
|
+
question: v(r[p - 1]),
|
|
33
34
|
answer: v(T),
|
|
34
35
|
messageId: e,
|
|
35
36
|
details: i
|
|
36
37
|
};
|
|
37
38
|
b({
|
|
38
|
-
eventName:
|
|
39
|
+
eventName: s === "positive" ? "assistant_positive_feedback_submitted" : "assistant_negative_feedback_submitted",
|
|
39
40
|
properties: A
|
|
40
|
-
}),
|
|
41
|
+
}), s === "negative" && b({
|
|
41
42
|
eventName: "user_escalation_indicated",
|
|
42
43
|
properties: {
|
|
43
44
|
escalationType: "downvote",
|
|
@@ -46,20 +47,20 @@ function B() {
|
|
|
46
47
|
}
|
|
47
48
|
});
|
|
48
49
|
},
|
|
49
|
-
[
|
|
50
|
+
[r, a, u, t, b, k]
|
|
50
51
|
), P = d(
|
|
51
52
|
async (e) => {
|
|
52
|
-
|
|
53
|
+
c(e, "positive");
|
|
53
54
|
},
|
|
54
|
-
[
|
|
55
|
+
[c]
|
|
55
56
|
), S = d(
|
|
56
|
-
async (e,
|
|
57
|
-
|
|
57
|
+
async (e, s) => {
|
|
58
|
+
c(e, "negative", s);
|
|
58
59
|
},
|
|
59
|
-
[
|
|
60
|
+
[c]
|
|
60
61
|
);
|
|
61
62
|
return {
|
|
62
|
-
feedback:
|
|
63
|
+
feedback: h,
|
|
63
64
|
currentFeedback: F,
|
|
64
65
|
setCurrentFeedback: l,
|
|
65
66
|
submitPositiveFeedback: P,
|