@inkeep/agents-ui 0.0.0-dev-20260501205503 → 0.0.0-dev-20260501215045
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/chat-error-helpers.d.ts +2 -4
- package/dist/primitives/components/embedded-chat/use-captcha.cjs +1 -0
- package/dist/primitives/components/embedded-chat/use-captcha.d.ts +30 -0
- package/dist/primitives/components/embedded-chat/use-captcha.js +67 -0
- package/dist/primitives/components/embedded-chat/use-inkeep-chat.cjs +2 -2
- package/dist/primitives/components/embedded-chat/use-inkeep-chat.d.ts +2 -0
- package/dist/primitives/components/embedded-chat/use-inkeep-chat.js +262 -237
- package/dist/primitives/hooks/use-anonymous-session.cjs +1 -1
- package/dist/primitives/hooks/use-anonymous-session.d.ts +3 -1
- package/dist/primitives/hooks/use-anonymous-session.js +56 -51
- package/dist/primitives/hooks/use-conversation-loader.cjs +1 -1
- package/dist/primitives/hooks/use-conversation-loader.d.ts +3 -1
- package/dist/primitives/hooks/use-conversation-loader.js +20 -15
- 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 +22 -16
- package/dist/primitives/hooks/use-inkeep-api-client.cjs +1 -1
- package/dist/primitives/hooks/use-inkeep-api-client.d.ts +11 -8
- package/dist/primitives/hooks/use-inkeep-api-client.js +64 -36
- package/dist/primitives/providers/chat-history-provider.cjs +1 -1
- package/dist/primitives/providers/chat-history-provider.js +39 -35
- package/dist/primitives/providers/feedback-provider.cjs +1 -1
- package/dist/primitives/providers/feedback-provider.js +35 -26
- package/dist/primitives/providers/root-provider.cjs +1 -1
- package/dist/primitives/providers/root-provider.js +9 -13
- package/dist/primitives/utils/default-settings.cjs +1 -1
- package/dist/primitives/utils/default-settings.d.ts +0 -1
- package/dist/primitives/utils/default-settings.js +5 -6
- package/dist/types/config/ai.d.ts +0 -8
- package/package.json +2 -2
- package/dist/node_modules/.pnpm/botid@1.5.11_next@16.2.4_@babel_core@7.29.0_@opentelemetry_api@1.9.1_react-dom@19.3.0-c_6ac35f5bf61166da3243b6cf36e09c95/node_modules/botid/dist/client/core/index.cjs +0 -1
- package/dist/node_modules/.pnpm/botid@1.5.11_next@16.2.4_@babel_core@7.29.0_@opentelemetry_api@1.9.1_react-dom@19.3.0-c_6ac35f5bf61166da3243b6cf36e09c95/node_modules/botid/dist/client/core/index.js +0 -160
- package/dist/primitives/providers/botid-initializer.cjs +0 -1
- package/dist/primitives/providers/botid-initializer.d.ts +0 -15
- package/dist/primitives/providers/botid-initializer.js +0 -69
|
@@ -1,25 +1,29 @@
|
|
|
1
1
|
"use client";
|
|
2
|
-
import { jsx as
|
|
3
|
-
import { useContext as
|
|
4
|
-
import { useChat as
|
|
5
|
-
import { useInkeepConfig as
|
|
6
|
-
import { useInkeepApiClient as
|
|
7
|
-
const z =
|
|
8
|
-
function
|
|
2
|
+
import { jsx as se } from "react/jsx-runtime";
|
|
3
|
+
import { useContext as re, useState as h, useRef as c, useEffect as H, useCallback as S, createContext as oe } from "react";
|
|
4
|
+
import { useChat as ie } from "../components/embedded-chat/chat-provider.js";
|
|
5
|
+
import { useInkeepConfig as ae } from "./config-provider.js";
|
|
6
|
+
import { useInkeepApiClient as ce } from "../hooks/use-inkeep-api-client.js";
|
|
7
|
+
const z = oe(void 0), q = 25;
|
|
8
|
+
function ue(e) {
|
|
9
9
|
const {
|
|
10
10
|
stop: u,
|
|
11
11
|
clear: f,
|
|
12
12
|
conversationId: d,
|
|
13
|
-
isStreaming:
|
|
13
|
+
isStreaming: y,
|
|
14
14
|
loadAndRestoreSession: P,
|
|
15
15
|
authToken: t,
|
|
16
|
-
refreshSession: B
|
|
17
|
-
|
|
16
|
+
refreshSession: B,
|
|
17
|
+
getCaptchaHeader: J,
|
|
18
|
+
invalidateCaptcha: Q
|
|
19
|
+
} = ie(), { aiChatSettings: V, baseSettings: X } = ae(), { baseUrl: w, appId: x, apiKey: Y } = V, i = !!X.getAuthToken, r = !Y && !!x && (!!t || i), { fetchWithAuth: E } = ce({
|
|
18
20
|
appId: x,
|
|
19
21
|
authToken: t,
|
|
22
|
+
getCaptchaHeader: J,
|
|
23
|
+
invalidateCaptcha: Q,
|
|
20
24
|
refreshSession: B
|
|
21
25
|
}), [m, A] = h(!1), [R, T] = h([]), [b, $] = h(!t && r), [L, M] = h(0), [k, j] = h(!1), p = c(!1), D = c(null), F = c(i), O = c(t);
|
|
22
|
-
|
|
26
|
+
H(() => {
|
|
23
27
|
const s = F.current, n = O.current;
|
|
24
28
|
F.current = i, O.current = t, (s !== i || n !== null && t !== null && n !== t) && (T([]), M(0), j(!1), p.current = !1);
|
|
25
29
|
}, [i, t]);
|
|
@@ -32,9 +36,9 @@ function ae(e) {
|
|
|
32
36
|
if (!(!w || !t || !r)) {
|
|
33
37
|
n || $(!0);
|
|
34
38
|
try {
|
|
35
|
-
const
|
|
36
|
-
if (!
|
|
37
|
-
const U = await
|
|
39
|
+
const C = `${w}/run/v1/conversations?page=${s + 1}&limit=${q}`, g = await G.current(C);
|
|
40
|
+
if (!g.ok) throw new Error(`Failed to fetch conversations: ${g.status}`);
|
|
41
|
+
const U = await g.json(), v = (U.data ?? []).map((o) => ({
|
|
38
42
|
id: o.id,
|
|
39
43
|
title: o.title ?? "",
|
|
40
44
|
createdAt: new Date(o.createdAt),
|
|
@@ -46,13 +50,13 @@ function ae(e) {
|
|
|
46
50
|
const l = new Set(v.map((I) => I.id));
|
|
47
51
|
return [...v, ...o.slice(q).filter((I) => !l.has(I.id))];
|
|
48
52
|
}
|
|
49
|
-
const
|
|
50
|
-
return [...o, ...v.filter((l) => !
|
|
53
|
+
const ne = new Set(o.map((l) => l.id));
|
|
54
|
+
return [...o, ...v.filter((l) => !ne.has(l.id))];
|
|
51
55
|
});
|
|
52
56
|
const { page: Z, pages: _ } = U.pagination ?? {};
|
|
53
57
|
j(Z != null && _ != null ? Z < _ : !1), n || M(s);
|
|
54
|
-
} catch (
|
|
55
|
-
console.error("[useChatHistory] Failed to load conversations:",
|
|
58
|
+
} catch (C) {
|
|
59
|
+
console.error("[useChatHistory] Failed to load conversations:", C);
|
|
56
60
|
} finally {
|
|
57
61
|
$(!1);
|
|
58
62
|
}
|
|
@@ -60,18 +64,18 @@ function ae(e) {
|
|
|
60
64
|
},
|
|
61
65
|
[w, t, r]
|
|
62
66
|
);
|
|
63
|
-
|
|
67
|
+
H(() => {
|
|
64
68
|
!m || !t && !i || !r || (e === "stack" ? a(0) : !p.current && t && (p.current = !0, a(0)));
|
|
65
69
|
}, [m, t, i, r, e, a]);
|
|
66
70
|
const K = c("");
|
|
67
|
-
|
|
68
|
-
r && e === "sidepane" && (!d || !
|
|
69
|
-
}, [d, r, e, a,
|
|
70
|
-
const
|
|
71
|
+
H(() => {
|
|
72
|
+
r && e === "sidepane" && (!d || !y || p.current && K.current !== d && (W.current.some((s) => s.id === d) || (K.current = d, a(0, !0))));
|
|
73
|
+
}, [d, r, e, a, y]);
|
|
74
|
+
const N = S(() => {
|
|
71
75
|
!b && k && a(L + 1);
|
|
72
|
-
}, [b, k, L, a]),
|
|
76
|
+
}, [b, k, L, a]), ee = S(() => {
|
|
73
77
|
u(), f(), e !== "sidepane" && A(!1);
|
|
74
|
-
}, [e, u, f]),
|
|
78
|
+
}, [e, u, f]), te = S(
|
|
75
79
|
async (s) => {
|
|
76
80
|
D.current?.abort();
|
|
77
81
|
const n = new AbortController();
|
|
@@ -86,21 +90,21 @@ function ae(e) {
|
|
|
86
90
|
sessions: R,
|
|
87
91
|
isLoading: b,
|
|
88
92
|
hasMore: k,
|
|
89
|
-
loadMore:
|
|
90
|
-
startNewConversation:
|
|
91
|
-
loadSession:
|
|
93
|
+
loadMore: N,
|
|
94
|
+
startNewConversation: ee,
|
|
95
|
+
loadSession: te
|
|
92
96
|
};
|
|
93
97
|
}
|
|
94
|
-
const
|
|
95
|
-
const f =
|
|
96
|
-
return /* @__PURE__ */
|
|
97
|
-
},
|
|
98
|
-
const e =
|
|
98
|
+
const ge = ({ layout: e, children: u }) => {
|
|
99
|
+
const f = ue(e);
|
|
100
|
+
return /* @__PURE__ */ se(z.Provider, { value: f, children: typeof u == "function" ? u(f) : u });
|
|
101
|
+
}, ve = () => {
|
|
102
|
+
const e = re(z);
|
|
99
103
|
if (!e)
|
|
100
104
|
throw new Error("useChatHistory must be used within a ChatHistoryProvider");
|
|
101
105
|
return e;
|
|
102
106
|
};
|
|
103
107
|
export {
|
|
104
|
-
|
|
105
|
-
|
|
108
|
+
ge as ChatHistoryProvider,
|
|
109
|
+
ve as useChatHistory
|
|
106
110
|
};
|
|
@@ -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 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:m,getCaptchaHeader:h,invalidateCaptcha:P,refreshSession:q}=T.useChat(),{analyticsProperties:d}=t,{logEvent:b}=E.useBaseEvents(),{submitFeedback:k}=j.useFeedbackApi({baseUrl:c.baseUrl,appId:c.appId,authToken:m,getCaptchaHeader:h,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}})},[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,33 +1,42 @@
|
|
|
1
1
|
"use client";
|
|
2
|
-
import { jsx as
|
|
3
|
-
import { useContext as
|
|
4
|
-
import { useChat as
|
|
2
|
+
import { jsx as E } from "react/jsx-runtime";
|
|
3
|
+
import { useContext as N, useState as m, useCallback as d, createContext as M } from "react";
|
|
4
|
+
import { useChat as U } from "../components/embedded-chat/chat-provider.js";
|
|
5
5
|
import { getMessageContent as v } from "../utils/misc.js";
|
|
6
|
-
import { useInkeepConfig as
|
|
7
|
-
import { useBaseEvents as
|
|
8
|
-
import { useFeedbackApi as
|
|
9
|
-
const f =
|
|
10
|
-
function
|
|
11
|
-
const { baseSettings: t, aiChatSettings: n } =
|
|
6
|
+
import { useInkeepConfig as j } from "./config-provider.js";
|
|
7
|
+
import { useBaseEvents as q } from "./base-events-provider.js";
|
|
8
|
+
import { useFeedbackApi as y } from "../hooks/use-feedback-api.js";
|
|
9
|
+
const f = M(void 0);
|
|
10
|
+
function B() {
|
|
11
|
+
const { baseSettings: t, aiChatSettings: n } = j(), [F, l] = m(null), [C, g] = m({}), {
|
|
12
|
+
conversationId: a,
|
|
13
|
+
messages: c,
|
|
14
|
+
authToken: h,
|
|
15
|
+
getCaptchaHeader: _,
|
|
16
|
+
invalidateCaptcha: w,
|
|
17
|
+
refreshSession: x
|
|
18
|
+
} = U(), { analyticsProperties: u } = t, { logEvent: b } = q(), { submitFeedback: k } = y({
|
|
12
19
|
baseUrl: n.baseUrl,
|
|
13
20
|
appId: n.appId,
|
|
14
21
|
authToken: h,
|
|
15
|
-
|
|
22
|
+
getCaptchaHeader: _,
|
|
23
|
+
invalidateCaptcha: w,
|
|
24
|
+
refreshSession: x
|
|
16
25
|
}), r = d(
|
|
17
26
|
async (e, s, i) => {
|
|
18
|
-
|
|
27
|
+
g((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(
|
|
19
28
|
(o) => console.warn("[feedback] submitFeedbackToApi error:", o)
|
|
20
29
|
);
|
|
21
|
-
const p = c.findIndex((o) => o.id === e),
|
|
30
|
+
const p = c.findIndex((o) => o.id === e), T = c[p], A = {
|
|
22
31
|
conversationId: a,
|
|
23
32
|
question: v(c[p - 1]),
|
|
24
|
-
answer: v(
|
|
33
|
+
answer: v(T),
|
|
25
34
|
messageId: e,
|
|
26
35
|
details: i
|
|
27
36
|
};
|
|
28
37
|
b({
|
|
29
38
|
eventName: s === "positive" ? "assistant_positive_feedback_submitted" : "assistant_negative_feedback_submitted",
|
|
30
|
-
properties:
|
|
39
|
+
properties: A
|
|
31
40
|
}), s === "negative" && b({
|
|
32
41
|
eventName: "user_escalation_indicated",
|
|
33
42
|
properties: {
|
|
@@ -37,35 +46,35 @@ function q() {
|
|
|
37
46
|
});
|
|
38
47
|
},
|
|
39
48
|
[c, a, u, t, b, k]
|
|
40
|
-
),
|
|
49
|
+
), P = d(
|
|
41
50
|
async (e) => {
|
|
42
51
|
r(e, "positive");
|
|
43
52
|
},
|
|
44
53
|
[r]
|
|
45
|
-
),
|
|
54
|
+
), S = d(
|
|
46
55
|
async (e, s) => {
|
|
47
56
|
r(e, "negative", s);
|
|
48
57
|
},
|
|
49
58
|
[r]
|
|
50
59
|
);
|
|
51
60
|
return {
|
|
52
|
-
feedback:
|
|
61
|
+
feedback: C,
|
|
53
62
|
currentFeedback: F,
|
|
54
63
|
setCurrentFeedback: l,
|
|
55
|
-
submitPositiveFeedback:
|
|
56
|
-
submitNegativeFeedback:
|
|
64
|
+
submitPositiveFeedback: P,
|
|
65
|
+
submitNegativeFeedback: S
|
|
57
66
|
};
|
|
58
67
|
}
|
|
59
|
-
const
|
|
60
|
-
const n =
|
|
61
|
-
return /* @__PURE__ */
|
|
62
|
-
},
|
|
63
|
-
const t =
|
|
68
|
+
const L = ({ children: t }) => {
|
|
69
|
+
const n = B();
|
|
70
|
+
return /* @__PURE__ */ E(f.Provider, { value: n, children: t });
|
|
71
|
+
}, O = () => {
|
|
72
|
+
const t = N(f);
|
|
64
73
|
if (!t)
|
|
65
74
|
throw new Error("useFeedback must be used within a FeedbackProvider");
|
|
66
75
|
return t;
|
|
67
76
|
};
|
|
68
77
|
export {
|
|
69
|
-
|
|
70
|
-
|
|
78
|
+
L as FeedbackProvider,
|
|
79
|
+
O as useMessageFeedback
|
|
71
80
|
};
|
|
@@ -1 +1 @@
|
|
|
1
|
-
"use client";"use strict";Object.defineProperty(exports,Symbol.toStringTag,{value:"Module"});const e=require("react/jsx-runtime"),t=require("./base-events-provider.cjs"),s=require("./
|
|
1
|
+
"use client";"use strict";Object.defineProperty(exports,Symbol.toStringTag,{value:"Module"});const e=require("react/jsx-runtime"),t=require("./base-events-provider.cjs"),s=require("./config-provider.cjs"),c=require("./theme-provider.cjs");function d(r){const{children:o,config:i,componentType:n}=r;return e.jsx(s.InkeepConfigProvider,{value:{...i,componentType:n},children:e.jsx(c.ThemeProvider,{children:e.jsx(t.BaseEventsProvider,{children:o})})})}exports.RootProvider=d;
|
|
@@ -1,25 +1,21 @@
|
|
|
1
1
|
"use client";
|
|
2
|
-
import {
|
|
3
|
-
import { BaseEventsProvider as
|
|
4
|
-
import {
|
|
5
|
-
import {
|
|
6
|
-
|
|
7
|
-
function u(o) {
|
|
2
|
+
import { jsx as r } from "react/jsx-runtime";
|
|
3
|
+
import { BaseEventsProvider as t } from "./base-events-provider.js";
|
|
4
|
+
import { InkeepConfigProvider as m } from "./config-provider.js";
|
|
5
|
+
import { ThemeProvider as c } from "./theme-provider.js";
|
|
6
|
+
function l(o) {
|
|
8
7
|
const { children: e, config: i, componentType: n } = o;
|
|
9
|
-
return /* @__PURE__ */
|
|
10
|
-
|
|
8
|
+
return /* @__PURE__ */ r(
|
|
9
|
+
m,
|
|
11
10
|
{
|
|
12
11
|
value: {
|
|
13
12
|
...i,
|
|
14
13
|
componentType: n
|
|
15
14
|
},
|
|
16
|
-
children:
|
|
17
|
-
/* @__PURE__ */ r(p, {}),
|
|
18
|
-
/* @__PURE__ */ r(d, { children: /* @__PURE__ */ r(m, { children: e }) })
|
|
19
|
-
]
|
|
15
|
+
children: /* @__PURE__ */ r(c, { children: /* @__PURE__ */ r(t, { children: e }) })
|
|
20
16
|
}
|
|
21
17
|
);
|
|
22
18
|
}
|
|
23
19
|
export {
|
|
24
|
-
|
|
20
|
+
l as RootProvider
|
|
25
21
|
};
|
|
@@ -1 +1 @@
|
|
|
1
|
-
"use client";"use strict";Object.defineProperty(exports,Symbol.toStringTag,{value:"Module"});const e=require("../../theme/index.cjs"),t=require("../../theme/colors.cjs"),s={baseUrl:"https://api.agents.inkeep.com",placeholder:"How do I get started?",aiAssistantName:void 0,shouldOpenLinksInNewTab:!0,disclaimerSettings:{isEnabled:!1,label:"Usage policy"},isShareButtonVisible:!1,isViewOnly:!1,isChatHistoryButtonVisible:!0,exampleQuestionsLabel:"Example questions",exampleQuestions:[],isFirstExampleQuestionHighlighted:!0,isCopyChatButtonVisible:!1,getHelpOptions:[],toolbarButtonLabels:{clear:"Clear",share:"Share",getHelp:"Get help",stop:"Stop",copyChat:"Copy"},context:{},shouldAutoScroll:!0
|
|
1
|
+
"use client";"use strict";Object.defineProperty(exports,Symbol.toStringTag,{value:"Module"});const e=require("../../theme/index.cjs"),t=require("../../theme/colors.cjs"),s={baseUrl:"https://api.agents.inkeep.com",placeholder:"How do I get started?",aiAssistantName:void 0,shouldOpenLinksInNewTab:!0,disclaimerSettings:{isEnabled:!1,label:"Usage policy"},isShareButtonVisible:!1,isViewOnly:!1,isChatHistoryButtonVisible:!0,exampleQuestionsLabel:"Example questions",exampleQuestions:[],isFirstExampleQuestionHighlighted:!0,isCopyChatButtonVisible:!1,getHelpOptions:[],toolbarButtonLabels:{clear:"Clear",share:"Share",getHelp:"Get help",stop:"Stop",copyChat:"Copy"},context:{},shouldAutoScroll:!0},a={shouldBypassCaptcha:!1,tags:[],userProperties:{},primaryBrandColor:t.DEFAULT_PRIMARY_BRAND_COLOR,theme:{varsClassName:"inkeep-widget-vars",...e.theme}},l={shouldOpenLinksInNewTab:!1,defaultQuery:"",debounceTimeMs:0,tabs:["All","Publications","PDFs","GitHub","Forums","Discord","Slack","StackOverflow"],placeholder:"Search for anything...",view:"single-pane"};exports.defaultInkeepAIChatSettings=s;exports.defaultInkeepBaseSettings=a;exports.defaultInkeepSearchSettings=l;
|
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
"use client";
|
|
2
2
|
import { theme as e } from "../../theme/index.js";
|
|
3
3
|
import { DEFAULT_PRIMARY_BRAND_COLOR as t } from "../../theme/colors.js";
|
|
4
|
-
const
|
|
4
|
+
const l = {
|
|
5
5
|
baseUrl: "https://api.agents.inkeep.com",
|
|
6
6
|
placeholder: "How do I get started?",
|
|
7
7
|
aiAssistantName: void 0,
|
|
@@ -26,9 +26,8 @@ const i = {
|
|
|
26
26
|
copyChat: "Copy"
|
|
27
27
|
},
|
|
28
28
|
context: {},
|
|
29
|
-
shouldAutoScroll: !0
|
|
30
|
-
|
|
31
|
-
}, l = {
|
|
29
|
+
shouldAutoScroll: !0
|
|
30
|
+
}, i = {
|
|
32
31
|
shouldBypassCaptcha: !1,
|
|
33
32
|
tags: [],
|
|
34
33
|
userProperties: {},
|
|
@@ -46,7 +45,7 @@ const i = {
|
|
|
46
45
|
view: "single-pane"
|
|
47
46
|
};
|
|
48
47
|
export {
|
|
49
|
-
|
|
50
|
-
|
|
48
|
+
l as defaultInkeepAIChatSettings,
|
|
49
|
+
i as defaultInkeepBaseSettings,
|
|
51
50
|
o as defaultInkeepSearchSettings
|
|
52
51
|
};
|
|
@@ -202,14 +202,6 @@ export interface InkeepAIChatSettings {
|
|
|
202
202
|
* @default true
|
|
203
203
|
*/
|
|
204
204
|
shouldAutoScroll?: boolean;
|
|
205
|
-
/**
|
|
206
|
-
* The bot protection check level applied to BotID-protected requests.
|
|
207
|
-
* - `'basic'`: lightweight challenge suitable for most traffic.
|
|
208
|
-
* - `'deepAnalysis'`: stricter analysis for high-risk surfaces (requires Vercel BotID Pro).
|
|
209
|
-
* @see https://vercel.com/docs/botid/advanced-configuration
|
|
210
|
-
* @default 'basic'
|
|
211
|
-
*/
|
|
212
|
-
botProtectionLevel?: 'basic' | 'deepAnalysis';
|
|
213
205
|
}
|
|
214
206
|
export interface AIChatDisclaimerSettings {
|
|
215
207
|
/**
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@inkeep/agents-ui",
|
|
3
|
-
"version": "0.0.0-dev-
|
|
3
|
+
"version": "0.0.0-dev-20260501215045",
|
|
4
4
|
"description": "",
|
|
5
5
|
"homepage": "",
|
|
6
6
|
"repository": {
|
|
@@ -72,8 +72,8 @@
|
|
|
72
72
|
"@zag-js/react": "^1.38.1",
|
|
73
73
|
"@zag-js/remove-scroll": "^1.38.1",
|
|
74
74
|
"ai": "6.0.44",
|
|
75
|
+
"altcha-lib": "^1.2.0",
|
|
75
76
|
"aria-hidden": "^1.2.4",
|
|
76
|
-
"botid": "^1.5.11",
|
|
77
77
|
"class-variance-authority": "0.7.1",
|
|
78
78
|
"clsx": "2.1.1",
|
|
79
79
|
"colorjs.io": "0.5.2",
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
"use strict";Object.defineProperty(exports,Symbol.toStringTag,{value:"Module"});function v(o){return new Promise((e,s)=>{if(document.querySelector(`script[src="${o}"]`)){e();return}let r=document.createElement("script");r.src=o,r.async=!0,r.onload=()=>e(),r.onerror=n=>{console.error("Error loading script",n),s(n)},document.head.appendChild(r)})}var L="/149e9513-01fa-4fb0-aad4-566afd725d1b/2d206a39-8ed7-437e-a3be-862e0f06eea3/a-4-a/c.js",R=class m{#e;#t;#r=0;constructor(){let{promise:e,resolve:s}=m.#i();this.#e=e,this.#t=s,this.#n(),window.addEventListener("online",this.#s),window.addEventListener("visibilitychange",this.#s)}getChallenge=async()=>(await this.#a(),await this.#e.then(e=>typeof e=="function"?e():e));#s=()=>{if(document.hidden)return;let{promise:e,resolve:s}=m.#i();this.#e=e,this.#t=s,window.V_C=[],window.V_C.push=s;let r=document.querySelector('script[src*="c.js"]');r&&r.remove(),this.#r+=1};#n=()=>{if(window.V_C){let e=window.V_C.pop();e&&this.#t(e)}else window.V_C=[],window.V_C.push=this.#t};#a=()=>{let e=new URL(L,window.location.origin);return e.searchParams.set("i",String(this.#r)),e.searchParams.set("v",String(3)),e.searchParams.set("h",window.location.host),v(e.pathname+e.search)};#o=()=>{window.V_C=void 0};static#i(){let e,s;return{promise:new Promise((r,n)=>{e=r,s=n}),resolve:e,reject:s}}},q="/149e9513-01fa-4fb0-aad4-566afd725d1b/2d206a39-8ed7-437e-a3be-862e0f06eea3",H=class g{#e=!1;#t;constructor(e){this.#t=e}get loaded(){return this.#e}load=async()=>{this.#e||await this.#s()};#r=()=>{if(typeof globalThis.window>"u")throw new Error("KPSDK is not available in the server");if(!window.KPSDK)throw new Error("KPSDK is not loaded");let e=this.#t.map(s=>{let r=g.#n(s.path);return{domain:r.host,path:r.pathname,method:s.method}});try{window.KPSDK.configure(e)}catch(s){console.error("Error configuring KPSDK...",s)}};#s=async()=>{let e=`${q}/p.js`,s=this;return new Promise((r,n)=>{let a=()=>{document.removeEventListener("kpsdk-load",a),this.#r()},d=()=>{document.removeEventListener("kpsdk-ready",d),s.#e=!0,r()};document.addEventListener("kpsdk-load",a,{once:!0}),document.addEventListener("kpsdk-ready",d,{once:!0}),v(e).catch(h=>{document.removeEventListener("kpsdk-load",a),document.removeEventListener("kpsdk-ready",d),n(h)})})};static#n(e){let s;try{s=new URL(e)}catch{s=new URL(e,location.origin)}return s}},y=o=>{let e=o.replace(/[.?+^$[\]\\(){}|-]/g,"\\$&").split("*").join(".*");return new RegExp(`^${e}$`)},b=({path:o,pattern:e})=>o.search(e)!==-1;function x(o,e,s){let r=window.fetch;window.fetch=async(n,a)=>{let d=new URL(n instanceof Request?n.url:n,location.href),h=d.origin===location.origin,u=a?.method??(n instanceof Request?n.method:"GET"),l=s.find(i=>{let w=b({path:d.pathname,pattern:y(i.path)}),f=i.method.toLowerCase()===u.toLowerCase()||i.method==="*";return w&&f});if(l==null||!h)return r(n,a);let p=await o.getChallenge(),c=new Headers(a?.headers||(n instanceof Request?n.headers:void 0));c.set("x-is-human",JSON.stringify(p)),c.set("x-path",d.pathname),c.set("x-method",u);let t={...a,headers:c};return e.loaded||p.b!==0?r(n,t):p.d===1||l?.advancedOptions?.checkLevel==="deepAnalysis"?(await e.load(),window.fetch(n,t)):r(n,t)}}async function E(o,e,s){let r=XMLHttpRequest.prototype.open,n=XMLHttpRequest.prototype.send;XMLHttpRequest.prototype.open=function(a,d,h,u,l){return this._requestUrl=d.toString(),this._requestMethod=a,r.call(this,a,d,h??!0,u,l)},XMLHttpRequest.prototype.send=async function(a){let d=this._requestUrl;if(!d)return n.call(this,a);if(this._isReexecution)return n.call(this,a);let h=new URL(d,location.href),u=h.origin===location.origin,l=this._requestMethod??"GET",p=s.find(i=>{let w=b({path:h.pathname,pattern:y(i.path)}),f=i.method.toLowerCase()===l.toLowerCase()||i.method==="*";return w&&f});if(!p||!u)return n.call(this,a);let c=await o.getChallenge();if(this.setRequestHeader("x-is-human",JSON.stringify(c)),this.setRequestHeader("x-path",h.pathname),this.setRequestHeader("x-method",l),c.b!==0)return n.call(this,a);if(e.loaded)return n.call(this,a);if((c.d===1||p?.advancedOptions?.checkLevel==="deepAnalysis")&&await e.load(),!e.loaded)return n.call(this,a);this.setRequestHeader("x-is-human",JSON.stringify(c)),this.setRequestHeader("x-path",h.pathname),this.setRequestHeader("x-method",l);let t=new XMLHttpRequest;return t._isReexecution=!0,t.open(l,d,!0),t.setRequestHeader("x-is-human",JSON.stringify(c)),t.setRequestHeader("x-path",h.pathname),t.setRequestHeader("x-method",l),this.timeout&&(t.timeout=this.timeout),this.responseType&&(t.responseType=this.responseType),this.withCredentials&&(t.withCredentials=this.withCredentials),t.onreadystatechange=()=>{Object.defineProperty(this,"readyState",{value:t.readyState,writable:!0,configurable:!0}),t.readyState===XMLHttpRequest.DONE&&(Object.defineProperty(this,"status",{value:t.status,writable:!0,configurable:!0}),Object.defineProperty(this,"statusText",{value:t.statusText,writable:!0,configurable:!0}),Object.defineProperty(this,"response",{value:t.response,writable:!0,configurable:!0}),Object.defineProperty(this,"responseText",{value:t.responseText,writable:!0,configurable:!0}),Object.defineProperty(this,"responseXML",{value:t.responseXML,writable:!0,configurable:!0}),this.getAllResponseHeaders=()=>t.getAllResponseHeaders(),this.getResponseHeader=i=>t.getResponseHeader(i)),this.onreadystatechange&&this.onreadystatechange.call(this,new Event("readystatechange"))},t.onload=i=>{this.onload&&this.onload.call(this,i)},t.onerror=i=>{this.onerror&&this.onerror.call(this,i)},t.onabort=i=>{this.onabort&&this.onabort.call(this,i)},t.ontimeout=i=>{this.ontimeout&&this.ontimeout.call(this,i)},t.onloadstart=i=>{this.onloadstart&&this.onloadstart.call(this,i)},t.onloadend=i=>{this.onloadend&&this.onloadend.call(this,i)},t.onprogress=i=>{this.onprogress&&this.onprogress.call(this,i)},t.send(a)}}function k({protect:o=[]}){for(let r of o)if(r.advancedOptions?.checkLevel!==void 0&&r.advancedOptions.checkLevel!=="deepAnalysis"&&r.advancedOptions.checkLevel!=="basic")throw new Error(`Invalid checkLevel "${r.advancedOptions.checkLevel}" for route "${r.path}". Must be one of: deepAnalysis, basic`);let e=new R,s=new H(o);E(e,s,o).catch(r=>{console.error("Error patching XMLHttpRequest:",r)}),x(e,s,o)}exports.initBotId=k;
|
|
@@ -1,160 +0,0 @@
|
|
|
1
|
-
function v(o) {
|
|
2
|
-
return new Promise((e, s) => {
|
|
3
|
-
if (document.querySelector(`script[src="${o}"]`)) {
|
|
4
|
-
e();
|
|
5
|
-
return;
|
|
6
|
-
}
|
|
7
|
-
let r = document.createElement("script");
|
|
8
|
-
r.src = o, r.async = !0, r.onload = () => e(), r.onerror = (n) => {
|
|
9
|
-
console.error("Error loading script", n), s(n);
|
|
10
|
-
}, document.head.appendChild(r);
|
|
11
|
-
});
|
|
12
|
-
}
|
|
13
|
-
var L = "/149e9513-01fa-4fb0-aad4-566afd725d1b/2d206a39-8ed7-437e-a3be-862e0f06eea3/a-4-a/c.js", R = class m {
|
|
14
|
-
#e;
|
|
15
|
-
#t;
|
|
16
|
-
#r = 0;
|
|
17
|
-
constructor() {
|
|
18
|
-
let { promise: e, resolve: s } = m.#a();
|
|
19
|
-
this.#e = e, this.#t = s, this.#n(), window.addEventListener("online", this.#s), window.addEventListener("visibilitychange", this.#s);
|
|
20
|
-
}
|
|
21
|
-
getChallenge = async () => (await this.#i(), await this.#e.then((e) => typeof e == "function" ? e() : e));
|
|
22
|
-
#s = () => {
|
|
23
|
-
if (document.hidden) return;
|
|
24
|
-
let { promise: e, resolve: s } = m.#a();
|
|
25
|
-
this.#e = e, this.#t = s, window.V_C = [], window.V_C.push = s;
|
|
26
|
-
let r = document.querySelector('script[src*="c.js"]');
|
|
27
|
-
r && r.remove(), this.#r += 1;
|
|
28
|
-
};
|
|
29
|
-
#n = () => {
|
|
30
|
-
if (window.V_C) {
|
|
31
|
-
let e = window.V_C.pop();
|
|
32
|
-
e && this.#t(e);
|
|
33
|
-
} else window.V_C = [], window.V_C.push = this.#t;
|
|
34
|
-
};
|
|
35
|
-
#i = () => {
|
|
36
|
-
let e = new URL(L, window.location.origin);
|
|
37
|
-
return e.searchParams.set("i", String(this.#r)), e.searchParams.set("v", String(3)), e.searchParams.set("h", window.location.host), v(e.pathname + e.search);
|
|
38
|
-
};
|
|
39
|
-
#o = () => {
|
|
40
|
-
window.V_C = void 0;
|
|
41
|
-
};
|
|
42
|
-
static #a() {
|
|
43
|
-
let e, s;
|
|
44
|
-
return { promise: new Promise((r, n) => {
|
|
45
|
-
e = r, s = n;
|
|
46
|
-
}), resolve: e, reject: s };
|
|
47
|
-
}
|
|
48
|
-
}, q = "/149e9513-01fa-4fb0-aad4-566afd725d1b/2d206a39-8ed7-437e-a3be-862e0f06eea3", x = class g {
|
|
49
|
-
#e = !1;
|
|
50
|
-
#t;
|
|
51
|
-
constructor(e) {
|
|
52
|
-
this.#t = e;
|
|
53
|
-
}
|
|
54
|
-
get loaded() {
|
|
55
|
-
return this.#e;
|
|
56
|
-
}
|
|
57
|
-
load = async () => {
|
|
58
|
-
this.#e || await this.#s();
|
|
59
|
-
};
|
|
60
|
-
#r = () => {
|
|
61
|
-
if (typeof globalThis.window > "u") throw new Error("KPSDK is not available in the server");
|
|
62
|
-
if (!window.KPSDK) throw new Error("KPSDK is not loaded");
|
|
63
|
-
let e = this.#t.map((s) => {
|
|
64
|
-
let r = g.#n(s.path);
|
|
65
|
-
return { domain: r.host, path: r.pathname, method: s.method };
|
|
66
|
-
});
|
|
67
|
-
try {
|
|
68
|
-
window.KPSDK.configure(e);
|
|
69
|
-
} catch (s) {
|
|
70
|
-
console.error("Error configuring KPSDK...", s);
|
|
71
|
-
}
|
|
72
|
-
};
|
|
73
|
-
#s = async () => {
|
|
74
|
-
let e = `${q}/p.js`, s = this;
|
|
75
|
-
return new Promise((r, n) => {
|
|
76
|
-
let i = () => {
|
|
77
|
-
document.removeEventListener("kpsdk-load", i), this.#r();
|
|
78
|
-
}, d = () => {
|
|
79
|
-
document.removeEventListener("kpsdk-ready", d), s.#e = !0, r();
|
|
80
|
-
};
|
|
81
|
-
document.addEventListener("kpsdk-load", i, { once: !0 }), document.addEventListener("kpsdk-ready", d, { once: !0 }), v(e).catch((h) => {
|
|
82
|
-
document.removeEventListener("kpsdk-load", i), document.removeEventListener("kpsdk-ready", d), n(h);
|
|
83
|
-
});
|
|
84
|
-
});
|
|
85
|
-
};
|
|
86
|
-
static #n(e) {
|
|
87
|
-
let s;
|
|
88
|
-
try {
|
|
89
|
-
s = new URL(e);
|
|
90
|
-
} catch {
|
|
91
|
-
s = new URL(e, location.origin);
|
|
92
|
-
}
|
|
93
|
-
return s;
|
|
94
|
-
}
|
|
95
|
-
}, y = (o) => {
|
|
96
|
-
let e = o.replace(/[.?+^$[\]\\(){}|-]/g, "\\$&").split("*").join(".*");
|
|
97
|
-
return new RegExp(`^${e}$`);
|
|
98
|
-
}, b = ({ path: o, pattern: e }) => o.search(e) !== -1;
|
|
99
|
-
function H(o, e, s) {
|
|
100
|
-
let r = window.fetch;
|
|
101
|
-
window.fetch = async (n, i) => {
|
|
102
|
-
let d = new URL(n instanceof Request ? n.url : n, location.href), h = d.origin === location.origin, u = i?.method ?? (n instanceof Request ? n.method : "GET"), l = s.find((a) => {
|
|
103
|
-
let w = b({ path: d.pathname, pattern: y(a.path) }), f = a.method.toLowerCase() === u.toLowerCase() || a.method === "*";
|
|
104
|
-
return w && f;
|
|
105
|
-
});
|
|
106
|
-
if (l == null || !h) return r(n, i);
|
|
107
|
-
let p = await o.getChallenge(), c = new Headers(i?.headers || (n instanceof Request ? n.headers : void 0));
|
|
108
|
-
c.set("x-is-human", JSON.stringify(p)), c.set("x-path", d.pathname), c.set("x-method", u);
|
|
109
|
-
let t = { ...i, headers: c };
|
|
110
|
-
return e.loaded || p.b !== 0 ? r(n, t) : p.d === 1 || l?.advancedOptions?.checkLevel === "deepAnalysis" ? (await e.load(), window.fetch(n, t)) : r(n, t);
|
|
111
|
-
};
|
|
112
|
-
}
|
|
113
|
-
async function E(o, e, s) {
|
|
114
|
-
let r = XMLHttpRequest.prototype.open, n = XMLHttpRequest.prototype.send;
|
|
115
|
-
XMLHttpRequest.prototype.open = function(i, d, h, u, l) {
|
|
116
|
-
return this._requestUrl = d.toString(), this._requestMethod = i, r.call(this, i, d, h ?? !0, u, l);
|
|
117
|
-
}, XMLHttpRequest.prototype.send = async function(i) {
|
|
118
|
-
let d = this._requestUrl;
|
|
119
|
-
if (!d) return n.call(this, i);
|
|
120
|
-
if (this._isReexecution) return n.call(this, i);
|
|
121
|
-
let h = new URL(d, location.href), u = h.origin === location.origin, l = this._requestMethod ?? "GET", p = s.find((a) => {
|
|
122
|
-
let w = b({ path: h.pathname, pattern: y(a.path) }), f = a.method.toLowerCase() === l.toLowerCase() || a.method === "*";
|
|
123
|
-
return w && f;
|
|
124
|
-
});
|
|
125
|
-
if (!p || !u) return n.call(this, i);
|
|
126
|
-
let c = await o.getChallenge();
|
|
127
|
-
if (this.setRequestHeader("x-is-human", JSON.stringify(c)), this.setRequestHeader("x-path", h.pathname), this.setRequestHeader("x-method", l), c.b !== 0) return n.call(this, i);
|
|
128
|
-
if (e.loaded) return n.call(this, i);
|
|
129
|
-
if ((c.d === 1 || p?.advancedOptions?.checkLevel === "deepAnalysis") && await e.load(), !e.loaded) return n.call(this, i);
|
|
130
|
-
this.setRequestHeader("x-is-human", JSON.stringify(c)), this.setRequestHeader("x-path", h.pathname), this.setRequestHeader("x-method", l);
|
|
131
|
-
let t = new XMLHttpRequest();
|
|
132
|
-
return t._isReexecution = !0, t.open(l, d, !0), t.setRequestHeader("x-is-human", JSON.stringify(c)), t.setRequestHeader("x-path", h.pathname), t.setRequestHeader("x-method", l), this.timeout && (t.timeout = this.timeout), this.responseType && (t.responseType = this.responseType), this.withCredentials && (t.withCredentials = this.withCredentials), t.onreadystatechange = () => {
|
|
133
|
-
Object.defineProperty(this, "readyState", { value: t.readyState, writable: !0, configurable: !0 }), t.readyState === XMLHttpRequest.DONE && (Object.defineProperty(this, "status", { value: t.status, writable: !0, configurable: !0 }), Object.defineProperty(this, "statusText", { value: t.statusText, writable: !0, configurable: !0 }), Object.defineProperty(this, "response", { value: t.response, writable: !0, configurable: !0 }), Object.defineProperty(this, "responseText", { value: t.responseText, writable: !0, configurable: !0 }), Object.defineProperty(this, "responseXML", { value: t.responseXML, writable: !0, configurable: !0 }), this.getAllResponseHeaders = () => t.getAllResponseHeaders(), this.getResponseHeader = (a) => t.getResponseHeader(a)), this.onreadystatechange && this.onreadystatechange.call(this, new Event("readystatechange"));
|
|
134
|
-
}, t.onload = (a) => {
|
|
135
|
-
this.onload && this.onload.call(this, a);
|
|
136
|
-
}, t.onerror = (a) => {
|
|
137
|
-
this.onerror && this.onerror.call(this, a);
|
|
138
|
-
}, t.onabort = (a) => {
|
|
139
|
-
this.onabort && this.onabort.call(this, a);
|
|
140
|
-
}, t.ontimeout = (a) => {
|
|
141
|
-
this.ontimeout && this.ontimeout.call(this, a);
|
|
142
|
-
}, t.onloadstart = (a) => {
|
|
143
|
-
this.onloadstart && this.onloadstart.call(this, a);
|
|
144
|
-
}, t.onloadend = (a) => {
|
|
145
|
-
this.onloadend && this.onloadend.call(this, a);
|
|
146
|
-
}, t.onprogress = (a) => {
|
|
147
|
-
this.onprogress && this.onprogress.call(this, a);
|
|
148
|
-
}, t.send(i);
|
|
149
|
-
};
|
|
150
|
-
}
|
|
151
|
-
function k({ protect: o = [] }) {
|
|
152
|
-
for (let r of o) if (r.advancedOptions?.checkLevel !== void 0 && r.advancedOptions.checkLevel !== "deepAnalysis" && r.advancedOptions.checkLevel !== "basic") throw new Error(`Invalid checkLevel "${r.advancedOptions.checkLevel}" for route "${r.path}". Must be one of: deepAnalysis, basic`);
|
|
153
|
-
let e = new R(), s = new x(o);
|
|
154
|
-
E(e, s, o).catch((r) => {
|
|
155
|
-
console.error("Error patching XMLHttpRequest:", r);
|
|
156
|
-
}), H(e, s, o);
|
|
157
|
-
}
|
|
158
|
-
export {
|
|
159
|
-
k as initBotId
|
|
160
|
-
};
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
"use client";"use strict";Object.defineProperty(exports,Symbol.toStringTag,{value:"Module"});const g=require("react"),I=require("../../node_modules/.pnpm/botid@1.5.11_next@16.2.4_@babel_core@7.29.0_@opentelemetry_api@1.9.1_react-dom@19.3.0-c_6ac35f5bf61166da3243b6cf36e09c95/node_modules/botid/dist/client/core/index.cjs"),m=require("./config-provider.cjs");function _(){const{baseSettings:f,aiChatSettings:b}=m.useInkeepConfig(),{shouldBypassCaptcha:c}=f,{baseUrl:r,apiKey:l,botProtectionLevel:d}=b,u=g.useRef(!1);return g.useEffect(()=>{if(u.current||c||l||!r)return;if(typeof window<"u"&&!window.__INKEEP_FETCH_DEBUG__){window.__INKEEP_FETCH_DEBUG__=!0;const o=window.fetch;window.fetch=async function(e,n){let i;typeof e=="string"?i=e:e instanceof URL?i=e.toString():i=e.url;try{const t=new URL(i,location.href);if(t.pathname.startsWith("/run/")){const s=new Headers(n?.headers??(e instanceof Request?e.headers:void 0)),w=n?.method??(e instanceof Request?e.method:"GET");console.log("[botid-debug] fetch →",{url:t.toString(),method:w,locationOrigin:location.origin,targetOrigin:t.origin,sameOrigin:t.origin===location.origin,hasXIsHuman:s.has("x-is-human"),xIsHumanLength:s.get("x-is-human")?.length??null,xPath:s.get("x-path"),xMethod:s.get("x-method")});const a=await o.call(this,e,n);return console.log("[botid-debug] fetch ←",{url:t.toString(),status:a.status,statusText:a.statusText}),a}}catch{}return o.call(this,e,n)}}const h={checkLevel:d};try{console.log("[botid-debug] calling initBotId",{baseUrl:r,advancedOptions:h}),I.initBotId({protect:[{path:"*",method:"POST",advancedOptions:h}]}),u.current=!0,console.log("[botid-debug] initBotId returned successfully")}catch(o){console.warn("[botid-debug] initBotId threw",o)}},[r,l,c,d]),null}exports.BotIdInitializer=_;
|
|
@@ -1,15 +0,0 @@
|
|
|
1
|
-
/**
|
|
2
|
-
* One-shot Vercel BotID client initializer. Mounts once at the top of the widget
|
|
3
|
-
* tree, calls `initBotId({ protect })` if bot protection is enabled and we have
|
|
4
|
-
* a baseUrl. The BotID SDK then patches `window.fetch` and `XMLHttpRequest` to
|
|
5
|
-
* attach `x-is-human` headers on requests matching the protect list.
|
|
6
|
-
*
|
|
7
|
-
* Initialization is gated:
|
|
8
|
-
* - Skipped when `shouldBypassCaptcha` is true (server-side API key flow).
|
|
9
|
-
* - Skipped when `apiKey` is set (consumer authenticated server-side already).
|
|
10
|
-
* - Skipped when no `baseUrl` is configured (nothing to protect against).
|
|
11
|
-
*
|
|
12
|
-
* Initialization is idempotent — `initBotId` is called at most once per page
|
|
13
|
-
* session even if the widget remounts.
|
|
14
|
-
*/
|
|
15
|
-
export declare function BotIdInitializer(): null;
|
|
@@ -1,69 +0,0 @@
|
|
|
1
|
-
"use client";
|
|
2
|
-
import { useRef as w, useEffect as b } from "react";
|
|
3
|
-
import { initBotId as I } from "../../node_modules/.pnpm/botid@1.5.11_next@16.2.4_@babel_core@7.29.0_@opentelemetry_api@1.9.1_react-dom@19.3.0-c_6ac35f5bf61166da3243b6cf36e09c95/node_modules/botid/dist/client/core/index.js";
|
|
4
|
-
import { useInkeepConfig as _ } from "./config-provider.js";
|
|
5
|
-
function C() {
|
|
6
|
-
const { baseSettings: f, aiChatSettings: g } = _(), { shouldBypassCaptcha: c } = f, { baseUrl: r, apiKey: l, botProtectionLevel: d } = g, h = w(!1);
|
|
7
|
-
return b(() => {
|
|
8
|
-
if (h.current || c || l || !r) return;
|
|
9
|
-
if (typeof window < "u" && !window.__INKEEP_FETCH_DEBUG__) {
|
|
10
|
-
window.__INKEEP_FETCH_DEBUG__ = !0;
|
|
11
|
-
const o = window.fetch;
|
|
12
|
-
window.fetch = async function(t, n) {
|
|
13
|
-
let s;
|
|
14
|
-
typeof t == "string" ? s = t : t instanceof URL ? s = t.toString() : s = t.url;
|
|
15
|
-
try {
|
|
16
|
-
const e = new URL(s, location.href);
|
|
17
|
-
if (e.pathname.startsWith("/run/")) {
|
|
18
|
-
const i = new Headers(
|
|
19
|
-
n?.headers ?? (t instanceof Request ? t.headers : void 0)
|
|
20
|
-
), m = n?.method ?? (t instanceof Request ? t.method : "GET");
|
|
21
|
-
console.log("[botid-debug] fetch →", {
|
|
22
|
-
url: e.toString(),
|
|
23
|
-
method: m,
|
|
24
|
-
locationOrigin: location.origin,
|
|
25
|
-
targetOrigin: e.origin,
|
|
26
|
-
sameOrigin: e.origin === location.origin,
|
|
27
|
-
hasXIsHuman: i.has("x-is-human"),
|
|
28
|
-
xIsHumanLength: i.get("x-is-human")?.length ?? null,
|
|
29
|
-
xPath: i.get("x-path"),
|
|
30
|
-
xMethod: i.get("x-method")
|
|
31
|
-
});
|
|
32
|
-
const a = await o.call(this, t, n);
|
|
33
|
-
return console.log("[botid-debug] fetch ←", {
|
|
34
|
-
url: e.toString(),
|
|
35
|
-
status: a.status,
|
|
36
|
-
statusText: a.statusText
|
|
37
|
-
}), a;
|
|
38
|
-
}
|
|
39
|
-
} catch {
|
|
40
|
-
}
|
|
41
|
-
return o.call(this, t, n);
|
|
42
|
-
};
|
|
43
|
-
}
|
|
44
|
-
const u = { checkLevel: d };
|
|
45
|
-
try {
|
|
46
|
-
console.log("[botid-debug] calling initBotId", { baseUrl: r, advancedOptions: u }), I({
|
|
47
|
-
protect: [
|
|
48
|
-
{
|
|
49
|
-
path: "*",
|
|
50
|
-
method: "POST",
|
|
51
|
-
advancedOptions: u
|
|
52
|
-
}
|
|
53
|
-
// {
|
|
54
|
-
// path: `${baseUrl}/run/auth/apps/*/anonymous-session`,
|
|
55
|
-
// method: 'POST',
|
|
56
|
-
// advancedOptions,
|
|
57
|
-
// },
|
|
58
|
-
// { path: `${baseUrl}/run/api/chat`, method: 'POST', advancedOptions },
|
|
59
|
-
// { path: `${baseUrl}/run/v1/feedback`, method: 'POST', advancedOptions },
|
|
60
|
-
]
|
|
61
|
-
}), h.current = !0, console.log("[botid-debug] initBotId returned successfully");
|
|
62
|
-
} catch (o) {
|
|
63
|
-
console.warn("[botid-debug] initBotId threw", o);
|
|
64
|
-
}
|
|
65
|
-
}, [r, l, c, d]), null;
|
|
66
|
-
}
|
|
67
|
-
export {
|
|
68
|
-
C as BotIdInitializer
|
|
69
|
-
};
|