@useago/sdk 1.4.4 → 1.5.0

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.
Files changed (41) hide show
  1. package/CHANGELOG.md +15 -1
  2. package/dist/{AgoClient-Ozz2b1dQ.js → AgoClient-q39FIjSC.js} +1 -1
  3. package/dist/{AgoClient-CLmtYTJx.cjs → AgoClient-wcPRaIMs.cjs} +1 -1
  4. package/dist/angular.cjs +1 -1
  5. package/dist/angular.d.cts +45 -3
  6. package/dist/angular.d.ts +45 -3
  7. package/dist/angular.js +5 -1
  8. package/dist/autoContinue-CcCTva-D.cjs +1 -0
  9. package/dist/autoContinue-D3Mmaaca.js +63 -0
  10. package/dist/{createConversationSession-CUkNp6mZ.cjs → createConversationSession-BBYfQLLS.cjs} +1 -1
  11. package/dist/{createConversationSession-QIBN0gLx.js → createConversationSession-DCSWShaW.js} +1 -1
  12. package/dist/{createFormCollector-DHT1ObOb.cjs → createFormCollector-eimwwWEi.cjs} +1 -1
  13. package/dist/{createFormCollector-F3YJfsbg.js → createFormCollector-sB6rMccD.js} +1 -1
  14. package/dist/devtools.d.cts +3 -3
  15. package/dist/devtools.d.ts +3 -3
  16. package/dist/helpers.cjs +1 -1
  17. package/dist/index.cjs +1 -1
  18. package/dist/index.d.cts +52 -3
  19. package/dist/index.d.ts +52 -3
  20. package/dist/index.js +45 -43
  21. package/dist/react.cjs +3 -3
  22. package/dist/react.d.cts +5 -17
  23. package/dist/react.d.ts +5 -17
  24. package/dist/react.js +396 -454
  25. package/dist/testing.cjs +1 -1
  26. package/dist/testing.d.cts +3 -3
  27. package/dist/testing.d.ts +3 -3
  28. package/dist/testing.js +1 -1
  29. package/dist/vue.cjs +1 -1
  30. package/dist/vue.d.cts +3 -3
  31. package/dist/vue.d.ts +3 -3
  32. package/dist/vue.js +1 -1
  33. package/dist/widget.cjs +1 -1
  34. package/dist/widget.d.cts +3 -3
  35. package/dist/widget.d.ts +3 -3
  36. package/dist/widget.js +3 -3
  37. package/llms-full.txt +26 -4
  38. package/package.json +1 -1
  39. /package/dist/{createMockClient-bAZ9KBHC.js → createMockClient-BUc9PSbo.js} +0 -0
  40. /package/dist/{createMockClient-BSr-UV8R.cjs → createMockClient-CjdCqixj.cjs} +0 -0
  41. /package/dist/{functions-Djnq-JAo.cjs → functions-IGSjjvF4.cjs} +0 -0
package/dist/index.d.ts CHANGED
@@ -39,6 +39,23 @@ export declare interface AgoAttachment {
39
39
  isSafeImage: boolean;
40
40
  }
41
41
 
42
+ export declare interface AgoAutoContinueOptions {
43
+ /** Function names whose invocation counts as "navigated". Default `["navigateToPage"]`. */
44
+ navigationFunctions?: string[];
45
+ /** Registered function that signals the destination has editable state. Default `"setPageState"`. */
46
+ pageStateFunctionName?: string;
47
+ /** The hidden continuation prompt. Override for i18n / tone. */
48
+ continuationPrompt?: string;
49
+ /** Max continuations per user gesture (guards navigate→continue→navigate loops). Default `1`. */
50
+ maxDepth?: number;
51
+ /** How long to wait for the destination page to register page-state before giving up. Default `4000`ms. */
52
+ readinessTimeoutMs?: number;
53
+ /** Extra settle delay after page-state appears, to let sibling state mount. Default `150`ms. */
54
+ settleMs?: number;
55
+ /** Opt-out escape hatch. Default `true`. */
56
+ enabled?: boolean;
57
+ }
58
+
42
59
  /**
43
60
  * Main SDK client for AGO Chat integration
44
61
  */
@@ -487,11 +504,11 @@ export declare interface AgoConfig {
487
504
  warnOnEmptyReply?: boolean;
488
505
  /**
489
506
  * How the agent loop treats client function calls (requires backend support):
490
- * - `"placeholder"` (default): the turn continues immediately on a placeholder
491
- * result; the real result is only visible to the agent on later turns.
492
- * - `"pause"`: the turn stops on client function call(s) with status
507
+ * - `"pause"` (default): the turn stops on client function call(s) with status
493
508
  * `WAITING_CLIENT`; once every result is submitted, the SDK resumes the SAME
494
509
  * turn via `POST /messages/{id}/continue`, so the agent sees the real results.
510
+ * - `"placeholder"` (legacy): the turn continues immediately on a placeholder
511
+ * result; the real result is only visible to the agent on later turns.
495
512
  * Older backends ignore the flag, so `"pause"` degrades to legacy behavior.
496
513
  */
497
514
  clientFunctionsMode?: ClientFunctionsMode;
@@ -659,6 +676,38 @@ declare interface ApiErrorResponse {
659
676
  };
660
677
  }
661
678
 
679
+ /**
680
+ * Auto-continue the agent after it navigates, so a "go to page B and change X"
681
+ * request completes in one user gesture. Attach once per client; returns a
682
+ * detach function that removes every listener.
683
+ *
684
+ * Two mechanisms, picked by the turn's client-functions mode:
685
+ *
686
+ * - **Pause mode** (`clientFunctionsMode: "pause"`, the default): the backend pauses the turn
687
+ * on the navigation call (`message:waiting-client`) and the SDK resumes it once
688
+ * the result is submitted. This helper only registers a *resume gate* that delays
689
+ * the resume until the destination page's page-state registered (plus a settle
690
+ * delay), so the continued turn ships the new page's `setPageState` and current
691
+ * state. Same turn, no extra prompt, backend budget as the guardrail —
692
+ * `continuationPrompt` and `maxDepth` are unused here.
693
+ *
694
+ * - **Placeholder mode** (legacy, `clientFunctionsMode: "placeholder"`): when the agent calls the navigation
695
+ * function and that turn ends, this waits for the destination page's state to
696
+ * register, then sends a hidden continuation message; the agent applies the
697
+ * state in a second turn (requires backend support for the `hidden` flag).
698
+ *
699
+ * ```ts
700
+ * const detach = attachAutoContinueAfterNavigation(client);
701
+ * // later, on teardown:
702
+ * detach();
703
+ * ```
704
+ *
705
+ * Options can be a plain object, or a getter for live options: the getter is
706
+ * re-read on every event, so changing what it returns never re-subscribes the
707
+ * listeners (this is how the React hook keeps options reactive).
708
+ */
709
+ export declare function attachAutoContinueAfterNavigation(client: AgoClient, options?: AgoAutoContinueOptions | (() => AgoAutoContinueOptions | undefined)): () => void;
710
+
662
711
  /**
663
712
  * Auto-detect AGO configuration from the DOM environment.
664
713
  *
package/dist/index.js CHANGED
@@ -1,37 +1,38 @@
1
- import { a as h, c as A, d as y, f as C, i as E, l as S, m as b, o as v, p as F, r as M, s as I, t as k, u as T } from "./functions-CApuQZ2b.js";
2
- import { _ as G, a as O, c as _, d as q, f as x, g as L, h as N, l as D, m as d, n as H, o as J, p as R, r as j, s as z, t as c, u as B } from "./AgoClient-Ozz2b1dQ.js";
3
- import { i as $, n as K, r as Q, t as V } from "./createFormCollector-F3YJfsbg.js";
4
- import { t as X } from "./createConversationSession-QIBN0gLx.js";
5
- import { t as Z } from "./createMockClient-bAZ9KBHC.js";
1
+ import { a as h, c as A, d as C, f as y, i as E, l as S, m as b, o as v, p as F, r as M, s as I, t as k, u as T } from "./functions-CApuQZ2b.js";
2
+ import { _ as G, a as N, c as O, d as _, f as q, g as x, h as L, l as D, m as d, n as H, o as J, p as R, r as j, s as z, t as c, u as B } from "./AgoClient-q39FIjSC.js";
3
+ import { t as $ } from "./autoContinue-D3Mmaaca.js";
4
+ import { i as Q, n as V, r as W, t as X } from "./createFormCollector-sB6rMccD.js";
5
+ import { t as Z } from "./createConversationSession-DCSWShaW.js";
6
+ import { t as oe } from "./createMockClient-BUc9PSbo.js";
6
7
  import "./testing.js";
7
- function oe(e) {
8
+ function re(e) {
8
9
  return e;
9
10
  }
10
- function te(e, o) {
11
+ function ne(e, o) {
11
12
  return e.on("message:complete", o), () => e.off("message:complete", o);
12
13
  }
13
- function re(e, o) {
14
+ function ae(e, o) {
14
15
  return e.on("message:chunk", o), () => e.off("message:chunk", o);
15
16
  }
16
- function ne(e, o) {
17
+ function se(e, o) {
17
18
  return e.on("message:start", o), () => e.off("message:start", o);
18
19
  }
19
- function ae(e, o) {
20
+ function ie(e, o) {
20
21
  return e.on("message:error", o), () => e.off("message:error", o);
21
22
  }
22
- function se(e, o) {
23
+ function ue(e, o) {
23
24
  return e.on("toolCall:received", o), () => e.off("toolCall:received", o);
24
25
  }
25
- function ie(e, o) {
26
+ function ge(e, o) {
26
27
  return e.on("form:submitted", o), () => e.off("form:submitted", o);
27
28
  }
28
- function ue(e, o) {
29
+ function fe(e, o) {
29
30
  return e.on("form:error", o), () => e.off("form:error", o);
30
31
  }
31
- function ge(e, o) {
32
+ function me(e, o) {
32
33
  return e.on("function:invoke", o), () => e.off("function:invoke", o);
33
34
  }
34
- async function* fe(e, o, u) {
35
+ async function* le(e, o, u) {
35
36
  const n = [];
36
37
  let r = null, a = !1;
37
38
  const g = (s) => {
@@ -94,12 +95,12 @@ function p(e) {
94
95
  debug: f
95
96
  } : null;
96
97
  }
97
- function me(e) {
98
+ function de(e) {
98
99
  const o = p(e);
99
100
  if (!o) throw new d('createAgo(): could not detect AGO configuration. Set window.AGO, add <meta name="ago-base-url">, or pass { baseUrl } explicitly.', "config_missing_base_url");
100
101
  return new c(o);
101
102
  }
102
- function le(e, o) {
103
+ function ce(e, o) {
103
104
  return {
104
105
  ...e,
105
106
  handler: o
@@ -109,49 +110,50 @@ export {
109
110
  R as AgoApiError,
110
111
  c as AgoClient,
111
112
  d as AgoError,
112
- N as AgoFunctionError,
113
- L as AgoNetworkError,
113
+ L as AgoFunctionError,
114
+ x as AgoNetworkError,
114
115
  G as AgoStreamError,
115
116
  B as ClientContextRegistry,
116
117
  j as EventEmitter,
117
- q as FunctionRegistry,
118
- _ as SSEHandler,
118
+ _ as FunctionRegistry,
119
+ O as SSEHandler,
120
+ $ as attachAutoContinueAfterNavigation,
119
121
  p as autoDetectConfig,
120
- O as canInlineImage,
122
+ N as canInlineImage,
121
123
  k as copyToClipboard,
122
- me as createAgo,
123
- X as createConversationSession,
124
- V as createFormCollector,
125
- fe as createMessageStream,
126
- Z as createMockClient,
127
- $ as createStore,
128
- oe as defineFunction,
129
- K as deriveFormStatus,
124
+ de as createAgo,
125
+ Z as createConversationSession,
126
+ X as createFormCollector,
127
+ le as createMessageStream,
128
+ oe as createMockClient,
129
+ Q as createStore,
130
+ re as defineFunction,
131
+ V as deriveFormStatus,
130
132
  J as formatFileSize,
131
133
  M as getLocalStorage,
132
134
  E as getUserLocation,
133
135
  h as highlightElement,
134
136
  D as isStreamNetworkError,
135
- Q as loadFormCollector,
136
- x as logger,
137
- ue as onFormError,
138
- ie as onFormSubmitted,
139
- ge as onFunctionInvoke,
140
- te as onMessage,
141
- re as onMessageChunk,
142
- ae as onMessageError,
143
- ne as onMessageStart,
144
- se as onToolCall,
137
+ W as loadFormCollector,
138
+ q as logger,
139
+ fe as onFormError,
140
+ ge as onFormSubmitted,
141
+ me as onFunctionInvoke,
142
+ ne as onMessage,
143
+ ae as onMessageChunk,
144
+ ie as onMessageError,
145
+ se as onMessageStart,
146
+ ue as onToolCall,
145
147
  v as openUrl,
146
148
  z as safeAttachmentUrl,
147
149
  I as scrollToElement,
148
150
  A as setLocalStorage,
149
151
  S as setTheme,
150
152
  T as showConfirmDialog,
151
- y as showNotification,
152
- C as showToast,
153
+ C as showNotification,
154
+ y as showToast,
153
155
  F as submitForm,
154
156
  b as trackEvent,
155
157
  H as validateConfig,
156
- le as withHandler
158
+ ce as withHandler
157
159
  };
package/dist/react.cjs CHANGED
@@ -1,7 +1,7 @@
1
- Object.defineProperty(exports,Symbol.toStringTag,{value:"Module"});const W=require("./rolldown-runtime-16Nf8qvH.cjs"),F=require("./AgoClient-CLmtYTJx.cjs"),M=require("./createFormCollector-DHT1ObOb.cjs"),V=require("./createMockClient-BSr-UV8R.cjs");let s=require("react");s=W.__toESM(s,1);let o=require("react/jsx-runtime"),P=require("react-markdown");P=W.__toESM(P,1);let T=require("remark-gfm");T=W.__toESM(T,1);function H(e){const[n,r]=(0,s.useState)(!1),t=(0,s.useRef)(null),a=(0,s.useMemo)(()=>{if(t.current&&(t.current.destroy(),t.current=null),!e)return null;const l=new F.AgoClient(e);return t.current=l,l},[e?.baseUrl,e?.widgetId]);return(0,s.useEffect)(()=>(r(!0),()=>{t.current?.destroy(),t.current=null}),[a]),(0,s.useEffect)(()=>{t.current&&e&&t.current.updateConfig({agent:e.agent,defaultAgentId:e.defaultAgentId,permission:e.permission,userEmail:e.userEmail,userJwt:e.userJwt,debug:e.debug,warnOnEmptyReply:e.warnOnEmptyReply})},[e?.agent,e?.defaultAgentId,e?.permission,e?.userEmail,e?.userJwt,e?.debug,e?.warnOnEmptyReply]),{client:a,isReady:n}}var D=(0,s.createContext)(null),Y=({children:e,client:n,tools:r,helpers:t,pageContext:a,...l})=>{const{client:d}=H(n?null:l),c=n||d;return(0,s.useEffect)(()=>{if(!(!r||r.length===0)){for(const p of r)c.register(p);return()=>{for(const p of r)c.unregisterFunction(p.name)}}},[c,r]),(0,s.useEffect)(()=>{if(!t)return;const p=[];return Promise.resolve().then(()=>require("./functions-Djnq-JAo.cjs")).then(u=>u.functions_exports).then(u=>{for(const[b,v]of Object.entries(t)){const I=u[b];if(!I){console.warn(`[AGO] Unknown helper: "${b}"`);continue}const g=v===!0?I:{...I,handler:v};c.register(g),p.push(g.name)}}),()=>{for(const u of p)c.unregisterFunction(u)}},[c,t]),(0,s.useEffect)(()=>{a==="auto"&&c.enableAutoPageContext()},[c,a]),(0,o.jsx)(D.Provider,{value:c,children:e})};function E(){const e=(0,s.useContext)(D);if(!e)throw new Error('useAgoClient must be used within an <AgoProvider>. Wrap your component tree with <AgoProvider baseUrl="...">.');return e}function _(){return(0,s.useContext)(D)}function L({client:e,conversationId:n}={}){const r=_(),t=e||r;if(!t)throw new Error("useMessages requires an AgoClient. Either pass it as options.client or wrap your app in <AgoProvider>.");const[a,l]=(0,s.useState)([]),[d,c]=(0,s.useState)(n),[p,u]=(0,s.useState)(!1),[b,v]=(0,s.useState)(null);(0,s.useEffect)(()=>{n&&n!==d&&(c(n),I(n))},[n]);const I=async g=>{try{l((await t.getMessages(g)).filter(m=>!m.hidden))}catch(m){v(m instanceof Error?m:new Error("Failed to load messages"))}};return(0,s.useEffect)(()=>{const g=f=>f==="IN_PROGRESS"||f==="WAITING_CLIENT",m=f=>{d||c(f.conversationId),u(!0),l(x=>{const C=x.findIndex(h=>h.id===f.messageId);return C>=0?x.map((h,N)=>N===C?{...h,status:"IN_PROGRESS"}:h):x.some(h=>h.role==="assistant"&&g(h.status))?x:[...x,{id:f.messageId,conversationId:f.conversationId,content:"",role:"assistant",status:"IN_PROGRESS",createdAt:new Date}]})},S=f=>{l(x=>{const C=x.findIndex(h=>h.id===f.messageId);return C<0?x:x.map((h,N)=>N===C?{...h,content:h.content+f.content}:h)})},w=f=>{l(x=>{let C=-1;for(let h=x.length-1;h>=0;h--)if(x[h].role==="assistant"&&g(x[h].status)){C=h;break}return C<0?x:[...x.slice(0,C),{...x[C],...f},...x.slice(C+1)]})},i=f=>{l(x=>{const C=x.findIndex(h=>h.id===f.id);return C>=0?[...x.slice(0,C),f,...x.slice(C+1)]:[...x,f]}),u(!1)},y=f=>{v(new Error(f.error)),u(!1)};return t.on("message:start",m),t.on("message:chunk",S),t.on("message:answer-complete",w),t.on("message:complete",i),t.on("message:error",y),()=>{t.off("message:start",m),t.off("message:chunk",S),t.off("message:answer-complete",w),t.off("message:complete",i),t.off("message:error",y)}},[t,d]),{messages:a,isLoading:p,error:b,sendMessage:(0,s.useCallback)(async(g,m)=>{u(!0),v(null);const S={id:`temp-${Date.now()}`,conversationId:d||"",content:g,role:"user",status:"DONE",attachments:m&&m.length>0?F.attachmentsFromFiles(m):void 0,createdAt:new Date},w={id:`temp-assistant-${Date.now()}`,conversationId:d||"",content:"",role:"assistant",status:"IN_PROGRESS",createdAt:new Date};l(i=>[...i,S,w]);try{const i=await t.sendMessage(g,{conversationId:d,files:m});return i.conversationId&&!d&&c(i.conversationId),l(y=>{const f=y.filter(C=>!C.id.startsWith("temp-")),x={...S,id:S.id.replace("temp-","user-"),conversationId:i.conversationId};return f.some(C=>C.id===i.id)?[...f,x].sort((C,h)=>new Date(C.createdAt).getTime()-new Date(h.createdAt).getTime()):[...f,x,i]}),i}catch(i){return v(i instanceof Error?i:new Error("Failed to send message")),u(!1),l(y=>y.filter(f=>!f.id.startsWith("temp-"))),null}},[t,d]),clearMessages:(0,s.useCallback)(()=>{l([]),c(void 0),v(null)},[]),conversationId:d}}var q=({onSend:e,disabled:n=!1,placeholder:r="Type a message...",allowFiles:t=!1,className:a=""})=>{const[l,d]=(0,s.useState)(""),[c,p]=(0,s.useState)([]),u=(0,s.useRef)(null),b=(0,s.useRef)(null),v=(0,s.useCallback)(()=>{const i=b.current;if(!i)return;const y=110;i.style.height="auto",i.style.height=`${Math.min(i.scrollHeight+2,y)}px`,i.style.overflowY=i.scrollHeight+2>y?"auto":"hidden"},[]),I=(0,s.useCallback)(i=>{i.preventDefault(),(l.trim()||c.length>0)&&(e(l.trim(),c.length>0?c:void 0),d(""),p([]),requestAnimationFrame(v))},[l,c,e,v]),g=(0,s.useCallback)(i=>{i.key==="Enter"&&!i.shiftKey&&(i.preventDefault(),I(i))},[I]),m=(0,s.useCallback)(i=>{const y=Array.from(i.target.files||[]);p(f=>[...f,...y])},[]),S=(0,s.useCallback)(i=>{p(y=>y.filter((f,x)=>x!==i))},[]),w=l.trim()||c.length>0;return(0,o.jsxs)("form",{onSubmit:I,className:`ago-chat-input ${a}`,style:{display:"flex",flexDirection:"column",gap:"8px",padding:"12px 16px",borderTop:"1px solid #dee3e8",backgroundColor:"#fff"},children:[c.length>0&&(0,o.jsx)("div",{className:"ago-chat-input__files",style:{display:"flex",flexWrap:"wrap",gap:"6px"},children:c.map((i,y)=>(0,o.jsxs)("div",{style:{display:"flex",alignItems:"center",gap:"6px",padding:"4px 10px",backgroundColor:"#f0f2f5",borderRadius:"6px",fontSize:"12px",color:"#30373e"},children:[(0,o.jsx)("span",{style:{maxWidth:"120px",overflow:"hidden",textOverflow:"ellipsis",whiteSpace:"nowrap"},children:i.name}),(0,o.jsx)("button",{type:"button",onClick:()=>S(y),"aria-label":`Remove ${i.name}`,style:{border:"none",background:"none",cursor:"pointer",padding:"0",color:"#6b6d6f",fontSize:"14px",lineHeight:1},children:"×"})]},y))}),(0,o.jsxs)("div",{style:{display:"flex",gap:"8px",alignItems:"flex-end"},children:[t&&(0,o.jsxs)(o.Fragment,{children:[(0,o.jsx)("button",{type:"button",onClick:()=>u.current?.click(),disabled:n,"aria-label":"Attach file",style:{padding:"8px",border:"1px solid #dee3e8",borderRadius:"8px",backgroundColor:"#fff",cursor:n?"not-allowed":"pointer",color:"#6b6d6f",fontSize:"16px",lineHeight:1},children:"+"}),(0,o.jsx)("input",{ref:u,type:"file",multiple:!0,onChange:m,style:{display:"none"}})]}),(0,o.jsx)("textarea",{ref:b,value:l,onChange:i=>{d(i.target.value),v()},onKeyDown:g,placeholder:r,"aria-label":r,disabled:n,rows:1,style:{flex:1,padding:"10px 14px",border:"1px solid #dee3e8",borderRadius:"20px",resize:"none",outline:"none",boxSizing:"border-box",maxHeight:"110px",overflowY:"hidden",fontFamily:"inherit",fontSize:"16px",lineHeight:1.4,color:"#30373e",backgroundColor:"#f8f8f8",transition:"border-color 0.15s"},onFocus:i=>{i.currentTarget.style.borderColor="#1b5fc4"},onBlur:i=>{i.currentTarget.style.borderColor="#dee3e8"}}),(0,o.jsx)("button",{type:"submit",disabled:n||!w,style:{padding:"10px 18px",border:"none",borderRadius:"20px",backgroundColor:n||!w?"#b5bfc8":"#03182f",color:"#fff",cursor:n||!w?"not-allowed":"pointer",fontWeight:500,fontSize:"16px",transition:"background-color 0.15s"},children:"Send"})]})]})},X=({href:e,children:n,...r})=>(0,o.jsx)("a",{href:e,target:"_blank",rel:"noopener noreferrer",style:{color:"#1b5fc4",textDecoration:"underline"},...r,children:n}),Q=({children:e,...n})=>(0,o.jsx)("p",{style:{margin:"0 0 8px 0",lineHeight:"1.6"},...n,children:e}),R=(e,n)=>{const r=({children:t,...a})=>s.default.createElement(`h${e}`,{style:{margin:"16px 0 8px 0",fontSize:n,fontWeight:600,lineHeight:"1.3"},...a},t);return r.displayName=`MarkdownHeading${e}`,r},Z=({children:e,...n})=>(0,o.jsx)("ul",{style:{margin:"0 0 8px 0",paddingLeft:"20px",listStyleType:"disc",listStylePosition:"outside"},...n,children:e}),ee=({children:e,...n})=>(0,o.jsx)("ol",{style:{margin:"0 0 8px 0",paddingLeft:"20px",listStyleType:"decimal",listStylePosition:"outside"},...n,children:e}),te=({children:e,...n})=>(0,o.jsx)("li",{style:{display:"list-item",margin:"2px 0",lineHeight:"1.6"},...n,children:e}),ne=({className:e,children:n,...r})=>e!==void 0||String(n).includes(`
2
- `)?(0,o.jsx)("code",{style:{display:"block",background:"#f5f5f5",padding:"8px 12px",borderRadius:"6px",fontSize:"13px",overflowX:"auto",fontFamily:'"IBM Plex Mono", monospace'},...r,children:n}):(0,o.jsx)("code",{style:{background:"#f0f2f5",padding:"2px 5px",borderRadius:"4px",fontSize:"13px",fontFamily:'"IBM Plex Mono", monospace'},...r,children:n}),re=({children:e,...n})=>(0,o.jsx)("pre",{style:{margin:"0 0 8px 0"},...n,children:e}),oe=({children:e,...n})=>(0,o.jsx)("blockquote",{style:{borderLeft:"4px solid #dee3e8",paddingLeft:"12px",margin:"0 0 8px 0",fontStyle:"italic",color:"#6b6d6f"},...n,children:e}),se=({children:e,...n})=>(0,o.jsx)("div",{style:{overflowX:"auto",margin:"0 0 8px 0"},children:(0,o.jsx)("table",{style:{borderCollapse:"collapse",width:"100%",fontSize:"13px"},...n,children:e})}),ae=({children:e,...n})=>(0,o.jsx)("th",{style:{border:"1px solid #dee3e8",padding:"6px 10px",textAlign:"left",backgroundColor:"#f5f7fa",fontWeight:600},...n,children:e}),ie=({children:e,...n})=>(0,o.jsx)("td",{style:{border:"1px solid #dee3e8",padding:"6px 10px"},...n,children:e}),le=({alt:e,...n})=>(0,o.jsx)("img",{alt:e??"",style:{maxWidth:"100%",borderRadius:"8px",margin:"4px 0"},...n}),ce=e=>(0,o.jsx)("hr",{style:{border:"none",borderTop:"1px solid #dee3e8",margin:"12px 0"},...e}),de={a:X,p:Q,h1:R(1,"20px"),h2:R(2,"18px"),h3:R(3,"16px"),h4:R(4,"15px"),h5:R(5,"14px"),h6:R(6,"13px"),ul:Z,ol:ee,li:te,code:ne,pre:re,blockquote:oe,table:se,th:ae,td:ie,img:le,hr:ce},ue=[T.default],$=({content:e})=>(0,o.jsx)(P.default,{remarkPlugins:ue,components:de,children:e}),fe=({attachment:e,isUser:n})=>{const r=F.safeAttachmentUrl(e.url);if(F.canInlineImage(e))return(0,o.jsx)("a",{href:r,target:"_blank",rel:"noopener noreferrer",style:{display:"inline-block",textDecoration:"none"},children:(0,o.jsx)("img",{src:r,alt:e.name,loading:"lazy",style:{maxWidth:"180px",maxHeight:"160px",objectFit:"cover",borderRadius:"10px",border:"1px solid #dee3e8",display:"block"}})});const t=F.formatFileSize(e.fileSize),a=(0,o.jsxs)(o.Fragment,{children:[(0,o.jsx)("span",{style:{fontSize:"16px",lineHeight:1,flexShrink:0},"aria-hidden":!0,children:"📄"}),(0,o.jsxs)("span",{style:{display:"flex",flexDirection:"column",minWidth:0},children:[(0,o.jsx)("span",{style:{overflow:"hidden",textOverflow:"ellipsis",whiteSpace:"nowrap",maxWidth:"160px"},title:e.name,children:e.name}),t&&(0,o.jsx)("span",{style:{fontSize:"11px",color:"#6b6d6f"},children:t})]})]}),l={display:"inline-flex",alignItems:"center",gap:"8px",padding:"8px 12px",borderRadius:"10px",border:"1px solid #dee3e8",backgroundColor:n?"rgba(255,255,255,0.12)":"#fff",color:n?"#fff":"#30373e",fontSize:"13px",textDecoration:"none",maxWidth:"220px"};return r?(0,o.jsx)("a",{href:r,target:"_blank",rel:"noopener noreferrer",style:l,children:a}):(0,o.jsx)("div",{style:l,children:a})},ge=({source:e,index:n})=>{const r=(0,o.jsxs)("div",{style:{display:"flex",alignItems:"center",gap:"8px",width:"100%",minWidth:0},children:[(0,o.jsx)("div",{style:{flexShrink:0,width:"18px",height:"18px",borderRadius:"3px",border:"1px solid #1b5fc4",color:"#1b5fc4",fontSize:"11px",fontWeight:500,display:"flex",alignItems:"center",justifyContent:"center",backgroundColor:"#f0f4ff"},children:n+1}),(0,o.jsx)("div",{style:{fontSize:"12px",overflow:"hidden",textOverflow:"ellipsis",whiteSpace:"nowrap",color:"#30373e"},title:e.title,children:e.title})]}),t={display:"flex",alignItems:"center",padding:"8px 10px",border:"1px solid #dee3e8",borderRadius:"8px",backgroundColor:"#fff",cursor:e.url?"pointer":"default",textDecoration:"none",color:"inherit",minWidth:0,transition:"border-color 0.15s"};return e.url?(0,o.jsx)("a",{href:e.url,target:"_blank",rel:"noopener noreferrer",style:t,onMouseEnter:a=>{a.currentTarget.style.borderColor="#1b5fc4"},onMouseLeave:a=>{a.currentTarget.style.borderColor="#dee3e8"},children:r}):(0,o.jsx)("div",{style:t,children:r})},pe=()=>(0,o.jsxs)("div",{style:{display:"flex",gap:"4px",padding:"4px 0"},children:[[0,1,2].map(e=>(0,o.jsx)("div",{style:{width:"6px",height:"6px",borderRadius:"50%",backgroundColor:"#b5bfc8",animation:"ago-pulse 1.2s ease-in-out infinite",animationDelay:`${e*.2}s`}},e)),(0,o.jsx)("style",{children:`
1
+ Object.defineProperty(exports,Symbol.toStringTag,{value:"Module"});const W=require("./rolldown-runtime-16Nf8qvH.cjs"),F=require("./AgoClient-wcPRaIMs.cjs"),J=require("./autoContinue-CcCTva-D.cjs"),I=require("./createFormCollector-eimwwWEi.cjs"),V=require("./createMockClient-CjdCqixj.cjs");let s=require("react");s=W.__toESM(s,1);let o=require("react/jsx-runtime"),P=require("react-markdown");P=W.__toESM(P,1);let T=require("remark-gfm");T=W.__toESM(T,1);function q(e){const[t,r]=(0,s.useState)(!1),n=(0,s.useRef)(null),a=(0,s.useMemo)(()=>{if(n.current&&(n.current.destroy(),n.current=null),!e)return null;const l=new F.AgoClient(e);return n.current=l,l},[e?.baseUrl,e?.widgetId]);return(0,s.useEffect)(()=>(r(!0),()=>{n.current?.destroy(),n.current=null}),[a]),(0,s.useEffect)(()=>{n.current&&e&&n.current.updateConfig({agent:e.agent,defaultAgentId:e.defaultAgentId,permission:e.permission,userEmail:e.userEmail,userJwt:e.userJwt,debug:e.debug,warnOnEmptyReply:e.warnOnEmptyReply})},[e?.agent,e?.defaultAgentId,e?.permission,e?.userEmail,e?.userJwt,e?.debug,e?.warnOnEmptyReply]),{client:a,isReady:t}}var z=(0,s.createContext)(null),Y=({children:e,client:t,tools:r,helpers:n,pageContext:a,...l})=>{const{client:d}=q(t?null:l),c=t||d;return(0,s.useEffect)(()=>{if(!(!r||r.length===0)){for(const g of r)c.register(g);return()=>{for(const g of r)c.unregisterFunction(g.name)}}},[c,r]),(0,s.useEffect)(()=>{if(!n)return;const g=[];return Promise.resolve().then(()=>require("./functions-IGSjjvF4.cjs")).then(f=>f.functions_exports).then(f=>{for(const[b,C]of Object.entries(n)){const j=f[b];if(!j){console.warn(`[AGO] Unknown helper: "${b}"`);continue}const h=C===!0?j:{...j,handler:C};c.register(h),g.push(h.name)}}),()=>{for(const f of g)c.unregisterFunction(f)}},[c,n]),(0,s.useEffect)(()=>{a==="auto"&&c.enableAutoPageContext()},[c,a]),(0,o.jsx)(z.Provider,{value:c,children:e})};function M(){const e=(0,s.useContext)(z);if(!e)throw new Error('useAgoClient must be used within an <AgoProvider>. Wrap your component tree with <AgoProvider baseUrl="...">.');return e}function N(){return(0,s.useContext)(z)}function L({client:e,conversationId:t}={}){const r=N(),n=e||r;if(!n)throw new Error("useMessages requires an AgoClient. Either pass it as options.client or wrap your app in <AgoProvider>.");const[a,l]=(0,s.useState)([]),[d,c]=(0,s.useState)(t),[g,f]=(0,s.useState)(!1),[b,C]=(0,s.useState)(null);(0,s.useEffect)(()=>{t&&t!==d&&(c(t),j(t))},[t]);const j=async h=>{try{l((await n.getMessages(h)).filter(y=>!y.hidden))}catch(y){C(y instanceof Error?y:new Error("Failed to load messages"))}};return(0,s.useEffect)(()=>{const h=u=>u==="IN_PROGRESS"||u==="WAITING_CLIENT",y=u=>{d||c(u.conversationId),f(!0),l(p=>{const m=p.findIndex(x=>x.id===u.messageId);return m>=0?p.map((x,_)=>_===m?{...x,status:"IN_PROGRESS"}:x):p.some(x=>x.role==="assistant"&&h(x.status))?p:[...p,{id:u.messageId,conversationId:u.conversationId,content:"",role:"assistant",status:"IN_PROGRESS",createdAt:new Date}]})},S=u=>{l(p=>{const m=p.findIndex(x=>x.id===u.messageId);return m<0?p:p.map((x,_)=>_===m?{...x,content:x.content+u.content}:x)})},k=u=>{l(p=>{let m=-1;for(let x=p.length-1;x>=0;x--)if(p[x].role==="assistant"&&h(p[x].status)){m=x;break}return m<0?p:[...p.slice(0,m),{...p[m],...u},...p.slice(m+1)]})},i=u=>{l(p=>{const m=p.findIndex(x=>x.id===u.id);return m>=0?[...p.slice(0,m),u,...p.slice(m+1)]:[...p,u]}),f(!1)},v=u=>{C(new Error(u.error)),f(!1)};return n.on("message:start",y),n.on("message:chunk",S),n.on("message:answer-complete",k),n.on("message:complete",i),n.on("message:error",v),()=>{n.off("message:start",y),n.off("message:chunk",S),n.off("message:answer-complete",k),n.off("message:complete",i),n.off("message:error",v)}},[n,d]),{messages:a,isLoading:g,error:b,sendMessage:(0,s.useCallback)(async(h,y)=>{f(!0),C(null);const S={id:`temp-${Date.now()}`,conversationId:d||"",content:h,role:"user",status:"DONE",attachments:y&&y.length>0?F.attachmentsFromFiles(y):void 0,createdAt:new Date},k={id:`temp-assistant-${Date.now()}`,conversationId:d||"",content:"",role:"assistant",status:"IN_PROGRESS",createdAt:new Date};l(i=>[...i,S,k]);try{const i=await n.sendMessage(h,{conversationId:d,files:y});return i.conversationId&&!d&&c(i.conversationId),l(v=>{const u=v.filter(m=>!m.id.startsWith("temp-")),p={...S,id:S.id.replace("temp-","user-"),conversationId:i.conversationId};return u.some(m=>m.id===i.id)?[...u,p].sort((m,x)=>new Date(m.createdAt).getTime()-new Date(x.createdAt).getTime()):[...u,p,i]}),i}catch(i){return C(i instanceof Error?i:new Error("Failed to send message")),f(!1),l(v=>v.filter(u=>!u.id.startsWith("temp-"))),null}},[n,d]),clearMessages:(0,s.useCallback)(()=>{l([]),c(void 0),C(null)},[]),conversationId:d}}var H=({onSend:e,disabled:t=!1,placeholder:r="Type a message...",allowFiles:n=!1,className:a=""})=>{const[l,d]=(0,s.useState)(""),[c,g]=(0,s.useState)([]),f=(0,s.useRef)(null),b=(0,s.useRef)(null),C=(0,s.useCallback)(()=>{const i=b.current;if(!i)return;const v=110;i.style.height="auto",i.style.height=`${Math.min(i.scrollHeight+2,v)}px`,i.style.overflowY=i.scrollHeight+2>v?"auto":"hidden"},[]),j=(0,s.useCallback)(i=>{i.preventDefault(),(l.trim()||c.length>0)&&(e(l.trim(),c.length>0?c:void 0),d(""),g([]),requestAnimationFrame(C))},[l,c,e,C]),h=(0,s.useCallback)(i=>{i.key==="Enter"&&!i.shiftKey&&(i.preventDefault(),j(i))},[j]),y=(0,s.useCallback)(i=>{const v=Array.from(i.target.files||[]);g(u=>[...u,...v])},[]),S=(0,s.useCallback)(i=>{g(v=>v.filter((u,p)=>p!==i))},[]),k=l.trim()||c.length>0;return(0,o.jsxs)("form",{onSubmit:j,className:`ago-chat-input ${a}`,style:{display:"flex",flexDirection:"column",gap:"8px",padding:"12px 16px",borderTop:"1px solid #dee3e8",backgroundColor:"#fff"},children:[c.length>0&&(0,o.jsx)("div",{className:"ago-chat-input__files",style:{display:"flex",flexWrap:"wrap",gap:"6px"},children:c.map((i,v)=>(0,o.jsxs)("div",{style:{display:"flex",alignItems:"center",gap:"6px",padding:"4px 10px",backgroundColor:"#f0f2f5",borderRadius:"6px",fontSize:"12px",color:"#30373e"},children:[(0,o.jsx)("span",{style:{maxWidth:"120px",overflow:"hidden",textOverflow:"ellipsis",whiteSpace:"nowrap"},children:i.name}),(0,o.jsx)("button",{type:"button",onClick:()=>S(v),"aria-label":`Remove ${i.name}`,style:{border:"none",background:"none",cursor:"pointer",padding:"0",color:"#6b6d6f",fontSize:"14px",lineHeight:1},children:"×"})]},v))}),(0,o.jsxs)("div",{style:{display:"flex",gap:"8px",alignItems:"flex-end"},children:[n&&(0,o.jsxs)(o.Fragment,{children:[(0,o.jsx)("button",{type:"button",onClick:()=>f.current?.click(),disabled:t,"aria-label":"Attach file",style:{padding:"8px",border:"1px solid #dee3e8",borderRadius:"8px",backgroundColor:"#fff",cursor:t?"not-allowed":"pointer",color:"#6b6d6f",fontSize:"16px",lineHeight:1},children:"+"}),(0,o.jsx)("input",{ref:f,type:"file",multiple:!0,onChange:y,style:{display:"none"}})]}),(0,o.jsx)("textarea",{ref:b,value:l,onChange:i=>{d(i.target.value),C()},onKeyDown:h,placeholder:r,"aria-label":r,disabled:t,rows:1,style:{flex:1,padding:"10px 14px",border:"1px solid #dee3e8",borderRadius:"20px",resize:"none",outline:"none",boxSizing:"border-box",maxHeight:"110px",overflowY:"hidden",fontFamily:"inherit",fontSize:"16px",lineHeight:1.4,color:"#30373e",backgroundColor:"#f8f8f8",transition:"border-color 0.15s"},onFocus:i=>{i.currentTarget.style.borderColor="#1b5fc4"},onBlur:i=>{i.currentTarget.style.borderColor="#dee3e8"}}),(0,o.jsx)("button",{type:"submit",disabled:t||!k,style:{padding:"10px 18px",border:"none",borderRadius:"20px",backgroundColor:t||!k?"#b5bfc8":"#03182f",color:"#fff",cursor:t||!k?"not-allowed":"pointer",fontWeight:500,fontSize:"16px",transition:"background-color 0.15s"},children:"Send"})]})]})},X=({href:e,children:t,...r})=>(0,o.jsx)("a",{href:e,target:"_blank",rel:"noopener noreferrer",style:{color:"#1b5fc4",textDecoration:"underline"},...r,children:t}),Q=({children:e,...t})=>(0,o.jsx)("p",{style:{margin:"0 0 8px 0",lineHeight:"1.6"},...t,children:e}),R=(e,t)=>{const r=({children:n,...a})=>s.default.createElement(`h${e}`,{style:{margin:"16px 0 8px 0",fontSize:t,fontWeight:600,lineHeight:"1.3"},...a},n);return r.displayName=`MarkdownHeading${e}`,r},Z=({children:e,...t})=>(0,o.jsx)("ul",{style:{margin:"0 0 8px 0",paddingLeft:"20px",listStyleType:"disc",listStylePosition:"outside"},...t,children:e}),ee=({children:e,...t})=>(0,o.jsx)("ol",{style:{margin:"0 0 8px 0",paddingLeft:"20px",listStyleType:"decimal",listStylePosition:"outside"},...t,children:e}),te=({children:e,...t})=>(0,o.jsx)("li",{style:{display:"list-item",margin:"2px 0",lineHeight:"1.6"},...t,children:e}),ne=({className:e,children:t,...r})=>e!==void 0||String(t).includes(`
2
+ `)?(0,o.jsx)("code",{style:{display:"block",background:"#f5f5f5",padding:"8px 12px",borderRadius:"6px",fontSize:"13px",overflowX:"auto",fontFamily:'"IBM Plex Mono", monospace'},...r,children:t}):(0,o.jsx)("code",{style:{background:"#f0f2f5",padding:"2px 5px",borderRadius:"4px",fontSize:"13px",fontFamily:'"IBM Plex Mono", monospace'},...r,children:t}),re=({children:e,...t})=>(0,o.jsx)("pre",{style:{margin:"0 0 8px 0"},...t,children:e}),oe=({children:e,...t})=>(0,o.jsx)("blockquote",{style:{borderLeft:"4px solid #dee3e8",paddingLeft:"12px",margin:"0 0 8px 0",fontStyle:"italic",color:"#6b6d6f"},...t,children:e}),se=({children:e,...t})=>(0,o.jsx)("div",{style:{overflowX:"auto",margin:"0 0 8px 0"},children:(0,o.jsx)("table",{style:{borderCollapse:"collapse",width:"100%",fontSize:"13px"},...t,children:e})}),ae=({children:e,...t})=>(0,o.jsx)("th",{style:{border:"1px solid #dee3e8",padding:"6px 10px",textAlign:"left",backgroundColor:"#f5f7fa",fontWeight:600},...t,children:e}),ie=({children:e,...t})=>(0,o.jsx)("td",{style:{border:"1px solid #dee3e8",padding:"6px 10px"},...t,children:e}),le=({alt:e,...t})=>(0,o.jsx)("img",{alt:e??"",style:{maxWidth:"100%",borderRadius:"8px",margin:"4px 0"},...t}),ce=e=>(0,o.jsx)("hr",{style:{border:"none",borderTop:"1px solid #dee3e8",margin:"12px 0"},...e}),de={a:X,p:Q,h1:R(1,"20px"),h2:R(2,"18px"),h3:R(3,"16px"),h4:R(4,"15px"),h5:R(5,"14px"),h6:R(6,"13px"),ul:Z,ol:ee,li:te,code:ne,pre:re,blockquote:oe,table:se,th:ae,td:ie,img:le,hr:ce},ue=[T.default],O=({content:e})=>(0,o.jsx)(P.default,{remarkPlugins:ue,components:de,children:e}),fe=({attachment:e,isUser:t})=>{const r=F.safeAttachmentUrl(e.url);if(F.canInlineImage(e))return(0,o.jsx)("a",{href:r,target:"_blank",rel:"noopener noreferrer",style:{display:"inline-block",textDecoration:"none"},children:(0,o.jsx)("img",{src:r,alt:e.name,loading:"lazy",style:{maxWidth:"180px",maxHeight:"160px",objectFit:"cover",borderRadius:"10px",border:"1px solid #dee3e8",display:"block"}})});const n=F.formatFileSize(e.fileSize),a=(0,o.jsxs)(o.Fragment,{children:[(0,o.jsx)("span",{style:{fontSize:"16px",lineHeight:1,flexShrink:0},"aria-hidden":!0,children:"📄"}),(0,o.jsxs)("span",{style:{display:"flex",flexDirection:"column",minWidth:0},children:[(0,o.jsx)("span",{style:{overflow:"hidden",textOverflow:"ellipsis",whiteSpace:"nowrap",maxWidth:"160px"},title:e.name,children:e.name}),n&&(0,o.jsx)("span",{style:{fontSize:"11px",color:"#6b6d6f"},children:n})]})]}),l={display:"inline-flex",alignItems:"center",gap:"8px",padding:"8px 12px",borderRadius:"10px",border:"1px solid #dee3e8",backgroundColor:t?"rgba(255,255,255,0.12)":"#fff",color:t?"#fff":"#30373e",fontSize:"13px",textDecoration:"none",maxWidth:"220px"};return r?(0,o.jsx)("a",{href:r,target:"_blank",rel:"noopener noreferrer",style:l,children:a}):(0,o.jsx)("div",{style:l,children:a})},ge=({source:e,index:t})=>{const r=(0,o.jsxs)("div",{style:{display:"flex",alignItems:"center",gap:"8px",width:"100%",minWidth:0},children:[(0,o.jsx)("div",{style:{flexShrink:0,width:"18px",height:"18px",borderRadius:"3px",border:"1px solid #1b5fc4",color:"#1b5fc4",fontSize:"11px",fontWeight:500,display:"flex",alignItems:"center",justifyContent:"center",backgroundColor:"#f0f4ff"},children:t+1}),(0,o.jsx)("div",{style:{fontSize:"12px",overflow:"hidden",textOverflow:"ellipsis",whiteSpace:"nowrap",color:"#30373e"},title:e.title,children:e.title})]}),n={display:"flex",alignItems:"center",padding:"8px 10px",border:"1px solid #dee3e8",borderRadius:"8px",backgroundColor:"#fff",cursor:e.url?"pointer":"default",textDecoration:"none",color:"inherit",minWidth:0,transition:"border-color 0.15s"};return e.url?(0,o.jsx)("a",{href:e.url,target:"_blank",rel:"noopener noreferrer",style:n,onMouseEnter:a=>{a.currentTarget.style.borderColor="#1b5fc4"},onMouseLeave:a=>{a.currentTarget.style.borderColor="#dee3e8"},children:r}):(0,o.jsx)("div",{style:n,children:r})},pe=()=>(0,o.jsxs)("div",{style:{display:"flex",gap:"4px",padding:"4px 0"},children:[[0,1,2].map(e=>(0,o.jsx)("div",{style:{width:"6px",height:"6px",borderRadius:"50%",backgroundColor:"#b5bfc8",animation:"ago-pulse 1.2s ease-in-out infinite",animationDelay:`${e*.2}s`}},e)),(0,o.jsx)("style",{children:`
3
3
  @keyframes ago-pulse {
4
4
  0%, 80%, 100% { opacity: 0.3; transform: scale(0.8); }
5
5
  40% { opacity: 1; transform: scale(1); }
6
6
  }
7
- `})]}),B=({message:e,className:n="",showAgentName:r=!1,isLast:t=!1,onFollowUpClick:a})=>{const l=e.role==="user",d=e.status==="IN_PROGRESS"||e.status==="WAITING_CLIENT";return(0,o.jsxs)("div",{className:`ago-message ago-message--${e.role} ${n}`,style:{display:"flex",flexDirection:"column",alignItems:l?"flex-end":"flex-start",marginBottom:"16px"},children:[!l&&r&&e.agent&&(0,o.jsx)("div",{className:"ago-message__agent",style:{display:"flex",alignItems:"center",gap:"6px",fontSize:"13px",fontWeight:500,color:"#30373e",marginBottom:"6px",padding:"0 4px"},children:e.agent.displayName||e.agent.name}),!l&&e.sources&&e.sources.length>0&&(0,o.jsx)("div",{className:"ago-message__sources",style:{display:"grid",gridTemplateColumns:"1fr 1fr",gap:"6px",marginBottom:"10px",width:"100%",maxWidth:"85%"},children:e.sources.map((c,p)=>(0,o.jsx)(ge,{source:c,index:p},c.id))}),e.attachments&&e.attachments.length>0&&(0,o.jsx)("div",{className:"ago-message__attachments",style:{display:"flex",flexWrap:"wrap",gap:"6px",marginBottom:"6px",justifyContent:l?"flex-end":"flex-start",maxWidth:"75%"},children:e.attachments.map(c=>(0,o.jsx)(fe,{attachment:c,isUser:l},c.id))}),(e.content||d)&&(0,o.jsx)("div",{className:"ago-message__content",style:{maxWidth:l?"75%":"100%",padding:l?"10px 14px":"2px 8px",borderRadius:l?"16px":"0",backgroundColor:l?"#03182f":"transparent",color:l?"#fff":"#30373e",wordBreak:"break-word",fontSize:"16px",lineHeight:"1.6"},children:e.content?(0,o.jsx)($,{content:e.content}):d&&(0,o.jsx)(pe,{})}),t&&e.followUpReplies&&e.followUpReplies.length>0&&(0,o.jsx)("div",{className:"ago-message__followups",style:{display:"flex",flexWrap:"wrap",gap:"8px",marginTop:"10px"},children:e.followUpReplies.map((c,p)=>(0,o.jsx)("button",{type:"button",className:"ago-message__followup-btn",disabled:!a,onClick:a?()=>a(c):void 0,style:{minHeight:"36px",padding:"6px 14px",fontSize:"13px",borderRadius:"16px",border:"1px solid #dee3e8",backgroundColor:"#fff",color:"#30373e",cursor:a?"pointer":"default",transition:"border-color 0.15s"},onMouseEnter:u=>{u.currentTarget.style.borderColor="#1b5fc4"},onMouseLeave:u=>{u.currentTarget.style.borderColor="#dee3e8"},children:c},p))})]})},xe=({client:e,conversationId:n,title:r="Chat",welcomeMessage:t="Hello! How can I help you today?",placeholder:a="Type a message...",allowFiles:l=!1,height:d=500,logoUrl:c,showAgentName:p=!1,forms:u,onFollowUpClick:b,className:v="",onMessageSent:I,onMessageReceived:g})=>{const m=(0,s.useRef)(null),S=_(),w=e??S,{messages:i,isLoading:y,error:f,sendMessage:x}=L({client:e,conversationId:n});(0,s.useEffect)(()=>{if(!w||!u||u.length===0)return;let k=!1;const A=[];return Promise.all(u.map(j=>j.schema!=null?Promise.resolve(M.createFormCollector(j)):M.loadFormCollector(w,j))).then(j=>{if(!k)for(const J of j)A.push(J.install(w))}).catch(()=>{}),()=>{k=!0,A.forEach(j=>j())}},[w,u?JSON.stringify(u.map(k=>[k.name,k.schema??null,k.submit??!1,k.description??null])):""]),(0,s.useEffect)(()=>{m.current?.scrollIntoView({behavior:"smooth"})},[i]),(0,s.useEffect)(()=>{const k=i[i.length-1];k&&k.role==="assistant"&&k.status==="DONE"&&g&&g({id:k.id,content:k.content})},[i,g]);const C=async(k,A)=>{I?.(k),await x(k,A)},h=i[i.length-1],N=y&&h?.role==="assistant"&&(h.status==="IN_PROGRESS"||h.status==="WAITING_CLIENT"),K=b===!1?void 0:b??(k=>C(k));return(0,o.jsxs)("div",{className:`ago-chat-widget ${v}`,style:{display:"flex",flexDirection:"column",height:typeof d=="number"?`${d}px`:d,border:"1px solid #dee3e8",borderRadius:"16px",overflow:"hidden",backgroundColor:"#fff",fontFamily:'"IBM Plex Sans", -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, sans-serif',textAlign:"left",boxShadow:"rgba(15, 15, 15, 0.08) 0px 2px 16px 0px"},children:[(0,o.jsxs)("div",{className:"ago-chat-widget__header",style:{padding:"14px 16px",borderBottom:"1px solid #dee3e8",backgroundColor:"#03182f",color:"#e8f0fe",display:"flex",alignItems:"center",gap:"10px"},children:[c&&(0,o.jsx)("img",{src:c,alt:"Logo",style:{height:"24px",width:"auto"}}),(0,o.jsx)("h3",{style:{margin:0,fontSize:"15px",fontWeight:600},children:r})]}),(0,o.jsxs)("div",{className:"ago-chat-widget__messages",role:"log","aria-live":"polite","aria-relevant":"additions text","aria-atomic":!1,style:{flex:1,overflow:"auto",padding:"16px",backgroundColor:"#fbfbfb"},children:[i.length===0?(0,o.jsx)("div",{style:{textAlign:"center",color:"#6b6d6f",padding:"24px 16px",fontSize:"16px",lineHeight:"1.5"},children:t}):i.map((k,A)=>(0,o.jsx)(B,{message:k,showAgentName:p,isLast:A===i.length-1,onFollowUpClick:K},k.id)),f&&(0,o.jsx)("div",{role:"alert",style:{padding:"10px 14px",backgroundColor:"#fef2f2",color:"#dc2626",borderRadius:"12px",marginTop:"8px",fontSize:"13px",border:"1px solid #fecaca"},children:f.message}),(0,o.jsx)("div",{ref:m})]}),(0,o.jsx)(q,{onSend:C,disabled:N,placeholder:a,allowFiles:l})]})};function G({client:e,autoLoad:n=!0}={}){const r=_(),t=e||r;if(!t)throw new Error("useConversation requires an AgoClient. Either pass it as options.client or wrap your app in <AgoProvider>.");const[a,l]=(0,s.useState)([]),[d,c]=(0,s.useState)(null),[p,u]=(0,s.useState)(!1),[b,v]=(0,s.useState)(null),I=(0,s.useCallback)(async()=>{u(!0),v(null);try{l(await t.getConversations())}catch(S){v(S instanceof Error?S:new Error("Failed to load conversations"))}finally{u(!1)}},[t]),g=(0,s.useCallback)(async S=>{u(!0),v(null);try{c(await t.getConversation(S))}catch(w){v(w instanceof Error?w:new Error("Failed to load conversation"))}finally{u(!1)}},[t]),m=(0,s.useCallback)(()=>{c(null)},[]);return(0,s.useEffect)(()=>{n&&I()},[n,I]),{conversations:a,currentConversation:d,isLoading:p,error:b,selectConversation:g,startNewConversation:m,refreshConversations:I}}function me(e={}){const n=_(),r=e.client||n;if(!r)throw new Error("useChat requires an AgoClient. Either pass it as options.client or wrap your app in <AgoProvider>.");const t=L({client:r,conversationId:e.conversationId}),a=G({client:r,autoLoad:e.autoLoad});return{messages:t.messages,isLoading:t.isLoading,error:t.error||a.error,sendMessage:t.sendMessage,clearMessages:t.clearMessages,conversationId:t.conversationId,conversations:a.conversations,currentConversation:a.currentConversation,isConversationsLoading:a.isLoading,selectConversation:a.selectConversation,startNewConversation:a.startNewConversation,refreshConversations:a.refreshConversations}}function he(e,n){const r=E(),{name:t,description:a,parameters:l,handler:d,maxResultBytes:c}=typeof e=="string"?{name:e,...n}:e,p=(0,s.useRef)(d);p.current=d,(0,s.useEffect)(()=>{const u=b=>p.current(b);return r.registerFunction(t,u,{description:a,parameters:l,maxResultBytes:c}),()=>{r.unregisterFunction(t)}},[r,t,a,l,c])}function ye(e,n){const r=E(),t=(0,s.useRef)(e);t.current=e,(0,s.useEffect)(()=>(r.registerNavigationFunction(a=>t.current(a),n),()=>{r.unregisterNavigationFunction()}),[r,n])}function be(e,n){const r=E(),t=n?.functionName??"setPageState",a=(0,s.useRef)(e);a.current=e,(0,s.useEffect)(()=>{const l=a.current.map(d=>{const c=()=>a.current.find(p=>p.name===d.name)??d;return{name:d.name,description:d.description,schema:d.schema,get:d.get?()=>c().get?.():void 0,set:p=>c().set(p)}});return r.registerPageStateFunction(l,{functionName:t}),()=>{r.unregisterPageStateFunction(t)}},[r,t])}var ve="You have navigated the user to a new page. That page now exposes its editable state through the available setPageState function, and its current values in the page context. If the user's latest request also asked to change something on this page, call setPageState now to apply exactly those changes and nothing else. Otherwise, reply with a short confirmation only.";function z(e){return{navigationFunctions:e?.navigationFunctions??["navigateToPage"],pageStateFunctionName:e?.pageStateFunctionName??"setPageState",continuationPrompt:e?.continuationPrompt??ve,maxDepth:e?.maxDepth??1,readinessTimeoutMs:e?.readinessTimeoutMs??4e3,settleMs:e?.settleMs??150,enabled:e?.enabled??!0}}function Ce(e){const n=E(),r=(0,s.useRef)(z(e));r.current=z(e),(0,s.useEffect)(()=>{const t={navigated:!1,pausedTurnNavigated:!1,depth:0,runId:0,ourSendPending:!1},a=()=>n.getRegisteredFunctions().some(g=>g.name===r.current.pageStateFunctionName),l=g=>new Promise(m=>{let S=!1;const w=x=>{S||(S=!0,clearTimeout(f),n.off("context:changed",y),m(x))},i=()=>setTimeout(()=>w(g===t.runId&&a()),r.current.settleMs),y=()=>{if(g!==t.runId)return w(!1);a()&&(n.off("context:changed",y),i())},f=setTimeout(()=>w(!1),r.current.readinessTimeoutMs);a()?i():n.on("context:changed",y)}),d=async g=>{const m=++t.runId;if(!(!await l(m)||m!==t.runId)){t.depth+=1,t.ourSendPending=!0;try{await n.sendMessage(r.current.continuationPrompt,{conversationId:g,hidden:!0})}catch{t.ourSendPending=!1}}},c=g=>{r.current.navigationFunctions.includes(g.functionName)&&(t.navigated=!0)},p=n.registerResumeGate(async()=>{r.current.enabled&&t.pausedTurnNavigated&&(t.pausedTurnNavigated=!1,await l(++t.runId))}),u=()=>{t.pausedTurnNavigated=t.navigated,t.navigated=!1},b=()=>{t.ourSendPending||(t.depth=0,t.runId+=1)},v=g=>{t.ourSendPending=!1;const m=t.navigated;t.navigated=!1,r.current.enabled&&m&&(t.depth>=r.current.maxDepth||d(g.conversationId))},I=()=>{t.ourSendPending=!1};return n.on("function:invoke",c),n.on("message:start",b),n.on("message:waiting-client",u),n.on("message:complete",v),n.on("message:error",I),()=>{t.runId+=1,p(),n.off("function:invoke",c),n.off("message:start",b),n.off("message:waiting-client",u),n.off("message:complete",v),n.off("message:error",I)}},[n])}function we(e,n){const r=E(),t=(0,s.useId)(),a=n??t,l=(0,s.useRef)(e);l.current=e;const d=typeof e=="function";(0,s.useEffect)(()=>{if(typeof l.current=="function"){const c=()=>l.current();return r.addDynamicContext(a,c),()=>{r.removeDynamicContext(a)}}return r.setContext(a,l.current),()=>{r.removeContext(a)}},[r,a,d,d?"":JSON.stringify(e)])}function U(e){return(0,s.useSyncExternalStore)(e.subscribe,e.get,e.get)}var O={missing:[],complete:!1};function Se(e){const n=E(),r=e.schema!=null,t=JSON.stringify(e.schema??null),a=e.submit,l=a?typeof a=="string"?`client:${a}`:a.via==="backend"?"backend":"handler"in a?"client:handler":`client:${a.url}`:"none",d=JSON.stringify(e.initialValues??null),c=(0,s.useMemo)(()=>r?M.createFormCollector(e):null,[r,e.name,t,l,d,e.autoSubmit]),[p,u]=(0,s.useState)({collector:null,loading:!r,error:null});(0,s.useEffect)(()=>{if(r)return;let y=!1;return u({collector:null,loading:!0,error:null}),M.loadFormCollector(n,e).then(f=>{y||u({collector:f,loading:!1,error:null})}).catch(f=>{y||u({collector:null,loading:!1,error:f instanceof Error?f:new Error(String(f))})}),()=>{y=!0}},[n,r,e.name,l,d,e.autoSubmit]);const b=r?c:p.collector,v=r?!1:p.loading,I=r?null:p.error;(0,s.useEffect)(()=>{if(b)return b.install(n)},[n,b]);const g=(0,s.useMemo)(()=>M.createStore({values:e.initialValues??{},submitted:!1}),[d]),m=U(b?.store??g),S=(0,s.useMemo)(()=>b?.getStatus()??O,[m,b]),w=(0,s.useMemo)(()=>({...m,...S}),[m,S]),i=(0,s.useMemo)(()=>({name:e.name,store:g,functions:[],contextKey:`form:${e.name}`,contextProvider:()=>({name:`Form: ${e.name}`,description:""}),install:()=>()=>{},hydrate:()=>{},submit:async()=>({ok:!1,error:"Form definition not loaded yet."}),getValues:()=>g.get().values,setValues:()=>{},reset:()=>{},getStatus:()=>O}),[e.name,g]);return{...b??i,state:w,loading:v,error:I}}exports.AgoProvider=Y;exports.ChatInput=q;exports.ChatWidget=xe;exports.Markdown=$;exports.Message=B;exports.createFormCollector=M.createFormCollector;exports.createMockClient=V.createMockClient;exports.deriveFormStatus=M.deriveFormStatus;exports.loadFormCollector=M.loadFormCollector;exports.useAgo=H;exports.useAgoAutoContinueAfterNavigation=Ce;exports.useAgoClient=E;exports.useAgoContext=we;exports.useAgoFunction=he;exports.useAgoNavigation=ye;exports.useAgoPageState=be;exports.useAgoStore=U;exports.useChat=me;exports.useConversation=G;exports.useFormCollector=Se;exports.useMessages=L;exports.useOptionalAgoClient=_;
7
+ `})]}),$=({message:e,className:t="",showAgentName:r=!1,isLast:n=!1,onFollowUpClick:a})=>{const l=e.role==="user",d=e.status==="IN_PROGRESS"||e.status==="WAITING_CLIENT";return(0,o.jsxs)("div",{className:`ago-message ago-message--${e.role} ${t}`,style:{display:"flex",flexDirection:"column",alignItems:l?"flex-end":"flex-start",marginBottom:"16px"},children:[!l&&r&&e.agent&&(0,o.jsx)("div",{className:"ago-message__agent",style:{display:"flex",alignItems:"center",gap:"6px",fontSize:"13px",fontWeight:500,color:"#30373e",marginBottom:"6px",padding:"0 4px"},children:e.agent.displayName||e.agent.name}),!l&&e.sources&&e.sources.length>0&&(0,o.jsx)("div",{className:"ago-message__sources",style:{display:"grid",gridTemplateColumns:"1fr 1fr",gap:"6px",marginBottom:"10px",width:"100%",maxWidth:"85%"},children:e.sources.map((c,g)=>(0,o.jsx)(ge,{source:c,index:g},c.id))}),e.attachments&&e.attachments.length>0&&(0,o.jsx)("div",{className:"ago-message__attachments",style:{display:"flex",flexWrap:"wrap",gap:"6px",marginBottom:"6px",justifyContent:l?"flex-end":"flex-start",maxWidth:"75%"},children:e.attachments.map(c=>(0,o.jsx)(fe,{attachment:c,isUser:l},c.id))}),(e.content||d)&&(0,o.jsx)("div",{className:"ago-message__content",style:{maxWidth:l?"75%":"100%",padding:l?"10px 14px":"2px 8px",borderRadius:l?"16px":"0",backgroundColor:l?"#03182f":"transparent",color:l?"#fff":"#30373e",wordBreak:"break-word",fontSize:"16px",lineHeight:"1.6"},children:e.content?(0,o.jsx)(O,{content:e.content}):d&&(0,o.jsx)(pe,{})}),n&&e.followUpReplies&&e.followUpReplies.length>0&&(0,o.jsx)("div",{className:"ago-message__followups",style:{display:"flex",flexWrap:"wrap",gap:"8px",marginTop:"10px"},children:e.followUpReplies.map((c,g)=>(0,o.jsx)("button",{type:"button",className:"ago-message__followup-btn",disabled:!a,onClick:a?()=>a(c):void 0,style:{minHeight:"36px",padding:"6px 14px",fontSize:"13px",borderRadius:"16px",border:"1px solid #dee3e8",backgroundColor:"#fff",color:"#30373e",cursor:a?"pointer":"default",transition:"border-color 0.15s"},onMouseEnter:f=>{f.currentTarget.style.borderColor="#1b5fc4"},onMouseLeave:f=>{f.currentTarget.style.borderColor="#dee3e8"},children:c},g))})]})},xe=({client:e,conversationId:t,title:r="Chat",welcomeMessage:n="Hello! How can I help you today?",placeholder:a="Type a message...",allowFiles:l=!1,height:d=500,logoUrl:c,showAgentName:g=!1,forms:f,onFollowUpClick:b,className:C="",onMessageSent:j,onMessageReceived:h})=>{const y=(0,s.useRef)(null),S=N(),k=e??S,{messages:i,isLoading:v,error:u,sendMessage:p}=L({client:e,conversationId:t});(0,s.useEffect)(()=>{if(!k||!f||f.length===0)return;let w=!1;const A=[];return Promise.all(f.map(E=>E.schema!=null?Promise.resolve(I.createFormCollector(E)):I.loadFormCollector(k,E))).then(E=>{if(!w)for(const U of E)A.push(U.install(k))}).catch(()=>{}),()=>{w=!0,A.forEach(E=>E())}},[k,f?JSON.stringify(f.map(w=>[w.name,w.schema??null,w.submit??!1,w.description??null])):""]),(0,s.useEffect)(()=>{y.current?.scrollIntoView({behavior:"smooth"})},[i]),(0,s.useEffect)(()=>{const w=i[i.length-1];w&&w.role==="assistant"&&w.status==="DONE"&&h&&h({id:w.id,content:w.content})},[i,h]);const m=async(w,A)=>{j?.(w),await p(w,A)},x=i[i.length-1],_=v&&x?.role==="assistant"&&(x.status==="IN_PROGRESS"||x.status==="WAITING_CLIENT"),K=b===!1?void 0:b??(w=>m(w));return(0,o.jsxs)("div",{className:`ago-chat-widget ${C}`,style:{display:"flex",flexDirection:"column",height:typeof d=="number"?`${d}px`:d,border:"1px solid #dee3e8",borderRadius:"16px",overflow:"hidden",backgroundColor:"#fff",fontFamily:'"IBM Plex Sans", -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, sans-serif',textAlign:"left",boxShadow:"rgba(15, 15, 15, 0.08) 0px 2px 16px 0px"},children:[(0,o.jsxs)("div",{className:"ago-chat-widget__header",style:{padding:"14px 16px",borderBottom:"1px solid #dee3e8",backgroundColor:"#03182f",color:"#e8f0fe",display:"flex",alignItems:"center",gap:"10px"},children:[c&&(0,o.jsx)("img",{src:c,alt:"Logo",style:{height:"24px",width:"auto"}}),(0,o.jsx)("h3",{style:{margin:0,fontSize:"15px",fontWeight:600},children:r})]}),(0,o.jsxs)("div",{className:"ago-chat-widget__messages",role:"log","aria-live":"polite","aria-relevant":"additions text","aria-atomic":!1,style:{flex:1,overflow:"auto",padding:"16px",backgroundColor:"#fbfbfb"},children:[i.length===0?(0,o.jsx)("div",{style:{textAlign:"center",color:"#6b6d6f",padding:"24px 16px",fontSize:"16px",lineHeight:"1.5"},children:n}):i.map((w,A)=>(0,o.jsx)($,{message:w,showAgentName:g,isLast:A===i.length-1,onFollowUpClick:K},w.id)),u&&(0,o.jsx)("div",{role:"alert",style:{padding:"10px 14px",backgroundColor:"#fef2f2",color:"#dc2626",borderRadius:"12px",marginTop:"8px",fontSize:"13px",border:"1px solid #fecaca"},children:u.message}),(0,o.jsx)("div",{ref:y})]}),(0,o.jsx)(H,{onSend:m,disabled:_,placeholder:a,allowFiles:l})]})};function B({client:e,autoLoad:t=!0}={}){const r=N(),n=e||r;if(!n)throw new Error("useConversation requires an AgoClient. Either pass it as options.client or wrap your app in <AgoProvider>.");const[a,l]=(0,s.useState)([]),[d,c]=(0,s.useState)(null),[g,f]=(0,s.useState)(!1),[b,C]=(0,s.useState)(null),j=(0,s.useCallback)(async()=>{f(!0),C(null);try{l(await n.getConversations())}catch(S){C(S instanceof Error?S:new Error("Failed to load conversations"))}finally{f(!1)}},[n]),h=(0,s.useCallback)(async S=>{f(!0),C(null);try{c(await n.getConversation(S))}catch(k){C(k instanceof Error?k:new Error("Failed to load conversation"))}finally{f(!1)}},[n]),y=(0,s.useCallback)(()=>{c(null)},[]);return(0,s.useEffect)(()=>{t&&j()},[t,j]),{conversations:a,currentConversation:d,isLoading:g,error:b,selectConversation:h,startNewConversation:y,refreshConversations:j}}function me(e={}){const t=N(),r=e.client||t;if(!r)throw new Error("useChat requires an AgoClient. Either pass it as options.client or wrap your app in <AgoProvider>.");const n=L({client:r,conversationId:e.conversationId}),a=B({client:r,autoLoad:e.autoLoad});return{messages:n.messages,isLoading:n.isLoading,error:n.error||a.error,sendMessage:n.sendMessage,clearMessages:n.clearMessages,conversationId:n.conversationId,conversations:a.conversations,currentConversation:a.currentConversation,isConversationsLoading:a.isLoading,selectConversation:a.selectConversation,startNewConversation:a.startNewConversation,refreshConversations:a.refreshConversations}}function he(e,t){const r=M(),{name:n,description:a,parameters:l,handler:d,maxResultBytes:c}=typeof e=="string"?{name:e,...t}:e,g=(0,s.useRef)(d);g.current=d,(0,s.useEffect)(()=>{const f=b=>g.current(b);return r.registerFunction(n,f,{description:a,parameters:l,maxResultBytes:c}),()=>{r.unregisterFunction(n)}},[r,n,a,l,c])}function ye(e,t){const r=M(),n=(0,s.useRef)(e);n.current=e,(0,s.useEffect)(()=>(r.registerNavigationFunction(a=>n.current(a),t),()=>{r.unregisterNavigationFunction()}),[r,t])}function be(e,t){const r=M(),n=t?.functionName??"setPageState",a=(0,s.useRef)(e);a.current=e,(0,s.useEffect)(()=>{const l=a.current.map(d=>{const c=()=>a.current.find(g=>g.name===d.name)??d;return{name:d.name,description:d.description,schema:d.schema,get:d.get?()=>c().get?.():void 0,set:g=>c().set(g)}});return r.registerPageStateFunction(l,{functionName:n}),()=>{r.unregisterPageStateFunction(n)}},[r,n])}function ve(e){const t=M(),r=(0,s.useRef)(e);r.current=e,(0,s.useEffect)(()=>J.attachAutoContinueAfterNavigation(t,()=>r.current),[t])}function Ce(e,t){const r=M(),n=(0,s.useId)(),a=t??n,l=(0,s.useRef)(e);l.current=e;const d=typeof e=="function";(0,s.useEffect)(()=>{if(typeof l.current=="function"){const c=()=>l.current();return r.addDynamicContext(a,c),()=>{r.removeDynamicContext(a)}}return r.setContext(a,l.current),()=>{r.removeContext(a)}},[r,a,d,d?"":JSON.stringify(e)])}function G(e){return(0,s.useSyncExternalStore)(e.subscribe,e.get,e.get)}var D={missing:[],complete:!1};function we(e){const t=M(),r=e.schema!=null,n=JSON.stringify(e.schema??null),a=e.submit,l=a?typeof a=="string"?`client:${a}`:a.via==="backend"?"backend":"handler"in a?"client:handler":`client:${a.url}`:"none",d=JSON.stringify(e.initialValues??null),c=(0,s.useMemo)(()=>r?I.createFormCollector(e):null,[r,e.name,n,l,d,e.autoSubmit]),[g,f]=(0,s.useState)({collector:null,loading:!r,error:null});(0,s.useEffect)(()=>{if(r)return;let v=!1;return f({collector:null,loading:!0,error:null}),I.loadFormCollector(t,e).then(u=>{v||f({collector:u,loading:!1,error:null})}).catch(u=>{v||f({collector:null,loading:!1,error:u instanceof Error?u:new Error(String(u))})}),()=>{v=!0}},[t,r,e.name,l,d,e.autoSubmit]);const b=r?c:g.collector,C=r?!1:g.loading,j=r?null:g.error;(0,s.useEffect)(()=>{if(b)return b.install(t)},[t,b]);const h=(0,s.useMemo)(()=>I.createStore({values:e.initialValues??{},submitted:!1}),[d]),y=G(b?.store??h),S=(0,s.useMemo)(()=>b?.getStatus()??D,[y,b]),k=(0,s.useMemo)(()=>({...y,...S}),[y,S]),i=(0,s.useMemo)(()=>({name:e.name,store:h,functions:[],contextKey:`form:${e.name}`,contextProvider:()=>({name:`Form: ${e.name}`,description:""}),install:()=>()=>{},hydrate:()=>{},submit:async()=>({ok:!1,error:"Form definition not loaded yet."}),getValues:()=>h.get().values,setValues:()=>{},reset:()=>{},getStatus:()=>D}),[e.name,h]);return{...b??i,state:k,loading:C,error:j}}exports.AgoProvider=Y;exports.ChatInput=H;exports.ChatWidget=xe;exports.Markdown=O;exports.Message=$;exports.createFormCollector=I.createFormCollector;exports.createMockClient=V.createMockClient;exports.deriveFormStatus=I.deriveFormStatus;exports.loadFormCollector=I.loadFormCollector;exports.useAgo=q;exports.useAgoAutoContinueAfterNavigation=ve;exports.useAgoClient=M;exports.useAgoContext=Ce;exports.useAgoFunction=he;exports.useAgoNavigation=ye;exports.useAgoPageState=be;exports.useAgoStore=G;exports.useChat=me;exports.useConversation=B;exports.useFormCollector=we;exports.useMessages=L;exports.useOptionalAgoClient=N;
package/dist/react.d.cts CHANGED
@@ -495,11 +495,11 @@ export declare interface AgoConfig {
495
495
  warnOnEmptyReply?: boolean;
496
496
  /**
497
497
  * How the agent loop treats client function calls (requires backend support):
498
- * - `"placeholder"` (default): the turn continues immediately on a placeholder
499
- * result; the real result is only visible to the agent on later turns.
500
- * - `"pause"`: the turn stops on client function call(s) with status
498
+ * - `"pause"` (default): the turn stops on client function call(s) with status
501
499
  * `WAITING_CLIENT`; once every result is submitted, the SDK resumes the SAME
502
500
  * turn via `POST /messages/{id}/continue`, so the agent sees the real results.
501
+ * - `"placeholder"` (legacy): the turn continues immediately on a placeholder
502
+ * result; the real result is only visible to the agent on later turns.
503
503
  * Older backends ignore the flag, so `"pause"` degrades to legacy behavior.
504
504
  */
505
505
  clientFunctionsMode?: ClientFunctionsMode;
@@ -1311,20 +1311,8 @@ export declare function useAgo(config: UseAgoOptions | null): {
1311
1311
  * Auto-continue the agent after it navigates, so a "go to page B and change X"
1312
1312
  * request completes in one user gesture. Mount this once inside `AgoProvider`.
1313
1313
  *
1314
- * Two mechanisms, picked by the turn's client-functions mode:
1315
- *
1316
- * - **Pause mode** (`clientFunctionsMode: "pause"`): the backend pauses the turn
1317
- * on the navigation call (`message:waiting-client`) and the SDK resumes it once
1318
- * the result is submitted. This hook only registers a *resume gate* that delays
1319
- * the resume until the destination page's `useAgoPageState` registered (plus a
1320
- * settle delay), so the continued turn ships the new page's `setPageState` and
1321
- * current state. Same turn, no extra prompt, backend budget as the guardrail —
1322
- * `continuationPrompt` and `maxDepth` are unused here.
1323
- *
1324
- * - **Placeholder mode** (legacy default): when the agent calls the navigation
1325
- * function and that turn ends, this waits for the destination page's state to
1326
- * register, then sends a hidden continuation message; the agent applies the
1327
- * state in a second turn (requires backend support for the `hidden` flag).
1314
+ * React binding of {@link attachAutoContinueAfterNavigation} — see it for the
1315
+ * pause-mode / placeholder-mode mechanics.
1328
1316
  *
1329
1317
  * ```tsx
1330
1318
  * function AppShell() {
package/dist/react.d.ts CHANGED
@@ -495,11 +495,11 @@ export declare interface AgoConfig {
495
495
  warnOnEmptyReply?: boolean;
496
496
  /**
497
497
  * How the agent loop treats client function calls (requires backend support):
498
- * - `"placeholder"` (default): the turn continues immediately on a placeholder
499
- * result; the real result is only visible to the agent on later turns.
500
- * - `"pause"`: the turn stops on client function call(s) with status
498
+ * - `"pause"` (default): the turn stops on client function call(s) with status
501
499
  * `WAITING_CLIENT`; once every result is submitted, the SDK resumes the SAME
502
500
  * turn via `POST /messages/{id}/continue`, so the agent sees the real results.
501
+ * - `"placeholder"` (legacy): the turn continues immediately on a placeholder
502
+ * result; the real result is only visible to the agent on later turns.
503
503
  * Older backends ignore the flag, so `"pause"` degrades to legacy behavior.
504
504
  */
505
505
  clientFunctionsMode?: ClientFunctionsMode;
@@ -1311,20 +1311,8 @@ export declare function useAgo(config: UseAgoOptions | null): {
1311
1311
  * Auto-continue the agent after it navigates, so a "go to page B and change X"
1312
1312
  * request completes in one user gesture. Mount this once inside `AgoProvider`.
1313
1313
  *
1314
- * Two mechanisms, picked by the turn's client-functions mode:
1315
- *
1316
- * - **Pause mode** (`clientFunctionsMode: "pause"`): the backend pauses the turn
1317
- * on the navigation call (`message:waiting-client`) and the SDK resumes it once
1318
- * the result is submitted. This hook only registers a *resume gate* that delays
1319
- * the resume until the destination page's `useAgoPageState` registered (plus a
1320
- * settle delay), so the continued turn ships the new page's `setPageState` and
1321
- * current state. Same turn, no extra prompt, backend budget as the guardrail —
1322
- * `continuationPrompt` and `maxDepth` are unused here.
1323
- *
1324
- * - **Placeholder mode** (legacy default): when the agent calls the navigation
1325
- * function and that turn ends, this waits for the destination page's state to
1326
- * register, then sends a hidden continuation message; the agent applies the
1327
- * state in a second turn (requires backend support for the `hidden` flag).
1314
+ * React binding of {@link attachAutoContinueAfterNavigation} — see it for the
1315
+ * pause-mode / placeholder-mode mechanics.
1328
1316
  *
1329
1317
  * ```tsx
1330
1318
  * function AppShell() {