@inkeep/agents-ui 0.16.3 → 0.16.4
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/hooks/use-events-api.cjs +1 -1
- package/dist/primitives/hooks/use-events-api.js +27 -27
- package/dist/primitives/hooks/use-feedback-api.cjs +1 -1
- package/dist/primitives/hooks/use-feedback-api.js +16 -16
- 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-base-events-provider.cjs +1 -1
- package/dist/primitives/providers/chat-base-events-provider.js +14 -15
- 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 c=require("react"),f=require("./use-inkeep-api-client.cjs"),h=()=>{};function g({baseUrl:e,appId:a,authToken:r,getCaptchaHeader:u,invalidateCaptcha:l,refreshSession:p,headers:o}){const{fetchWithAuth:s}=f.useInkeepApiClient({appId:a,authToken:r,getCaptchaHeader:u,invalidateCaptcha:l??h,refreshSession:p}),i=c.useRef(o);return i.current=o,{logEvent:c.useCallback(async({body:v})=>{if(e)try{const t=`${e}/run/v1/events`,n=await s(t,{method:"POST",headers:{"Content-Type":"application/json",...i.current},body:JSON.stringify(v)});if(!n.ok){const d=await n.text().catch(()=>"<unreadable>");console.warn(`[events-api] log failed: ${n.status}`,d)}}catch(t){console.warn("[events-api] log threw",t)}},[e,s])}}exports.useEventsApi=g;
|
|
@@ -1,42 +1,42 @@
|
|
|
1
1
|
"use client";
|
|
2
|
-
import { useRef as
|
|
3
|
-
import { useInkeepApiClient as
|
|
2
|
+
import { useRef as h, useCallback as v } from "react";
|
|
3
|
+
import { useInkeepApiClient as d } from "./use-inkeep-api-client.js";
|
|
4
4
|
const g = () => {
|
|
5
5
|
};
|
|
6
6
|
function C({
|
|
7
7
|
baseUrl: t,
|
|
8
|
-
appId:
|
|
9
|
-
authToken:
|
|
10
|
-
getCaptchaHeader:
|
|
11
|
-
invalidateCaptcha:
|
|
12
|
-
refreshSession:
|
|
13
|
-
headers:
|
|
8
|
+
appId: s,
|
|
9
|
+
authToken: c,
|
|
10
|
+
getCaptchaHeader: i,
|
|
11
|
+
invalidateCaptcha: u,
|
|
12
|
+
refreshSession: l,
|
|
13
|
+
headers: o
|
|
14
14
|
}) {
|
|
15
|
-
const { fetchWithAuth:
|
|
16
|
-
appId:
|
|
17
|
-
authToken:
|
|
18
|
-
getCaptchaHeader:
|
|
19
|
-
invalidateCaptcha:
|
|
20
|
-
refreshSession:
|
|
21
|
-
}),
|
|
22
|
-
return
|
|
23
|
-
async ({ body:
|
|
24
|
-
if (
|
|
15
|
+
const { fetchWithAuth: a } = d({
|
|
16
|
+
appId: s,
|
|
17
|
+
authToken: c,
|
|
18
|
+
getCaptchaHeader: i,
|
|
19
|
+
invalidateCaptcha: u ?? g,
|
|
20
|
+
refreshSession: l
|
|
21
|
+
}), r = h(o);
|
|
22
|
+
return r.current = o, { logEvent: v(
|
|
23
|
+
async ({ body: p }) => {
|
|
24
|
+
if (t)
|
|
25
25
|
try {
|
|
26
|
-
const
|
|
26
|
+
const e = `${t}/run/v1/events`, n = await a(e, {
|
|
27
27
|
method: "POST",
|
|
28
|
-
headers: { "Content-Type": "application/json", ...
|
|
29
|
-
body: JSON.stringify(
|
|
28
|
+
headers: { "Content-Type": "application/json", ...r.current },
|
|
29
|
+
body: JSON.stringify(p)
|
|
30
30
|
});
|
|
31
|
-
if (!
|
|
32
|
-
const f = await
|
|
33
|
-
console.warn(`[events-api] log failed: ${
|
|
31
|
+
if (!n.ok) {
|
|
32
|
+
const f = await n.text().catch(() => "<unreadable>");
|
|
33
|
+
console.warn(`[events-api] log failed: ${n.status}`, f);
|
|
34
34
|
}
|
|
35
|
-
} catch (
|
|
36
|
-
console.warn("[events-api] log threw",
|
|
35
|
+
} catch (e) {
|
|
36
|
+
console.warn("[events-api] log threw", e);
|
|
37
37
|
}
|
|
38
38
|
},
|
|
39
|
-
[t,
|
|
39
|
+
[t, a]
|
|
40
40
|
) };
|
|
41
41
|
}
|
|
42
42
|
export {
|
|
@@ -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 c=require("react"),h=require("./use-inkeep-api-client.cjs"),y=()=>{};function m({baseUrl:e,appId:o,authToken:r,getCaptchaHeader:u,invalidateCaptcha:a,refreshSession:d,headers:n}){const{fetchWithAuth:i}=h.useInkeepApiClient({appId:o,authToken:r,getCaptchaHeader:u,invalidateCaptcha:a??y,refreshSession:d}),s=c.useRef(n);return s.current=n,{submitFeedback:c.useCallback(async({conversationId:p,messageId:b,type:f,details:k})=>{if(!e)return;const l=`${e}/run/v1/feedback`,t=await i(l,{method:"POST",headers:{"Content-Type":"application/json",...s.current},body:JSON.stringify({conversationId:p,messageId:b,type:f,details:k})});if(!t.ok)throw new Error(`Feedback submission failed: ${t.status}`);return t.json()},[e,i])}}exports.useFeedbackApi=m;
|
|
@@ -1,36 +1,36 @@
|
|
|
1
1
|
"use client";
|
|
2
|
-
import { useRef as
|
|
3
|
-
import { useInkeepApiClient as
|
|
2
|
+
import { useRef as m, useCallback as h } from "react";
|
|
3
|
+
import { useInkeepApiClient as l } from "./use-inkeep-api-client.js";
|
|
4
4
|
const y = () => {
|
|
5
5
|
};
|
|
6
6
|
function A({
|
|
7
7
|
baseUrl: e,
|
|
8
|
-
appId:
|
|
9
|
-
authToken:
|
|
8
|
+
appId: r,
|
|
9
|
+
authToken: s,
|
|
10
10
|
getCaptchaHeader: c,
|
|
11
11
|
invalidateCaptcha: u,
|
|
12
12
|
refreshSession: a,
|
|
13
|
-
headers:
|
|
13
|
+
headers: n
|
|
14
14
|
}) {
|
|
15
|
-
const { fetchWithAuth: o } =
|
|
16
|
-
appId:
|
|
17
|
-
authToken:
|
|
15
|
+
const { fetchWithAuth: o } = l({
|
|
16
|
+
appId: r,
|
|
17
|
+
authToken: s,
|
|
18
18
|
getCaptchaHeader: c,
|
|
19
19
|
invalidateCaptcha: u ?? y,
|
|
20
20
|
refreshSession: a
|
|
21
|
-
}),
|
|
22
|
-
return
|
|
21
|
+
}), i = m(n);
|
|
22
|
+
return i.current = n, { submitFeedback: h(
|
|
23
23
|
async ({ conversationId: f, messageId: p, type: d, details: b }) => {
|
|
24
|
-
if (!e
|
|
25
|
-
const
|
|
24
|
+
if (!e) return;
|
|
25
|
+
const k = `${e}/run/v1/feedback`, t = await o(k, {
|
|
26
26
|
method: "POST",
|
|
27
|
-
headers: { "Content-Type": "application/json", ...
|
|
27
|
+
headers: { "Content-Type": "application/json", ...i.current },
|
|
28
28
|
body: JSON.stringify({ conversationId: f, messageId: p, type: d, details: b })
|
|
29
29
|
});
|
|
30
|
-
if (!
|
|
31
|
-
return
|
|
30
|
+
if (!t.ok) throw new Error(`Feedback submission failed: ${t.status}`);
|
|
31
|
+
return t.json();
|
|
32
32
|
},
|
|
33
|
-
[e,
|
|
33
|
+
[e, o]
|
|
34
34
|
) };
|
|
35
35
|
}
|
|
36
36
|
export {
|
|
@@ -1 +1 @@
|
|
|
1
|
-
"use client";"use strict";Object.defineProperty(exports,Symbol.toStringTag,{value:"Module"});const l=require("react/jsx-runtime"),t=require("react"),p=require("./config-provider.cjs"),n=t.createContext(void 0),g=({children:e})=>{const{baseSettings:s,componentType:o}=p.useInkeepConfig(),{tags:r,analyticsProperties:i}=s,c="0.16.
|
|
1
|
+
"use client";"use strict";Object.defineProperty(exports,Symbol.toStringTag,{value:"Module"});const l=require("react/jsx-runtime"),t=require("react"),p=require("./config-provider.cjs"),n=t.createContext(void 0),g=({children:e})=>{const{baseSettings:s,componentType:o}=p.useInkeepConfig(),{tags:r,analyticsProperties:i}=s,c="0.16.4",a=t.useMemo(()=>({widgetLibraryVersion:c,componentType:o,tags:r}),[o,r,c]),v={logEvent:t.useCallback(async u=>{const E={...a,...u.properties,...i},d={eventName:u.eventName,properties:E};return s.onEvent?.(d)},[s,a,i])};return l.jsx(n.Provider,{value:v,children:e})},m=()=>{const e=t.useContext(n);if(!e)throw new Error("useBaseEvents must be used within a BaseEventsProvider");return e};exports.BaseEventsContext=n;exports.BaseEventsProvider=g;exports.useBaseEvents=m;
|
|
@@ -3,7 +3,7 @@ import { jsx as u } from "react/jsx-runtime";
|
|
|
3
3
|
import { createContext as E, useMemo as d, useCallback as l, useContext as g } from "react";
|
|
4
4
|
import { useInkeepConfig as x } from "./config-provider.js";
|
|
5
5
|
const c = E(void 0), b = ({ children: e }) => {
|
|
6
|
-
const { baseSettings: t, componentType: o } = x(), { tags: s, analyticsProperties: n } = t, r = "0.16.
|
|
6
|
+
const { baseSettings: t, componentType: o } = x(), { tags: s, analyticsProperties: n } = t, r = "0.16.4", i = d(
|
|
7
7
|
() => ({
|
|
8
8
|
widgetLibraryVersion: r,
|
|
9
9
|
componentType: o,
|
|
@@ -1 +1 @@
|
|
|
1
|
-
"use client";"use strict";Object.defineProperty(exports,Symbol.toStringTag,{value:"Module"});const j=require("react/jsx-runtime"),
|
|
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.4",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;
|
|
@@ -5,17 +5,17 @@ import { useInkeepConfig as N } from "./config-provider.js";
|
|
|
5
5
|
import { useChatAuth as O } from "./chat-auth-provider.js";
|
|
6
6
|
import { useEventsApi as j } from "../hooks/use-events-api.js";
|
|
7
7
|
import { BaseEventsContext as M } from "./base-events-provider.js";
|
|
8
|
-
const F = ({ children:
|
|
9
|
-
const { baseSettings: r, aiChatSettings:
|
|
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.4", 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
21
|
refreshSession: u,
|
|
@@ -31,19 +31,19 @@ const F = ({ children: g }) => {
|
|
|
31
31
|
...n
|
|
32
32
|
}
|
|
33
33
|
};
|
|
34
|
-
if (!
|
|
35
|
-
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 = {
|
|
36
36
|
...t ? { tags: t } : {},
|
|
37
37
|
...n ?? {}
|
|
38
38
|
}, T = {
|
|
39
39
|
...a,
|
|
40
40
|
...s.properties
|
|
41
41
|
};
|
|
42
|
-
|
|
42
|
+
l({
|
|
43
43
|
body: {
|
|
44
44
|
type: s.eventName,
|
|
45
|
-
...
|
|
46
|
-
...
|
|
45
|
+
...v ? { conversationId: v } : {},
|
|
46
|
+
...d ? { messageId: d } : {},
|
|
47
47
|
...w ? { userProperties: o } : {},
|
|
48
48
|
properties: S,
|
|
49
49
|
metadata: T
|
|
@@ -61,13 +61,12 @@ const F = ({ children: g }) => {
|
|
|
61
61
|
a,
|
|
62
62
|
t,
|
|
63
63
|
n,
|
|
64
|
-
v,
|
|
65
64
|
l,
|
|
66
|
-
|
|
65
|
+
p,
|
|
67
66
|
o
|
|
68
67
|
]
|
|
69
68
|
) };
|
|
70
|
-
return /* @__PURE__ */ U(M.Provider, { value: P, children:
|
|
69
|
+
return /* @__PURE__ */ U(M.Provider, { value: P, children: m });
|
|
71
70
|
};
|
|
72
71
|
export {
|
|
73
72
|
F as ChatBaseEventsProvider
|