@inkeep/agents-ui 0.0.0-dev-20260529093700 → 0.0.0-dev-20260604220939
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/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 +1 -1
- package/dist/react/embedded-search-and-chat.impl.cjs +1 -1
- package/dist/react/embedded-search-and-chat.impl.js +29 -24
- package/dist/types/widget.d.ts +21 -0
- package/package.json +1 -1
|
@@ -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.
|
|
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.17.0",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.
|
|
6
|
+
const { baseSettings: t, componentType: o } = x(), { tags: s, analyticsProperties: n } = t, r = "0.17.0", 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"),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.
|
|
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.17.0",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;
|
|
@@ -6,7 +6,7 @@ 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
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.
|
|
9
|
+
const { baseSettings: r, aiChatSettings: g, componentType: i } = N(), { tags: t, analyticsProperties: n, privacyPreferences: f, userProperties: o } = r, c = "0.17.0", a = x(
|
|
10
10
|
() => ({
|
|
11
11
|
widgetLibraryVersion: c,
|
|
12
12
|
componentType: i
|
|
@@ -1 +1 @@
|
|
|
1
|
-
"use client";"use strict";Object.defineProperty(exports,Symbol.toStringTag,{value:"Module"});const t=require("react"),
|
|
1
|
+
"use client";"use strict";Object.defineProperty(exports,Symbol.toStringTag,{value:"Module"});const t=require("react"),f=require("./utils.cjs");function y(g){const{defaultView:c="search",aiChatSettings:i,baseSettings:l,searchSettings:o,shouldAutoFocusInput:h=!0,onToggleView:S,onSelectAskAI:r,ref:R,...m}=g,s=t.useRef(null),w=f.composeRefs(s,i?.chatFunctionsRef),a=t.useRef(null),b=f.composeRefs(a,o?.searchFunctionsRef),d={...i,chatFunctionsRef:w},I={...o,searchFunctionsRef:b},[n,u]=t.useState(c),q=e=>{if(e.view==="chat"&&r){r({query:e.query,autoSubmit:e.autoSubmit});return}e.autoSubmit&&e.query&&s.current?.submitMessage(e.query),S?.(e),u(e.view)};return t.useImperativeHandle(R,()=>({setView:u})),t.useEffect(()=>{n==="chat"?s.current?.focusInput():a.current?.focusInput()},[n]),{config:{baseSettings:l,aiChatSettings:d,searchSettings:I},defaultView:c,view:n,setView:u,onToggleView:q,shouldAutoFocusInput:h,...m}}exports.useWidgetImpl=y;
|
|
@@ -1,43 +1,48 @@
|
|
|
1
1
|
"use client";
|
|
2
|
-
import { useRef as
|
|
3
|
-
import { composeRefs as
|
|
4
|
-
function
|
|
2
|
+
import { useRef as a, useState as d, useImperativeHandle as q, useEffect as v } from "react";
|
|
3
|
+
import { composeRefs as f } from "./utils.js";
|
|
4
|
+
function T(g) {
|
|
5
5
|
const {
|
|
6
6
|
defaultView: c = "search",
|
|
7
|
-
aiChatSettings:
|
|
8
|
-
baseSettings:
|
|
9
|
-
searchSettings:
|
|
10
|
-
shouldAutoFocusInput:
|
|
11
|
-
onToggleView:
|
|
7
|
+
aiChatSettings: u,
|
|
8
|
+
baseSettings: h,
|
|
9
|
+
searchSettings: i,
|
|
10
|
+
shouldAutoFocusInput: l = !0,
|
|
11
|
+
onToggleView: S,
|
|
12
|
+
onSelectAskAI: o,
|
|
12
13
|
ref: m,
|
|
13
|
-
...
|
|
14
|
-
} =
|
|
15
|
-
...
|
|
14
|
+
...w
|
|
15
|
+
} = g, t = a(null), R = f(t, u?.chatFunctionsRef), r = a(null), I = f(r, i?.searchFunctionsRef), b = {
|
|
16
|
+
...u,
|
|
16
17
|
chatFunctionsRef: R
|
|
17
18
|
}, F = {
|
|
18
|
-
...
|
|
19
|
-
searchFunctionsRef:
|
|
20
|
-
}, [n, s] =
|
|
21
|
-
e.
|
|
19
|
+
...i,
|
|
20
|
+
searchFunctionsRef: I
|
|
21
|
+
}, [n, s] = d(c), V = (e) => {
|
|
22
|
+
if (e.view === "chat" && o) {
|
|
23
|
+
o({ query: e.query, autoSubmit: e.autoSubmit });
|
|
24
|
+
return;
|
|
25
|
+
}
|
|
26
|
+
e.autoSubmit && e.query && t.current?.submitMessage(e.query), S?.(e), s(e.view);
|
|
22
27
|
};
|
|
23
|
-
return
|
|
28
|
+
return q(m, () => ({
|
|
24
29
|
setView: s
|
|
25
|
-
})),
|
|
26
|
-
n === "chat" ? t.current?.focusInput() :
|
|
30
|
+
})), v(() => {
|
|
31
|
+
n === "chat" ? t.current?.focusInput() : r.current?.focusInput();
|
|
27
32
|
}, [n]), {
|
|
28
33
|
config: {
|
|
29
|
-
baseSettings:
|
|
30
|
-
aiChatSettings:
|
|
34
|
+
baseSettings: h,
|
|
35
|
+
aiChatSettings: b,
|
|
31
36
|
searchSettings: F
|
|
32
37
|
},
|
|
33
38
|
defaultView: c,
|
|
34
39
|
view: n,
|
|
35
40
|
setView: s,
|
|
36
|
-
onToggleView:
|
|
37
|
-
shouldAutoFocusInput:
|
|
38
|
-
...
|
|
41
|
+
onToggleView: V,
|
|
42
|
+
shouldAutoFocusInput: l,
|
|
43
|
+
...w
|
|
39
44
|
};
|
|
40
45
|
}
|
|
41
46
|
export {
|
|
42
|
-
|
|
47
|
+
T as useWidgetImpl
|
|
43
48
|
};
|
package/dist/types/widget.d.ts
CHANGED
|
@@ -12,6 +12,27 @@ export interface WidgetView {
|
|
|
12
12
|
query?: string;
|
|
13
13
|
autoSubmit?: boolean;
|
|
14
14
|
}) => void;
|
|
15
|
+
/**
|
|
16
|
+
* Callback fired when the user selects "Ask AI" — via the Ask AI card or the
|
|
17
|
+
* Search/Ask AI toggle — on a search-and-chat component.
|
|
18
|
+
*
|
|
19
|
+
* When provided, this replaces the default behavior of switching to the
|
|
20
|
+
* component's internal chat view. The internal chat pane is not shown and no
|
|
21
|
+
* message is submitted to it; instead the parent handles the Ask AI intent
|
|
22
|
+
* (for example, closing the modal and opening a separate sidebar chat).
|
|
23
|
+
*
|
|
24
|
+
* `query` is the current search input, so the parent can autofill or submit it
|
|
25
|
+
* in the destination chat.
|
|
26
|
+
*
|
|
27
|
+
* `autoSubmit` reflects the user's intent based on how they selected Ask AI:
|
|
28
|
+
* `true` when they clicked the Ask AI card (a query-specific action), and
|
|
29
|
+
* `false`/`undefined` when they used the Search/Ask AI toggle (a mode switch).
|
|
30
|
+
* Honor it to decide between auto-submitting and only filling in the query.
|
|
31
|
+
*/
|
|
32
|
+
onSelectAskAI?: (opts: {
|
|
33
|
+
query?: string;
|
|
34
|
+
autoSubmit?: boolean;
|
|
35
|
+
}) => void;
|
|
15
36
|
/**
|
|
16
37
|
* The label for the Ask AI button.
|
|
17
38
|
*/
|