@inkeep/agents-ui 0.0.0-dev-20260501021535 → 0.0.0-dev-20260501182500
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/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 +1 -0
- 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 +160 -0
- package/dist/primitives/components/embedded-chat/chat-error-helpers.d.ts +4 -2
- package/dist/primitives/components/embedded-chat/use-inkeep-chat.cjs +2 -2
- package/dist/primitives/components/embedded-chat/use-inkeep-chat.d.ts +0 -2
- package/dist/primitives/components/embedded-chat/use-inkeep-chat.js +237 -262
- package/dist/primitives/hooks/use-anonymous-session.cjs +1 -1
- package/dist/primitives/hooks/use-anonymous-session.d.ts +1 -3
- package/dist/primitives/hooks/use-anonymous-session.js +51 -56
- package/dist/primitives/hooks/use-conversation-loader.cjs +1 -1
- package/dist/primitives/hooks/use-conversation-loader.d.ts +1 -3
- package/dist/primitives/hooks/use-conversation-loader.js +15 -20
- package/dist/primitives/hooks/use-feedback-api.cjs +1 -1
- package/dist/primitives/hooks/use-feedback-api.d.ts +1 -3
- package/dist/primitives/hooks/use-feedback-api.js +16 -22
- package/dist/primitives/hooks/use-inkeep-api-client.cjs +1 -1
- package/dist/primitives/hooks/use-inkeep-api-client.d.ts +8 -11
- package/dist/primitives/hooks/use-inkeep-api-client.js +36 -64
- package/dist/primitives/providers/botid-initializer.cjs +1 -0
- package/dist/primitives/providers/botid-initializer.d.ts +15 -0
- package/dist/primitives/providers/botid-initializer.js +64 -0
- package/dist/primitives/providers/chat-history-provider.cjs +1 -1
- package/dist/primitives/providers/chat-history-provider.js +35 -39
- package/dist/primitives/providers/feedback-provider.cjs +1 -1
- package/dist/primitives/providers/feedback-provider.js +26 -35
- package/dist/primitives/providers/root-provider.cjs +1 -1
- package/dist/primitives/providers/root-provider.js +13 -9
- package/dist/primitives/utils/default-settings.cjs +1 -1
- package/dist/primitives/utils/default-settings.d.ts +1 -0
- package/dist/primitives/utils/default-settings.js +6 -5
- package/dist/types/config/ai.d.ts +8 -0
- package/package.json +2 -2
- package/dist/primitives/components/embedded-chat/use-captcha.cjs +0 -1
- package/dist/primitives/components/embedded-chat/use-captcha.d.ts +0 -30
- package/dist/primitives/components/embedded-chat/use-captcha.js +0 -67
|
@@ -1,29 +1,25 @@
|
|
|
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 te } from "react/jsx-runtime";
|
|
3
|
+
import { useContext as ne, useState as h, useRef as c, useEffect as y, useCallback as S, createContext as se } from "react";
|
|
4
|
+
import { useChat as re } from "../components/embedded-chat/chat-provider.js";
|
|
5
|
+
import { useInkeepConfig as oe } from "./config-provider.js";
|
|
6
|
+
import { useInkeepApiClient as ie } from "../hooks/use-inkeep-api-client.js";
|
|
7
|
+
const z = se(void 0), q = 25;
|
|
8
|
+
function ae(e) {
|
|
9
9
|
const {
|
|
10
10
|
stop: u,
|
|
11
11
|
clear: f,
|
|
12
12
|
conversationId: d,
|
|
13
|
-
isStreaming:
|
|
13
|
+
isStreaming: H,
|
|
14
14
|
loadAndRestoreSession: P,
|
|
15
15
|
authToken: t,
|
|
16
|
-
refreshSession: B
|
|
17
|
-
|
|
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({
|
|
16
|
+
refreshSession: B
|
|
17
|
+
} = re(), { aiChatSettings: J, baseSettings: Q } = oe(), { baseUrl: w, appId: x, apiKey: V } = J, i = !!Q.getAuthToken, r = !V && !!x && (!!t || i), { fetchWithAuth: E } = ie({
|
|
20
18
|
appId: x,
|
|
21
19
|
authToken: t,
|
|
22
|
-
getCaptchaHeader: J,
|
|
23
|
-
invalidateCaptcha: Q,
|
|
24
20
|
refreshSession: B
|
|
25
21
|
}), [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);
|
|
26
|
-
|
|
22
|
+
y(() => {
|
|
27
23
|
const s = F.current, n = O.current;
|
|
28
24
|
F.current = i, O.current = t, (s !== i || n !== null && t !== null && n !== t) && (T([]), M(0), j(!1), p.current = !1);
|
|
29
25
|
}, [i, t]);
|
|
@@ -36,9 +32,9 @@ function ue(e) {
|
|
|
36
32
|
if (!(!w || !t || !r)) {
|
|
37
33
|
n || $(!0);
|
|
38
34
|
try {
|
|
39
|
-
const
|
|
40
|
-
if (!
|
|
41
|
-
const U = await
|
|
35
|
+
const g = `${w}/run/v1/conversations?page=${s + 1}&limit=${q}`, C = await G.current(g);
|
|
36
|
+
if (!C.ok) throw new Error(`Failed to fetch conversations: ${C.status}`);
|
|
37
|
+
const U = await C.json(), v = (U.data ?? []).map((o) => ({
|
|
42
38
|
id: o.id,
|
|
43
39
|
title: o.title ?? "",
|
|
44
40
|
createdAt: new Date(o.createdAt),
|
|
@@ -50,13 +46,13 @@ function ue(e) {
|
|
|
50
46
|
const l = new Set(v.map((I) => I.id));
|
|
51
47
|
return [...v, ...o.slice(q).filter((I) => !l.has(I.id))];
|
|
52
48
|
}
|
|
53
|
-
const
|
|
54
|
-
return [...o, ...v.filter((l) => !
|
|
49
|
+
const ee = new Set(o.map((l) => l.id));
|
|
50
|
+
return [...o, ...v.filter((l) => !ee.has(l.id))];
|
|
55
51
|
});
|
|
56
52
|
const { page: Z, pages: _ } = U.pagination ?? {};
|
|
57
53
|
j(Z != null && _ != null ? Z < _ : !1), n || M(s);
|
|
58
|
-
} catch (
|
|
59
|
-
console.error("[useChatHistory] Failed to load conversations:",
|
|
54
|
+
} catch (g) {
|
|
55
|
+
console.error("[useChatHistory] Failed to load conversations:", g);
|
|
60
56
|
} finally {
|
|
61
57
|
$(!1);
|
|
62
58
|
}
|
|
@@ -64,18 +60,18 @@ function ue(e) {
|
|
|
64
60
|
},
|
|
65
61
|
[w, t, r]
|
|
66
62
|
);
|
|
67
|
-
|
|
63
|
+
y(() => {
|
|
68
64
|
!m || !t && !i || !r || (e === "stack" ? a(0) : !p.current && t && (p.current = !0, a(0)));
|
|
69
65
|
}, [m, t, i, r, e, a]);
|
|
70
66
|
const K = c("");
|
|
71
|
-
|
|
72
|
-
r && e === "sidepane" && (!d || !
|
|
73
|
-
}, [d, r, e, a,
|
|
74
|
-
const
|
|
67
|
+
y(() => {
|
|
68
|
+
r && e === "sidepane" && (!d || !H || p.current && K.current !== d && (W.current.some((s) => s.id === d) || (K.current = d, a(0, !0))));
|
|
69
|
+
}, [d, r, e, a, H]);
|
|
70
|
+
const X = S(() => {
|
|
75
71
|
!b && k && a(L + 1);
|
|
76
|
-
}, [b, k, L, a]),
|
|
72
|
+
}, [b, k, L, a]), Y = S(() => {
|
|
77
73
|
u(), f(), e !== "sidepane" && A(!1);
|
|
78
|
-
}, [e, u, f]),
|
|
74
|
+
}, [e, u, f]), N = S(
|
|
79
75
|
async (s) => {
|
|
80
76
|
D.current?.abort();
|
|
81
77
|
const n = new AbortController();
|
|
@@ -90,21 +86,21 @@ function ue(e) {
|
|
|
90
86
|
sessions: R,
|
|
91
87
|
isLoading: b,
|
|
92
88
|
hasMore: k,
|
|
93
|
-
loadMore:
|
|
94
|
-
startNewConversation:
|
|
95
|
-
loadSession:
|
|
89
|
+
loadMore: X,
|
|
90
|
+
startNewConversation: Y,
|
|
91
|
+
loadSession: N
|
|
96
92
|
};
|
|
97
93
|
}
|
|
98
|
-
const
|
|
99
|
-
const f =
|
|
100
|
-
return /* @__PURE__ */
|
|
101
|
-
},
|
|
102
|
-
const e =
|
|
94
|
+
const pe = ({ layout: e, children: u }) => {
|
|
95
|
+
const f = ae(e);
|
|
96
|
+
return /* @__PURE__ */ te(z.Provider, { value: f, children: typeof u == "function" ? u(f) : u });
|
|
97
|
+
}, ge = () => {
|
|
98
|
+
const e = ne(z);
|
|
103
99
|
if (!e)
|
|
104
100
|
throw new Error("useChatHistory must be used within a ChatHistoryProvider");
|
|
105
101
|
return e;
|
|
106
102
|
};
|
|
107
103
|
export {
|
|
108
|
-
|
|
109
|
-
|
|
104
|
+
pe as ChatHistoryProvider,
|
|
105
|
+
ge as useChatHistory
|
|
110
106
|
};
|
|
@@ -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 x=require("react/jsx-runtime"),c=require("react"),S=require("../components/embedded-chat/chat-provider.cjs"),F=require("../utils/misc.cjs"),M=require("./config-provider.cjs"),T=require("./base-events-provider.cjs"),A=require("../hooks/use-feedback-api.cjs"),l=c.createContext(void 0);function E(){const{baseSettings:t,aiChatSettings:o}=M.useInkeepConfig(),[p,g]=c.useState(null),[f,m]=c.useState({}),{conversationId:a,messages:r,authToken:C,refreshSession:P}=S.useChat(),{analyticsProperties:d}=t,{logEvent:b}=T.useBaseEvents(),{submitFeedback:k}=A.useFeedbackApi({baseUrl:o.baseUrl,appId:o.appId,authToken:C,refreshSession:P}),i=c.useCallback(async(e,s,u)=>{m(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:a,messageId:e,type:s,details:u}).catch(n=>console.warn("[feedback] submitFeedbackToApi error:",n));const v=r.findIndex(n=>n.id===e),_=r[v],w={conversationId:a,question:F.getMessageContent(r[v-1]),answer:F.getMessageContent(_),messageId:e,details:u};b({eventName:s==="positive"?"assistant_positive_feedback_submitted":"assistant_negative_feedback_submitted",properties:w}),s==="negative"&&b({eventName:"user_escalation_indicated",properties:{escalationType:"downvote",conversationId:a}})},[r,a,d,t,b,k]),h=c.useCallback(async e=>{i(e,"positive")},[i]),q=c.useCallback(async(e,s)=>{i(e,"negative",s)},[i]);return{feedback:f,currentFeedback:p,setCurrentFeedback:g,submitPositiveFeedback:h,submitNegativeFeedback:q}}const j=({children:t})=>{const o=E();return x.jsx(l.Provider,{value:o,children:t})},y=()=>{const t=c.useContext(l);if(!t)throw new Error("useFeedback must be used within a FeedbackProvider");return t};exports.FeedbackProvider=j;exports.useMessageFeedback=y;
|
|
@@ -1,42 +1,33 @@
|
|
|
1
1
|
"use client";
|
|
2
|
-
import { jsx as
|
|
3
|
-
import { useContext as
|
|
4
|
-
import { useChat as
|
|
2
|
+
import { jsx as T } from "react/jsx-runtime";
|
|
3
|
+
import { useContext as A, useState as m, useCallback as d, createContext as E } from "react";
|
|
4
|
+
import { useChat as N } 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 } =
|
|
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({
|
|
6
|
+
import { useInkeepConfig as M } from "./config-provider.js";
|
|
7
|
+
import { useBaseEvents as U } from "./base-events-provider.js";
|
|
8
|
+
import { useFeedbackApi as j } from "../hooks/use-feedback-api.js";
|
|
9
|
+
const f = E(void 0);
|
|
10
|
+
function q() {
|
|
11
|
+
const { baseSettings: t, aiChatSettings: n } = M(), [F, l] = m(null), [g, C] = m({}), { conversationId: a, messages: c, authToken: h, refreshSession: _ } = N(), { analyticsProperties: u } = t, { logEvent: b } = U(), { submitFeedback: k } = j({
|
|
19
12
|
baseUrl: n.baseUrl,
|
|
20
13
|
appId: n.appId,
|
|
21
14
|
authToken: h,
|
|
22
|
-
|
|
23
|
-
invalidateCaptcha: w,
|
|
24
|
-
refreshSession: x
|
|
15
|
+
refreshSession: _
|
|
25
16
|
}), r = d(
|
|
26
17
|
async (e, s, i) => {
|
|
27
|
-
|
|
18
|
+
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(
|
|
28
19
|
(o) => console.warn("[feedback] submitFeedbackToApi error:", o)
|
|
29
20
|
);
|
|
30
|
-
const p = c.findIndex((o) => o.id === e),
|
|
21
|
+
const p = c.findIndex((o) => o.id === e), P = c[p], S = {
|
|
31
22
|
conversationId: a,
|
|
32
23
|
question: v(c[p - 1]),
|
|
33
|
-
answer: v(
|
|
24
|
+
answer: v(P),
|
|
34
25
|
messageId: e,
|
|
35
26
|
details: i
|
|
36
27
|
};
|
|
37
28
|
b({
|
|
38
29
|
eventName: s === "positive" ? "assistant_positive_feedback_submitted" : "assistant_negative_feedback_submitted",
|
|
39
|
-
properties:
|
|
30
|
+
properties: S
|
|
40
31
|
}), s === "negative" && b({
|
|
41
32
|
eventName: "user_escalation_indicated",
|
|
42
33
|
properties: {
|
|
@@ -46,35 +37,35 @@ function B() {
|
|
|
46
37
|
});
|
|
47
38
|
},
|
|
48
39
|
[c, a, u, t, b, k]
|
|
49
|
-
),
|
|
40
|
+
), w = d(
|
|
50
41
|
async (e) => {
|
|
51
42
|
r(e, "positive");
|
|
52
43
|
},
|
|
53
44
|
[r]
|
|
54
|
-
),
|
|
45
|
+
), x = d(
|
|
55
46
|
async (e, s) => {
|
|
56
47
|
r(e, "negative", s);
|
|
57
48
|
},
|
|
58
49
|
[r]
|
|
59
50
|
);
|
|
60
51
|
return {
|
|
61
|
-
feedback:
|
|
52
|
+
feedback: g,
|
|
62
53
|
currentFeedback: F,
|
|
63
54
|
setCurrentFeedback: l,
|
|
64
|
-
submitPositiveFeedback:
|
|
65
|
-
submitNegativeFeedback:
|
|
55
|
+
submitPositiveFeedback: w,
|
|
56
|
+
submitNegativeFeedback: x
|
|
66
57
|
};
|
|
67
58
|
}
|
|
68
|
-
const
|
|
69
|
-
const n =
|
|
70
|
-
return /* @__PURE__ */
|
|
71
|
-
},
|
|
72
|
-
const t =
|
|
59
|
+
const J = ({ children: t }) => {
|
|
60
|
+
const n = q();
|
|
61
|
+
return /* @__PURE__ */ T(f.Provider, { value: n, children: t });
|
|
62
|
+
}, K = () => {
|
|
63
|
+
const t = A(f);
|
|
73
64
|
if (!t)
|
|
74
65
|
throw new Error("useFeedback must be used within a FeedbackProvider");
|
|
75
66
|
return t;
|
|
76
67
|
};
|
|
77
68
|
export {
|
|
78
|
-
|
|
79
|
-
|
|
69
|
+
J as FeedbackProvider,
|
|
70
|
+
K as useMessageFeedback
|
|
80
71
|
};
|
|
@@ -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("./config-provider.cjs"),
|
|
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("./botid-initializer.cjs"),c=require("./config-provider.cjs"),d=require("./theme-provider.cjs");function u(r){const{children:i,config:o,componentType:n}=r;return e.jsxs(c.InkeepConfigProvider,{value:{...o,componentType:n},children:[e.jsx(s.BotIdInitializer,{}),e.jsx(d.ThemeProvider,{children:e.jsx(t.BaseEventsProvider,{children:i})})]})}exports.RootProvider=u;
|
|
@@ -1,21 +1,25 @@
|
|
|
1
1
|
"use client";
|
|
2
|
-
import { jsx as r } from "react/jsx-runtime";
|
|
3
|
-
import { BaseEventsProvider as
|
|
4
|
-
import {
|
|
5
|
-
import {
|
|
6
|
-
|
|
2
|
+
import { jsxs as t, jsx as r } from "react/jsx-runtime";
|
|
3
|
+
import { BaseEventsProvider as m } from "./base-events-provider.js";
|
|
4
|
+
import { BotIdInitializer as p } from "./botid-initializer.js";
|
|
5
|
+
import { InkeepConfigProvider as c } from "./config-provider.js";
|
|
6
|
+
import { ThemeProvider as d } from "./theme-provider.js";
|
|
7
|
+
function u(o) {
|
|
7
8
|
const { children: e, config: i, componentType: n } = o;
|
|
8
|
-
return /* @__PURE__ */
|
|
9
|
-
|
|
9
|
+
return /* @__PURE__ */ t(
|
|
10
|
+
c,
|
|
10
11
|
{
|
|
11
12
|
value: {
|
|
12
13
|
...i,
|
|
13
14
|
componentType: n
|
|
14
15
|
},
|
|
15
|
-
children:
|
|
16
|
+
children: [
|
|
17
|
+
/* @__PURE__ */ r(p, {}),
|
|
18
|
+
/* @__PURE__ */ r(d, { children: /* @__PURE__ */ r(m, { children: e }) })
|
|
19
|
+
]
|
|
16
20
|
}
|
|
17
21
|
);
|
|
18
22
|
}
|
|
19
23
|
export {
|
|
20
|
-
|
|
24
|
+
u as RootProvider
|
|
21
25
|
};
|
|
@@ -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},a={shouldBypassCaptcha:!1,tags:[],userProperties:{},primaryBrandColor:t.DEFAULT_PRIMARY_BRAND_COLOR,theme:{varsClassName:"inkeep-widget-vars",...e.theme}},
|
|
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,botProtectionLevel:"basic"},a={shouldBypassCaptcha:!1,tags:[],userProperties:{},primaryBrandColor:t.DEFAULT_PRIMARY_BRAND_COLOR,theme:{varsClassName:"inkeep-widget-vars",...e.theme}},i={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=i;
|
|
@@ -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 i = {
|
|
5
5
|
baseUrl: "https://api.agents.inkeep.com",
|
|
6
6
|
placeholder: "How do I get started?",
|
|
7
7
|
aiAssistantName: void 0,
|
|
@@ -26,8 +26,9 @@ const l = {
|
|
|
26
26
|
copyChat: "Copy"
|
|
27
27
|
},
|
|
28
28
|
context: {},
|
|
29
|
-
shouldAutoScroll: !0
|
|
30
|
-
|
|
29
|
+
shouldAutoScroll: !0,
|
|
30
|
+
botProtectionLevel: "basic"
|
|
31
|
+
}, l = {
|
|
31
32
|
shouldBypassCaptcha: !1,
|
|
32
33
|
tags: [],
|
|
33
34
|
userProperties: {},
|
|
@@ -45,7 +46,7 @@ const l = {
|
|
|
45
46
|
view: "single-pane"
|
|
46
47
|
};
|
|
47
48
|
export {
|
|
48
|
-
|
|
49
|
-
|
|
49
|
+
i as defaultInkeepAIChatSettings,
|
|
50
|
+
l as defaultInkeepBaseSettings,
|
|
50
51
|
o as defaultInkeepSearchSettings
|
|
51
52
|
};
|
|
@@ -202,6 +202,14 @@ 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';
|
|
205
213
|
}
|
|
206
214
|
export interface AIChatDisclaimerSettings {
|
|
207
215
|
/**
|
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-20260501182500",
|
|
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",
|
|
76
75
|
"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 client";"use strict";Object.defineProperty(exports,Symbol.toStringTag,{value:"Module"});const w=require("altcha-lib"),c=require("react"),x=30*1e3;function b(l){const e=/[?&]expires=(\d+)/.exec(l);return e?Number.parseInt(e[1],10)*1e3:null}const p=async l=>{try{const e=await fetch(l,{method:"GET"});if(!e.ok)throw new Error(`Failed to fetch challenge: ${e.statusText}`);const i=await e.json(),{challenge:u,algorithm:n,salt:r,maxnumber:t}=i,{promise:g}=await w.solveChallenge(u,r,n,t),f=await g||void 0;if(!f)throw new Error("Challenge not solved");return{payload:{number:f.number,...i},expiresAt:b(r)}}catch(e){console.warn("[captcha] Error fetching/solving challenge:",e);return}},m=({baseUrl:l,shouldBypassCaptcha:e=!1,shouldMakeInitialRequest:i=!0})=>{const u=`${l}/run/auth/pow/challenge`,n=c.useRef(null),r=c.useRef(null),t=c.useCallback(()=>{const o=p(u);n.current=o,o.then(a=>{a&&(r.current=a.expiresAt)})},[u]),g=c.useCallback(async()=>{if(e)return{};n.current||t();const o=n.current;n.current=null,t();const a=n.current,h=await o;if(!h){const s=await a;return s?{"x-inkeep-challenge-solution":btoa(JSON.stringify(s.payload))}:{}}if(h.expiresAt!==null&&Date.now()>=h.expiresAt){const s=await a;return s?{"x-inkeep-challenge-solution":btoa(JSON.stringify(s.payload))}:{}}return{"x-inkeep-challenge-solution":btoa(JSON.stringify(h.payload))}},[e,t]),f=c.useCallback(()=>{e||t()},[e,t]);return c.useEffect(()=>{if(!i||e)return;const o=r.current!==null&&Date.now()>=r.current-x;(!n.current||o)&&t()},[i,e,t]),{getCaptchaHeader:g,invalidate:f}};exports.fetchAndSolveChallenge=p;exports.useCaptcha=m;
|
|
@@ -1,30 +0,0 @@
|
|
|
1
|
-
import { Payload } from 'altcha-lib/types';
|
|
2
|
-
interface UseCaptchaOptions {
|
|
3
|
-
baseUrl: string;
|
|
4
|
-
shouldBypassCaptcha?: boolean;
|
|
5
|
-
shouldMakeInitialRequest?: boolean;
|
|
6
|
-
}
|
|
7
|
-
interface SolvedEntry {
|
|
8
|
-
payload: Payload;
|
|
9
|
-
expiresAt: number | null;
|
|
10
|
-
}
|
|
11
|
-
export declare const fetchAndSolveChallenge: (fetchUrl: string) => Promise<SolvedEntry | undefined>;
|
|
12
|
-
/**
|
|
13
|
-
* Manages the PoW captcha lifecycle for /run/* API requests.
|
|
14
|
-
*
|
|
15
|
-
* - getCaptchaHeader(): atomically consumes the current pre-fetched challenge,
|
|
16
|
-
* immediately kicks off the next fetch so a fresh solution is always warm, and
|
|
17
|
-
* returns the ready-to-use `{ 'x-inkeep-challenge-solution': '...' }` header
|
|
18
|
-
* (or {} when bypassing or on failure). Checks token expiry and falls back to
|
|
19
|
-
* the already-started pre-fetch if the resolved token is stale.
|
|
20
|
-
*
|
|
21
|
-
* - invalidate(): discards any in-flight solution and starts a fresh fetch.
|
|
22
|
-
* Call this on request errors to recover from a rejected/stale challenge.
|
|
23
|
-
*
|
|
24
|
-
* All hooks are called unconditionally — bypass logic lives inside callbacks.
|
|
25
|
-
*/
|
|
26
|
-
export declare const useCaptcha: ({ baseUrl, shouldBypassCaptcha, shouldMakeInitialRequest, }: UseCaptchaOptions) => {
|
|
27
|
-
getCaptchaHeader: () => Promise<Record<string, string>>;
|
|
28
|
-
invalidate: () => void;
|
|
29
|
-
};
|
|
30
|
-
export {};
|
|
@@ -1,67 +0,0 @@
|
|
|
1
|
-
"use client";
|
|
2
|
-
import { solveChallenge as m } from "altcha-lib";
|
|
3
|
-
import { useRef as p, useCallback as h, useEffect as x } from "react";
|
|
4
|
-
const w = 30 * 1e3;
|
|
5
|
-
function E(i) {
|
|
6
|
-
const e = /[?&]expires=(\d+)/.exec(i);
|
|
7
|
-
return e ? Number.parseInt(e[1], 10) * 1e3 : null;
|
|
8
|
-
}
|
|
9
|
-
const y = async (i) => {
|
|
10
|
-
try {
|
|
11
|
-
const e = await fetch(i, { method: "GET" });
|
|
12
|
-
if (!e.ok)
|
|
13
|
-
throw new Error(`Failed to fetch challenge: ${e.statusText}`);
|
|
14
|
-
const c = await e.json(), { challenge: s, algorithm: t, salt: r, maxnumber: n } = c, { promise: g } = await m(
|
|
15
|
-
s,
|
|
16
|
-
r,
|
|
17
|
-
t,
|
|
18
|
-
n
|
|
19
|
-
), u = await g || void 0;
|
|
20
|
-
if (!u)
|
|
21
|
-
throw new Error("Challenge not solved");
|
|
22
|
-
return {
|
|
23
|
-
payload: { number: u.number, ...c },
|
|
24
|
-
expiresAt: E(r)
|
|
25
|
-
};
|
|
26
|
-
} catch (e) {
|
|
27
|
-
console.warn("[captcha] Error fetching/solving challenge:", e);
|
|
28
|
-
return;
|
|
29
|
-
}
|
|
30
|
-
}, k = ({
|
|
31
|
-
baseUrl: i,
|
|
32
|
-
shouldBypassCaptcha: e = !1,
|
|
33
|
-
shouldMakeInitialRequest: c = !0
|
|
34
|
-
}) => {
|
|
35
|
-
const s = `${i}/run/auth/pow/challenge`, t = p(null), r = p(null), n = h(() => {
|
|
36
|
-
const o = y(s);
|
|
37
|
-
t.current = o, o.then((l) => {
|
|
38
|
-
l && (r.current = l.expiresAt);
|
|
39
|
-
});
|
|
40
|
-
}, [s]), g = h(async () => {
|
|
41
|
-
if (e) return {};
|
|
42
|
-
t.current || n();
|
|
43
|
-
const o = t.current;
|
|
44
|
-
t.current = null, n();
|
|
45
|
-
const l = t.current, f = await o;
|
|
46
|
-
if (!f) {
|
|
47
|
-
const a = await l;
|
|
48
|
-
return a ? { "x-inkeep-challenge-solution": btoa(JSON.stringify(a.payload)) } : {};
|
|
49
|
-
}
|
|
50
|
-
if (f.expiresAt !== null && Date.now() >= f.expiresAt) {
|
|
51
|
-
const a = await l;
|
|
52
|
-
return a ? { "x-inkeep-challenge-solution": btoa(JSON.stringify(a.payload)) } : {};
|
|
53
|
-
}
|
|
54
|
-
return { "x-inkeep-challenge-solution": btoa(JSON.stringify(f.payload)) };
|
|
55
|
-
}, [e, n]), u = h(() => {
|
|
56
|
-
e || n();
|
|
57
|
-
}, [e, n]);
|
|
58
|
-
return x(() => {
|
|
59
|
-
if (!c || e) return;
|
|
60
|
-
const o = r.current !== null && Date.now() >= r.current - w;
|
|
61
|
-
(!t.current || o) && n();
|
|
62
|
-
}, [c, e, n]), { getCaptchaHeader: g, invalidate: u };
|
|
63
|
-
};
|
|
64
|
-
export {
|
|
65
|
-
y as fetchAndSolveChallenge,
|
|
66
|
-
k as useCaptcha
|
|
67
|
-
};
|