@inkeep/agents-ui 0.17.0 → 0.17.1

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.
@@ -1 +1 @@
1
- "use client";"use strict";var A=Object.create;var w=Object.defineProperty;var P=Object.getOwnPropertyDescriptor;var S=Object.getOwnPropertyNames;var O=Object.getPrototypeOf,b=Object.prototype.hasOwnProperty;var L=(r,n,e,o)=>{if(n&&typeof n=="object"||typeof n=="function")for(let t of S(n))!b.call(r,t)&&t!==e&&w(r,t,{get:()=>n[t],enumerable:!(o=P(n,t))||o.enumerable});return r};var C=(r,n,e)=>(e=r!=null?A(O(r)):{},L(n||!r||!r.__esModule?w(e,"default",{value:r,enumerable:!0}):e,r));Object.defineProperty(exports,Symbol.toStringTag,{value:"Module"});const f=require("react"),h="[sentinel]",x=45e3,M=3e4,D=3,I=5,N=250,Y=4e3;let v=null;function F(){return typeof customElements>"u"||customElements.get("altcha-widget")?Promise.resolve():v||(v=import("altcha").then(()=>customElements.whenDefined("altcha-widget")).then(()=>{}).catch(r=>{throw v=null,console.error(h,"failed to load altcha widget module",r),r instanceof Error?r:new Error("Failed to load altcha widget module")}),v)}function k(r){const n=document.createElement("div");n.style.cssText="position:fixed;left:-9999px;top:-9999px;width:0;height:0;overflow:hidden;pointer-events:none",document.body.appendChild(n);const e=document.createElement("altcha-widget");e.setAttribute("challenge",r),e.setAttribute("auto","onload"),e.setAttribute("hidefooter","true"),e.setAttribute("hidelogo","true"),n.appendChild(e);let o=[],t,c="mounted",s=!1,E=!1,u=null,i=null,a=0,m=!1;const R=d=>{const l=o;o=[];for(const p of l)p(d)},g=()=>{s||m||(t=void 0,c="resetting",e.reset?.(),e.verify?.())},_=()=>{u&&clearTimeout(u),u=setTimeout(()=>{u=null,!(!s||m)&&(s=!1,a=0,t=void 0,c="resetting",e.reset?.(),e.verify?.())},M)},y=d=>{const l=d.detail;if(l&&(c=l.state??c,l.state==="verified"&&l.payload&&(E=!0,a=0,t=l.payload,R(l.payload)),l.state==="error"))if(t=void 0,a++,a>=(E?I:D))R(void 0),s=!0,console.warn(h,`Sentinel unavailable after ${a} consecutive errors, requests will proceed without bot protection`),_();else{const T=Math.min(N*2**(a-1),Y);i&&clearTimeout(i),i=setTimeout(()=>{i=null,!(m||s)&&(c="resetting",e.reset?.(),e.verify?.())},T)}};return e.addEventListener("statechange",y),{getPayload:()=>{if(m||s)return Promise.resolve(void 0);if(t){const d=t;return t=void 0,g(),Promise.resolve(d)}return c==="verified"&&g(),new Promise(d=>{o.push(d),setTimeout(()=>{const l=o.indexOf(d);l!==-1&&(o.splice(l,1),d(void 0))},x)})},startNextSolve:g,destroy:()=>{m=!0,e.removeEventListener("statechange",y),u&&(clearTimeout(u),u=null),i&&(clearTimeout(i),i=null),R(void 0),n.remove()}}}const V=({baseUrl:r,appId:n,shouldBypassCaptcha:e=!1})=>{const o=f.useRef(null),t=f.useRef(null),c=f.useRef(!1),s=f.useCallback(()=>o.current?Promise.resolve():t.current?t.current:n?(t.current=F().then(()=>{if(!c.current&&!o.current){const i=`${r}/run/auth/sentinel/challenge?appId=${encodeURIComponent(n)}`;o.current=k(i)}}).catch(i=>{console.error(h,"failed to mount widget",i),t.current=null}),t.current):Promise.resolve(),[r,n]);f.useEffect(()=>{if(c.current=!1,!e)return s(),()=>{c.current=!0,o.current?.destroy(),o.current=null,t.current=null}},[e,s]);const E=f.useCallback(async()=>{if(e)return{};await s();const i=o.current;if(!i)return{};const a=await i.getPayload();return a?{"x-inkeep-challenge-solution":btoa(JSON.stringify({payload:a}))}:{}},[e,s]),u=f.useCallback(()=>{o.current?.startNextSolve()},[]);return{getCaptchaHeader:E,invalidate:u}};exports.useCaptcha=V;
1
+ "use client";"use strict";var A=Object.create;var w=Object.defineProperty;var S=Object.getOwnPropertyDescriptor;var P=Object.getOwnPropertyNames;var b=Object.getPrototypeOf,O=Object.prototype.hasOwnProperty;var L=(r,n,e,o)=>{if(n&&typeof n=="object"||typeof n=="function")for(let t of P(n))!O.call(r,t)&&t!==e&&w(r,t,{get:()=>n[t],enumerable:!(o=S(n,t))||o.enumerable});return r};var C=(r,n,e)=>(e=r!=null?A(b(r)):{},L(n||!r||!r.__esModule?w(e,"default",{value:r,enumerable:!0}):e,r));Object.defineProperty(exports,Symbol.toStringTag,{value:"Module"});const f=require("react"),h="[sentinel]",x=45e3,M=3e4,N=3,D=5,F=250,I=4e3;let v=null;function Y(){return typeof customElements>"u"||customElements.get("altcha-widget")?Promise.resolve():v||(v=import("altcha").then(()=>customElements.whenDefined("altcha-widget")).then(()=>{}).catch(r=>{throw v=null,console.error(h,"failed to load altcha widget module",r),r instanceof Error?r:new Error("Failed to load altcha widget module")}),v)}function k(r){const n=document.createElement("div");n.style.cssText="position:fixed;left:-9999px;top:-9999px;width:0;height:0;overflow:hidden;pointer-events:none",document.body.appendChild(n);const e=document.createElement("altcha-widget");e.setAttribute("challenge",r),e.setAttribute("auto","onload"),e.setAttribute("hidefooter","true"),e.setAttribute("hidelogo","true"),e.setAttribute("configuration",JSON.stringify({disableAutoFocus:!0})),n.appendChild(e);let o=[],t,c="mounted",s=!1,E=!1,u=null,i=null,a=0,m=!1;const R=d=>{const l=o;o=[];for(const p of l)p(d)},g=()=>{s||m||(t=void 0,c="resetting",e.reset?.(),e.verify?.())},_=()=>{u&&clearTimeout(u),u=setTimeout(()=>{u=null,!(!s||m)&&(s=!1,a=0,t=void 0,c="resetting",e.reset?.(),e.verify?.())},M)},y=d=>{const l=d.detail;if(l&&(c=l.state??c,l.state==="verified"&&l.payload&&(E=!0,a=0,t=l.payload,R(l.payload)),l.state==="error"))if(t=void 0,a++,a>=(E?D:N))R(void 0),s=!0,console.warn(h,`Sentinel unavailable after ${a} consecutive errors, requests will proceed without bot protection`),_();else{const T=Math.min(F*2**(a-1),I);i&&clearTimeout(i),i=setTimeout(()=>{i=null,!(m||s)&&(c="resetting",e.reset?.(),e.verify?.())},T)}};return e.addEventListener("statechange",y),{getPayload:()=>{if(m||s)return Promise.resolve(void 0);if(t){const d=t;return t=void 0,g(),Promise.resolve(d)}return c==="verified"&&g(),new Promise(d=>{o.push(d),setTimeout(()=>{const l=o.indexOf(d);l!==-1&&(o.splice(l,1),d(void 0))},x)})},startNextSolve:g,destroy:()=>{m=!0,e.removeEventListener("statechange",y),u&&(clearTimeout(u),u=null),i&&(clearTimeout(i),i=null),R(void 0),n.remove()}}}const V=({baseUrl:r,appId:n,shouldBypassCaptcha:e=!1})=>{const o=f.useRef(null),t=f.useRef(null),c=f.useRef(!1),s=f.useCallback(()=>o.current?Promise.resolve():t.current?t.current:n?(t.current=Y().then(()=>{if(!c.current&&!o.current){const i=`${r}/run/auth/sentinel/challenge?appId=${encodeURIComponent(n)}`;o.current=k(i)}}).catch(i=>{console.error(h,"failed to mount widget",i),t.current=null}),t.current):Promise.resolve(),[r,n]);f.useEffect(()=>{if(c.current=!1,!e)return s(),()=>{c.current=!0,o.current?.destroy(),o.current=null,t.current=null}},[e,s]);const E=f.useCallback(async()=>{if(e)return{};await s();const i=o.current;if(!i)return{};const a=await i.getPayload();return a?{"x-inkeep-challenge-solution":btoa(JSON.stringify({payload:a}))}:{}},[e,s]),u=f.useCallback(()=>{o.current?.startNextSolve()},[]);return{getCaptchaHeader:E,invalidate:u}};exports.useCaptcha=V;
@@ -1,24 +1,24 @@
1
1
  "use client";
2
- import { useRef as g, useCallback as h, useEffect as A } from "react";
3
- const y = "[sentinel]", P = 45e3, S = 3e4, O = 3, L = 5, x = 250, b = 4e3;
2
+ import { useRef as R, useCallback as h, useEffect as A } from "react";
3
+ const y = "[sentinel]", P = 45e3, S = 3e4, O = 3, b = 5, L = 250, x = 4e3;
4
4
  let m = null;
5
- function C() {
5
+ function N() {
6
6
  return typeof customElements > "u" || customElements.get("altcha-widget") ? Promise.resolve() : m || (m = import("altcha").then(() => customElements.whenDefined("altcha-widget")).then(() => {
7
7
  }).catch((a) => {
8
8
  throw m = null, console.error(y, "failed to load altcha widget module", a), a instanceof Error ? a : new Error("Failed to load altcha widget module");
9
9
  }), m);
10
10
  }
11
- function D(a) {
11
+ function C(a) {
12
12
  const d = document.createElement("div");
13
13
  d.style.cssText = "position:fixed;left:-9999px;top:-9999px;width:0;height:0;overflow:hidden;pointer-events:none", document.body.appendChild(d);
14
14
  const e = document.createElement("altcha-widget");
15
- e.setAttribute("challenge", a), e.setAttribute("auto", "onload"), e.setAttribute("hidefooter", "true"), e.setAttribute("hidelogo", "true"), d.appendChild(e);
15
+ e.setAttribute("challenge", a), e.setAttribute("auto", "onload"), e.setAttribute("hidefooter", "true"), e.setAttribute("hidelogo", "true"), e.setAttribute("configuration", JSON.stringify({ disableAutoFocus: !0 })), d.appendChild(e);
16
16
  let n = [], t, l = "mounted", i = !1, E = !1, s = null, r = null, c = 0, f = !1;
17
17
  const v = (u) => {
18
18
  const o = n;
19
19
  n = [];
20
20
  for (const w of o) w(u);
21
- }, R = () => {
21
+ }, g = () => {
22
22
  i || f || (t = void 0, l = "resetting", e.reset?.(), e.verify?.());
23
23
  }, _ = () => {
24
24
  s && clearTimeout(s), s = setTimeout(() => {
@@ -27,15 +27,15 @@ function D(a) {
27
27
  }, p = (u) => {
28
28
  const o = u.detail;
29
29
  if (o && (l = o.state ?? l, o.state === "verified" && o.payload && (E = !0, c = 0, t = o.payload, v(o.payload)), o.state === "error"))
30
- if (t = void 0, c++, c >= (E ? L : O))
30
+ if (t = void 0, c++, c >= (E ? b : O))
31
31
  v(void 0), i = !0, console.warn(
32
32
  y,
33
33
  `Sentinel unavailable after ${c} consecutive errors, requests will proceed without bot protection`
34
34
  ), _();
35
35
  else {
36
36
  const T = Math.min(
37
- x * 2 ** (c - 1),
38
- b
37
+ L * 2 ** (c - 1),
38
+ x
39
39
  );
40
40
  r && clearTimeout(r), r = setTimeout(() => {
41
41
  r = null, !(f || i) && (l = "resetting", e.reset?.(), e.verify?.());
@@ -46,23 +46,23 @@ function D(a) {
46
46
  if (f || i) return Promise.resolve(void 0);
47
47
  if (t) {
48
48
  const u = t;
49
- return t = void 0, R(), Promise.resolve(u);
49
+ return t = void 0, g(), Promise.resolve(u);
50
50
  }
51
- return l === "verified" && R(), new Promise((u) => {
51
+ return l === "verified" && g(), new Promise((u) => {
52
52
  n.push(u), setTimeout(() => {
53
53
  const o = n.indexOf(u);
54
54
  o !== -1 && (n.splice(o, 1), u(void 0));
55
55
  }, P);
56
56
  });
57
- }, startNextSolve: R, destroy: () => {
57
+ }, startNextSolve: g, destroy: () => {
58
58
  f = !0, e.removeEventListener("statechange", p), s && (clearTimeout(s), s = null), r && (clearTimeout(r), r = null), v(void 0), d.remove();
59
59
  } };
60
60
  }
61
- const Y = ({ baseUrl: a, appId: d, shouldBypassCaptcha: e = !1 }) => {
62
- const n = g(null), t = g(null), l = g(!1), i = h(() => n.current ? Promise.resolve() : t.current ? t.current : d ? (t.current = C().then(() => {
61
+ const M = ({ baseUrl: a, appId: d, shouldBypassCaptcha: e = !1 }) => {
62
+ const n = R(null), t = R(null), l = R(!1), i = h(() => n.current ? Promise.resolve() : t.current ? t.current : d ? (t.current = N().then(() => {
63
63
  if (!l.current && !n.current) {
64
64
  const r = `${a}/run/auth/sentinel/challenge?appId=${encodeURIComponent(d)}`;
65
- n.current = D(r);
65
+ n.current = C(r);
66
66
  }
67
67
  }).catch((r) => {
68
68
  console.error(y, "failed to mount widget", r), t.current = null;
@@ -88,5 +88,5 @@ const Y = ({ baseUrl: a, appId: d, shouldBypassCaptcha: e = !1 }) => {
88
88
  return { getCaptchaHeader: E, invalidate: s };
89
89
  };
90
90
  export {
91
- Y as useCaptcha
91
+ M as useCaptcha
92
92
  };
@@ -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.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;
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.1",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.17.0", i = d(
6
+ const { baseSettings: t, componentType: o } = x(), { tags: s, analyticsProperties: n } = t, r = "0.17.1", 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.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;
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.1",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.17.0", a = x(
9
+ const { baseSettings: r, aiChatSettings: g, componentType: i } = N(), { tags: t, analyticsProperties: n, privacyPreferences: f, userProperties: o } = r, c = "0.17.1", a = x(
10
10
  () => ({
11
11
  widgetLibraryVersion: c,
12
12
  componentType: i
@@ -5,6 +5,31 @@ export interface InkeepEmbeddedSearchAndChatFunctions {
5
5
  setView: (view: ModalViewTypes) => void;
6
6
  }
7
7
  export interface InkeepEmbeddedSearchAndChatProps extends Partial<Omit<InkeepConfig, 'componentType'>>, WidgetView {
8
+ /**
9
+ * Callback fired when the user selects "Ask AI" — via the Ask AI card or the
10
+ * Search/Ask AI toggle.
11
+ *
12
+ * When provided, this replaces the default behavior of switching to the
13
+ * component's internal chat view. The internal chat pane is not shown and no
14
+ * message is submitted to it; instead the parent handles the Ask AI intent
15
+ * (for example, closing the modal and opening a separate sidebar chat).
16
+ *
17
+ * `query` is the current search input, so the parent can autofill or submit it
18
+ * in the destination chat.
19
+ *
20
+ * `autoSubmit` reflects the user's intent based on how they selected Ask AI:
21
+ * `true` when they clicked the Ask AI card (a query-specific action), and
22
+ * `false`/`undefined` when they used the Search/Ask AI toggle (a mode switch).
23
+ * Honor it to decide between auto-submitting and only filling in the query.
24
+ *
25
+ * Precedence: this takes full ownership of the Ask AI intent. When it is
26
+ * provided, `onToggleView` is NOT called for `view: 'chat'` selections and the
27
+ * internal view does not change. `onToggleView` still fires for `view: 'search'`.
28
+ */
29
+ onSelectAskAI?: (opts: {
30
+ query?: string;
31
+ autoSubmit?: boolean;
32
+ }) => void;
8
33
  /**
9
34
  * The default view to show when the widget is loaded.
10
35
  * @default 'search'
@@ -1 +1 @@
1
- "use client";"use strict";Object.defineProperty(exports,Symbol.toStringTag,{value:"Module"});const t=require("react"),a=require("./utils.cjs");function p(f){const{defaultView:u="search",aiChatSettings:i,baseSettings:g,searchSettings:o,shouldAutoFocusInput:l=!0,onToggleView:h,ref:R,...S}=f,s=t.useRef(null),m=a.composeRefs(s,i?.chatFunctionsRef),r=t.useRef(null),d=a.composeRefs(r,o?.searchFunctionsRef),w={...i,chatFunctionsRef:m},I={...o,searchFunctionsRef:d},[n,c]=t.useState(u),b=e=>{e.autoSubmit&&e.query&&s.current?.submitMessage(e.query),h?.(e),c(e.view)};return t.useImperativeHandle(R,()=>({setView:c})),t.useEffect(()=>{n==="chat"?s.current?.focusInput():r.current?.focusInput()},[n]),{config:{baseSettings:g,aiChatSettings:w,searchSettings:I},defaultView:u,view:n,setView:c,onToggleView:b,shouldAutoFocusInput:l,...S}}exports.useWidgetImpl=p;
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 r, useState as V, useImperativeHandle as d, useEffect as b } from "react";
3
- import { composeRefs as a } from "./utils.js";
4
- function _(f) {
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: i,
8
- baseSettings: g,
9
- searchSettings: o,
10
- shouldAutoFocusInput: h = !0,
11
- onToggleView: l,
7
+ aiChatSettings: u,
8
+ baseSettings: h,
9
+ searchSettings: i,
10
+ shouldAutoFocusInput: l = !0,
11
+ onToggleView: S,
12
+ onSelectAskAI: o,
12
13
  ref: m,
13
- ...S
14
- } = f, t = r(null), R = a(t, i?.chatFunctionsRef), u = r(null), w = a(u, o?.searchFunctionsRef), p = {
15
- ...i,
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
- ...o,
19
- searchFunctionsRef: w
20
- }, [n, s] = V(c), I = (e) => {
21
- e.autoSubmit && e.query && t.current?.submitMessage(e.query), l?.(e), s(e.view);
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 d(m, () => ({
28
+ return q(m, () => ({
24
29
  setView: s
25
- })), b(() => {
26
- n === "chat" ? t.current?.focusInput() : u.current?.focusInput();
30
+ })), v(() => {
31
+ n === "chat" ? t.current?.focusInput() : r.current?.focusInput();
27
32
  }, [n]), {
28
33
  config: {
29
- baseSettings: g,
30
- aiChatSettings: p,
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: I,
37
- shouldAutoFocusInput: h,
38
- ...S
41
+ onToggleView: V,
42
+ shouldAutoFocusInput: l,
43
+ ...w
39
44
  };
40
45
  }
41
46
  export {
42
- _ as useWidgetImpl
47
+ T as useWidgetImpl
43
48
  };
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@inkeep/agents-ui",
3
- "version": "0.17.0",
3
+ "version": "0.17.1",
4
4
  "description": "",
5
5
  "homepage": "",
6
6
  "repository": {