@heroui/agent 1.0.0-beta.5 → 1.0.0-beta.7

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/CHANGELOG.md CHANGED
@@ -2,6 +2,25 @@
2
2
 
3
3
  ## Unreleased
4
4
 
5
+ - Move the model catalog, attachment limits and MIME allowlist, and design theme
6
+ list out of the published package and into the hosted runtime. Adding a model,
7
+ attachment type, or theme variant no longer requires a customer npm release.
8
+ Removed exports: `AGENT_MODEL_IDS`, `AGENT_MODEL_OPTIONS`,
9
+ `DEFAULT_AGENT_PICKER_MODEL_ID`, `LEGACY_AGENT_MODEL_IDS`,
10
+ `resolveAgentModelId`, `isAgentModelId`, `getAgentModelTier`,
11
+ `AgentModelOption`, `AgentModelTier`, `AGENT_DESIGN_THEMES`, every
12
+ `HEROUI_AGENT_*ATTACHMENT*` constant, `isHeroUIAgentAttachmentContentType`,
13
+ `resolveHeroUIAgentAttachmentContentType`, and
14
+ `HeroUIAgentAttachmentContentType`.
15
+ - Type `composer.defaultModel` (`AgentModelId`), `composer.attachments`
16
+ (`AgentAttachmentContentType`), and `theme.designTheme` (`AgentDesignTheme`)
17
+ as plain strings. The hosted runtime validates them: retired model ids resolve
18
+ to their replacement, unknown model ids fall back to the hosted default,
19
+ unsupported attachment types are dropped, and unknown design themes render
20
+ `base`.
21
+ - Accept client tool results and page context whose optional fields are
22
+ `undefined`. The bridge previously rejected them as not JSON-serializable
23
+ even though `JSON.stringify` drops them; it now forwards the canonical JSON.
5
24
  - Move the visible Agent UI into a cross-origin iframe hosted by HeroUI. This is
6
25
  the one-time host-bridge upgrade; UI, renderer, chart, PDF/XLSX, and backend
7
26
  changes no longer require another customer npm release.
package/README.md CHANGED
@@ -31,6 +31,7 @@ export function AppAgent() {
31
31
  getAuthToken={async (context) => {
32
32
  const response = await fetch("/api/heroui-agent/auth-token", {
33
33
  method: "POST",
34
+ signal: context.signal,
34
35
  headers: {"Content-Type": "application/json"},
35
36
  body: JSON.stringify(context),
36
37
  });
@@ -58,6 +59,7 @@ export function AppAgent() {
58
59
  getAuthToken={async (context) => {
59
60
  const response = await fetch("/api/heroui-agent/auth-token", {
60
61
  method: "POST",
62
+ signal: context.signal,
61
63
  headers: {"Content-Type": "application/json"},
62
64
  body: JSON.stringify(context),
63
65
  });
@@ -264,3 +266,21 @@ MIT — see [LICENSE](LICENSE).
264
266
  ---
265
267
 
266
268
  Built by [HeroUI](https://www.heroui.com)
269
+
270
+ ## Status, recovery, and cancellation
271
+
272
+ Use `onStatusChange(status)` to observe startup, connection, generation, finishing, and recovery.
273
+ `onError(error)` receives a safe `message`, `category`, `phase`, `retryable`, and `diagnosticId`.
274
+ Use the diagnostic ID to correlate failures; keep prompts, form values, files, credentials, and tool
275
+ outputs out of telemetry. The hosted panel supplies recovery actions and preserves conversation drafts.
276
+
277
+ Pass `context.signal` from `getAuthToken` into your authentication fetch. Authentication expires
278
+ after 15 seconds and superseded attempts are cancelled. Client tools receive
279
+ `execution.signal` as their third argument; pass it into cancellable requests and use
280
+ `execution.idempotencyKey` for server mutations. Cancellation after dispatch can leave an unknown
281
+ outcome, so the runtime preserves a receipt and does not automatically repeat the effect.
282
+
283
+ Generated forms submit their validated values as a queued user message without changing the composer
284
+ draft. “Submitted to agent” confirms queue acceptance; action completion is reported separately.
285
+ The selected conversation stays connected while visible. Settled inactive conversations disconnect
286
+ after a grace period; closing the panel leaves active work running.
@@ -0,0 +1 @@
1
+ import{b as G}from"./chunk-MPJ6AAXH.js";import{c as K,e as J,f as V,i as X,j as Y,k as Q}from"./chunk-YPHOJDYK.js";function pe(e,t){return e.throwIfAborted(),new Promise((n,r)=>{let l=()=>r(e.reason);e.addEventListener("abort",l,{once:!0});try{t().then(n,r).finally(()=>e.removeEventListener("abort",l))}catch(c){e.removeEventListener("abort",l),r(c)}})}async function _(e,t,n){let r=new AbortController,l=setTimeout(()=>r.abort(new DOMException("Request timed out","TimeoutError")),e),c=n?AbortSignal.any([n,r.signal]):r.signal;try{return await pe(c,()=>t(c))}finally{clearTimeout(l)}}var ge={approval:"This approval has expired. Ask the agent to request it again.",authentication:"Could not authenticate. Sign in if needed, then retry.",chunk:"Could not load the conversation. Retry, or reload the panel.",configuration:"Could not load the agent configuration. Try again.",connection:"Connection interrupted. Check your connection and retry.",credits:"This agent has reached its usage limit.",deleted:"This conversation was deleted. Start a new conversation.",rate_limit:"Too many requests. Wait a moment before retrying.",unknown:"The request could not be completed. Try again."};function Z(e,t="connecting"){let n=e&&typeof e=="object"?e:{},r=[e instanceof Error?e.message:"",n.code,n.status].filter(c=>typeof c=="string"||typeof c=="number").join(" ").toLowerCase(),l=t==="authenticating"||/auth|401|sign.in/.test(r)?"authentication":/429|rate.limit/.test(r)?"rate_limit":/credit|usage.limit|usage_limit|402/.test(r)?"credits":/deleted|conversation_not_found/.test(r)?"deleted":/approval.*expir/.test(r)?"approval":/dynamic.*import|chunk|module.*fetch/.test(r)?"chunk":/config/.test(r)?"configuration":/network|fetch|connect|timeout|timed out/.test(r)?"connection":"unknown";return{category:l,diagnosticId:crypto.randomUUID(),message:ge[l],phase:t,retryable:!["credits","deleted","approval"].includes(l)}}var fe=5e3;function ee(e){return`heroui-agent:anonymous:${e}`}function he(e){return e instanceof Error?e:new Error("Auth token request failed")}var P=class{constructor(t,n){this.agentId=t;this.getAuthToken=n}cached=null;failure=null;generation=0;pending=null;controller=new AbortController;clear(){this.controller.abort(),this.controller=new AbortController,this.generation+=1,this.cached=null,this.failure=null,this.pending=null}reset(){this.clear();try{localStorage.removeItem(ee(this.agentId))}catch{}}async get(){if(this.cached&&this.expiresAt(this.cached)>Date.now()+6e4)return this.cached.token;if(!this.pending&&this.failure&&Date.now()<this.failure.retryAt)throw this.failure.error;let t=this.generation,n=this.pending??this.refresh();this.pending||(this.pending=n);try{let r=await n;return t!==this.generation?this.get():(this.cached=r,this.failure=null,r.token)}catch(r){throw t===this.generation&&(this.failure={error:he(r),retryAt:Date.now()+fe}),r}finally{this.pending===n&&(this.pending=null)}}async subjectHash(){let t=await this.get(),n=me(t),r=typeof n.sub=="string"?n.sub:"anonymous",l=await crypto.subtle.digest("SHA-256",new TextEncoder().encode(`${this.agentId}:${r}`));return Array.from(new Uint8Array(l),c=>c.toString(16).padStart(2,"0")).join("").slice(0,24)}anonymousId(){let t=ee(this.agentId);try{let n=localStorage.getItem(t);if(n)return n;let r=crypto.randomUUID();return localStorage.setItem(t,r),r}catch{return crypto.randomUUID()}}expiresAt(t){return t.expiresAt}async refresh(){let t=await _(15e3,n=>this.getAuthToken({agentId:this.agentId,anonymousId:this.anonymousId(),signal:n}),this.controller.signal);if(!t||typeof t.token!="string"||!t.token.trim()||typeof t.expiresAt!="number"||!Number.isFinite(t.expiresAt)||t.expiresAt<=0)throw new Error("Auth token callback returned invalid data");return{expiresAt:t.expiresAt,token:t.token}}};function me(e){try{let t=e.split(".")[1];if(!t)return{};let n=t.replace(/-/g,"+").replace(/_/g,"/"),r=n.padEnd(Math.ceil(n.length/4)*4,"=");return JSON.parse(atob(r))}catch{return{}}}function te(e){return{bounds:null,closing:!1,dragging:!1,expanded:e.appearance?.panel?.expanded??!1,mounted:!1,open:!1,overlayOpen:!1,ready:!1,resizing:!1,sidebarWidth:null,viewMode:e.appearance?.viewMode??"floating"}}function w(e,t,n){return{background:"transparent",border:"0",clipPath:ye(e,t,n),colorScheme:"normal",height:"100dvh",inset:"0",position:"fixed",width:"100vw",zIndex:t.appearance?.zIndex??40}}function ne(e){if(!e||typeof e!="object")return null;let t=e;return typeof t.open!="boolean"||typeof t.ready!="boolean"||typeof t.expanded!="boolean"||t.viewMode!=="floating"&&t.viewMode!=="sidebar"?null:{bounds:we(t.bounds),closing:t.closing===!0,dragging:t.dragging===!0,expanded:t.expanded,mounted:t.mounted!==!1,open:t.open,overlayOpen:t.overlayOpen===!0,ready:t.ready,resizing:t.resizing===!0,sidebarWidth:L(t.sidebarWidth)?t.sidebarWidth:null,viewMode:t.viewMode}}function oe(){let e=document.documentElement,t=document.body;return{active:!1,body:t,original:{bodyLeft:t.style.left,bodyOverflow:t.style.overflow,bodyPosition:t.style.position,bodyRight:t.style.right,bodyTop:t.style.top,bodyWidth:t.style.width,rootMarginRight:e.style.marginRight,rootOverflow:e.style.overflow,rootTransition:e.style.transition},root:e,scrollLock:null}}function I(e,t,n,r){let l=t.open||t.closing;if(!l&&!e.active)return;l&&(e.active=!0);let c=l&&(r||t.viewMode==="sidebar"&&t.expanded);ie(e,c);let a=l&&t.viewMode==="sidebar"&&!t.expanded&&!r?be(t,n):e.original.rootMarginRight;e.root.style.transition=e.original.rootTransition,e.root.style.marginRight=a,l||(e.active=!1)}function re(e){ie(e,!1),e.root.style.marginRight=e.original.rootMarginRight,e.root.style.transition=e.original.rootTransition,e.active=!1}function ye(e,t,n){let r=e.open||e.closing;if(r&&(n||e.overlayOpen))return"inset(0px)";if(e.bounds)return`inset(${e.bounds.top}px calc(100% - ${e.bounds.right}px) calc(100% - ${e.bounds.bottom}px) ${e.bounds.left}px)`;let l=t.appearance?.launcher,c=l?.position==="bottom-left",g=(l?.offset?.x??24)+60,a=(l?.offset?.y??24)+60;if(!r)return c?`inset(calc(100% - ${a}px) calc(100% - ${g}px) 0px 0px)`:`inset(calc(100% - ${a}px) 0px 0px calc(100% - ${g}px))`;if(e.viewMode==="sidebar")return`inset(0px 0px 0px calc(100% - (${F(t.appearance?.panel?.initialWidth??420)} + 16px)))`;let h=F(t.appearance?.panel?.initialWidth??440),v=`calc(100% - min(calc(${F(t.appearance?.panel?.initialHeight??"max(420px, 56dvh)")} + 32px), 100dvh))`;return c?`inset(${v} calc(100% - min(calc(${h} + 32px), 100vw)) 0px 0px)`:`inset(${v} 0px 0px calc(100% - min(calc(${h} + 32px), 100vw)))`}function we(e){if(!e||typeof e!="object")return null;let t=e;return!L(t.top)||!L(t.right)||!L(t.bottom)||!L(t.left)||t.right<t.left||t.bottom<t.top?null:{bottom:t.bottom,left:t.left,right:t.right,top:t.top}}function L(e){return typeof e=="number"&&Number.isFinite(e)&&e>=0&&e<=1e5}function be(e,t){return e.sidebarWidth===null?F(t.appearance?.panel?.initialWidth??420):`${Math.round(e.sidebarWidth)}px`}function F(e){return typeof e=="number"?`${Math.round(e)}px`:e}function ie(e,t){if(t&&!e.scrollLock){e.scrollLock={x:window.scrollX,y:window.scrollY},e.root.style.overflow="hidden",e.body.style.overflow="hidden",e.body.style.position="fixed",e.body.style.top=`${-e.scrollLock.y}px`,e.body.style.left=`${-e.scrollLock.x}px`,e.body.style.right="0",e.body.style.width="100%";return}if(!t&&e.scrollLock){let{x:n,y:r}=e.scrollLock;e.root.style.overflow=e.original.rootOverflow,e.body.style.overflow=e.original.bodyOverflow,e.body.style.position=e.original.bodyPosition,e.body.style.top=e.original.bodyTop,e.body.style.left=e.original.bodyLeft,e.body.style.right=e.original.bodyRight,e.body.style.width=e.original.bodyWidth,e.scrollLock=null;try{window.scrollTo(n,r)}catch{}}}var ve=16*1024,Ae=64*1024;function De(e,t){let n=e;if(!n?.agentId||typeof n.getAuthToken!="function")throw new Error("HeroUIAgent.mount requires agentId and getAuthToken");let r=crypto.randomUUID(),l=crypto.randomUUID(),c=(n._api?.baseUrl??G).replace(/\/$/,""),g=He(c,n._api?.embedOrigin),a=document.createElement("iframe"),h=new Map,y=[],v=new Set,A=new Map,k=new Set,T=oe(),C=new P(n.agentId,n.getAuthToken),s=te(n),O=null,m=!1,b=!1,x=null,W=!1,$=!1,B=new URL("/embed",g);B.searchParams.set("agentId",n.agentId),B.hash=new URLSearchParams({nonce:l,parentOrigin:window.location.origin,sessionId:r}).toString(),a.allow="microphone; clipboard-write",a.referrerPolicy="origin",a.setAttribute("sandbox","allow-downloads allow-forms allow-popups allow-popups-to-escape-sandbox allow-same-origin allow-scripts"),a.src=B.toString(),a.title="HeroUI Agent",Object.assign(a.style,w(s,n,window.innerWidth<640)),document.body.append(a);let f=(o,i,d)=>{$||a.contentWindow?.postMessage(X(r,l,o,i,d),g)},le=(o,i)=>{let d=crypto.randomUUID();return new Promise((u,p)=>{let H=window.setTimeout(()=>{h.delete(d),p(new Error(`HeroUI Agent iframe request timed out: ${o}`))},3e4);h.set(d,{reject:p,resolve:u,timer:H}),f(o,i,d)})},S=new Map,D=0,q="",N=async(o,i=!1)=>{let d=++D,u=await xe(n,t);if($||d!==D)return;let p=JSON.stringify({props:u.props,tools:u.tools});!i&&p===q||(q=p,f(o,{...u,restoreSession:o==="host.init"&&b}))},E=(o,i)=>{if(!s.mounted){y.push({name:o,payload:i}),y.length>32&&y.shift();return}f("host.command",{name:o,payload:i})},M=o=>{o&&!m&&document.activeElement!==a&&(O=document.activeElement),m=o,o||(b=!1),E(o?"show":"hide")},de=()=>{if(s.mounted)for(let o of y.splice(0))f("host.command",o)},ce=()=>{b=s.mounted&&m&&!s.closing,s={...s,bounds:null,closing:!1,mounted:!1,open:b,ready:!1},W=!1;for(let o of k)o();Object.assign(a.style,w(s,n,window.innerWidth<640)),I(T,s,n,window.innerWidth<640)},z=o=>{if(o.origin!==g||o.source!==a.contentWindow)return;let i=Y(o.data);if(!(!i||i.sessionId!==r||i.nonce!==l)){if(i.type==="iframe.rpc-result"||i.type==="iframe.rpc-error"){Ie(i,h);return}Ee(v,i.requestId)&&ue(i)}},ue=async o=>{try{if(o.type==="iframe.ready"){(s.mounted||s.ready)&&ce(),await N("host.init",!0);return}if(o.type==="iframe.reload"){let i=a.cloneNode(!1),d=new URL(a.src);d.pathname=`/reload/${crypto.randomUUID()}/embed`,i.src=d.href,a.replaceWith(i),a=i;return}if(o.type==="iframe.state"){let i=ne(o.payload);if(i){let d=s.open||s.closing,u=i;b?i.mounted?(b=!1,i.open||(f("host.command",{name:"show"}),u={...i,bounds:null,closing:!1,open:!0,sidebarWidth:i.sidebarWidth??s.sidebarWidth})):u={...i,bounds:null,closing:!1,open:!0,sidebarWidth:i.sidebarWidth??s.sidebarWidth}:i.open?m=!0:(i.closing||s.open||s.closing)&&(m=!1);let p=u.open||u.closing;if(p&&!d&&document.activeElement!==a&&(O=document.activeElement),!p&&d&&O?.isConnected){let H=O;window.requestAnimationFrame(()=>window.requestAnimationFrame(()=>H.focus({preventScroll:!0})))}s=u,p&&s.expanded?a.dataset.expanded="true":a.removeAttribute("data-expanded");for(let H of k)H();Object.assign(a.style,w(s,n,window.innerWidth<640)),I(T,s,n,window.innerWidth<640),de(),s.ready&&!W&&(W=!0,n.onReady?.())}return}if(o.type==="iframe.error"){n.onError?.(o.payload);return}if(o.type==="iframe.status"){n.onStatusChange?.(o.payload);return}if(o.type==="iframe.tool-cancel"){let i=o.payload;i.idempotencyKey&&S.get(i.idempotencyKey)?.abort();return}if(o.type==="iframe.auth-request"){let i=await C.get(),d=await _(15e3,u=>fetch(`${c}/v1/agents/${encodeURIComponent(n.agentId)}/embed-sessions`,{body:JSON.stringify({iframeOrigin:g,sessionId:r}),cache:"no-store",headers:{Authorization:`Bearer ${i}`,"Content-Type":"application/json"},method:"POST",signal:u}));if(!d.ok)throw new Error("Could not authenticate HeroUI Agent");f("host.rpc-result",{value:await d.json()},o.requestId);return}if(o.type==="iframe.context-request"){let i=ae(await n.context?.page?.()??{},ve,"Agent page context");f("host.rpc-result",{value:i},o.requestId);return}if(o.type==="iframe.tool-execute"){let i=ke(o.payload),d=n.tools?.find(p=>p.name===i.name);if(!d)throw new Error(`Unknown client tool: ${i.name}`);let u=A.get(i.idempotencyKey);if(!u){let p=new AbortController;S.set(i.idempotencyKey,p),u=Te(d,i,n,le,p.signal).finally(()=>S.delete(i.idempotencyKey)),A.set(i.idempotencyKey,u),A.size>2048&&A.delete(A.keys().next().value)}f("host.rpc-result",{value:await u},o.requestId);return}if(o.type==="iframe.feedback"){await n.onFeedback?.(o.payload);return}if(o.type==="iframe.storage"){Se(o.payload);return}if(o.type==="iframe.persistence"){let i=await import("./persistence-YI6JSYCT.js").then(({executeAgentHostPersistence:d})=>d(n.agentId,o.payload));f("host.rpc-result",{value:i},o.requestId)}}catch(i){let d=Z(i,o.type==="iframe.auth-request"?"authenticating":"failed");n.onError?.(d),f("host.rpc-error",{error:d.message},o.requestId)}},j=o=>{o.composedPath().includes(a)||s.open&&s.viewMode==="floating"&&(n.appearance?.shouldCloseOnInteractOutside??!0)&&M(!1)},R=()=>{s={...s,bounds:null},Object.assign(a.style,w(s,n,window.innerWidth<640)),I(T,s,n,window.innerWidth<640)},U=()=>{document.visibilityState==="visible"&&(s={...s,bounds:null},Object.assign(a.style,w(s,n,window.innerWidth<640)),I(T,s,n,window.innerWidth<640),m&&s.mounted&&f("host.command",{name:"show"}),x!==null&&window.cancelAnimationFrame(x),x=window.requestAnimationFrame(()=>{x=null,Object.assign(a.style,w(s,n,window.innerWidth<640))}))};return window.addEventListener("message",z),window.addEventListener("pointerdown",j,!0),window.addEventListener("resize",R),window.addEventListener("pageshow",U),window.visualViewport?.addEventListener("resize",R),document.addEventListener("visibilitychange",U),{destroy:()=>{$=!0;for(let o of S.values())o.abort();S.clear(),window.removeEventListener("message",z),window.removeEventListener("pointerdown",j,!0),window.removeEventListener("resize",R),window.removeEventListener("pageshow",U),window.visualViewport?.removeEventListener("resize",R),document.removeEventListener("visibilitychange",U),x!==null&&window.cancelAnimationFrame(x);for(let o of h.values())window.clearTimeout(o.timer),o.reject(new Error("HeroUI Agent iframe was removed"));h.clear(),y.length=0,k.clear(),re(T),a.remove()},hide:()=>M(!1),newConversation:o=>{m=!0,E("newConversation",{prompt:o})},preload:()=>E("preload"),get ready(){return s.ready},refreshAuth:()=>{C.clear(),E("refreshAuth")},show:()=>M(!0),shutdown:()=>{m=!1,b=!1,C.reset(),E("shutdown")},subscribe:o=>(k.add(o),()=>k.delete(o)),toggle:()=>M(!m),update:o=>{if(o.agentId!==n.agentId)throw new Error("HeroUI Agent agentId cannot change without remounting");o.getAuthToken!==n.getAuthToken&&(C=new P(o.agentId,o.getAuthToken)),n=o,Object.assign(a.style,w(s,n,window.innerWidth<640)),I(T,s,n,window.innerWidth<640),s.ready&&N("host.update")}}}async function Te(e,t,n,r,l){let c={conversationId:t.conversationId,idempotencyKey:t.idempotencyKey,signal:l,toolCallId:t.toolCallId,uploadDataSource:async a=>await r("host.upload-data-source",{toolCallId:t.toolCallId,upload:a})},g=await e.execute(K(e,t.args),n.context??{},c)??null;return ae(g,Ae,`Client tool ${e.name} result`)}async function xe(e,t){let{context:n,getAuthToken:r,onError:l,onFeedback:c,onReady:g,onStatusChange:a,tools:h,...y}=e,v=await t(h??[]);return{localStorage:se(window.localStorage),props:JSON.parse(JSON.stringify(y)),sessionStorage:se(window.sessionStorage),tools:v}}function Ie(e,t){let n=t.get(e.requestId);if(n)if(t.delete(e.requestId),window.clearTimeout(n.timer),e.type==="iframe.rpc-error"){let r=e.payload;n.reject(new Error(typeof r?.error=="string"?r.error:"Iframe request failed"))}else{let r=e.payload;n.resolve(r?.value)}}function ke(e){if(!e||typeof e!="object")throw new Error("Invalid client tool request");let t=e;if(typeof t.conversationId!="string"||typeof t.idempotencyKey!="string"||typeof t.name!="string"||typeof t.toolCallId!="string")throw new Error("Invalid client tool request");return t}function ae(e,t,n){if(!Q(e))throw new Error(`${n} must be JSON-serializable`);let r=JSON.stringify(e);if(new TextEncoder().encode(r).byteLength>t)throw new Error(`${n} exceeds ${Math.round(t/1024)} KiB`);return JSON.parse(r)}function se(e){let t={};try{for(let n=0;n<e.length;n+=1){let r=e.key(n);r?.startsWith("heroui-agent:")&&(t[r]=e.getItem(r)??"")}}catch{}return t}function Se(e){if(!e||typeof e!="object")return;let t=e;if(typeof t.key=="string"&&!t.key.startsWith("heroui-agent:"))return;let n=t.storage==="session"?sessionStorage:localStorage;try{if(t.operation==="set"&&typeof t.key=="string"&&typeof t.value=="string")n.setItem(t.key,t.value);else if(t.operation==="remove"&&typeof t.key=="string")n.removeItem(t.key);else if(t.operation==="clear")for(let r=n.length-1;r>=0;r-=1){let l=n.key(r);l?.startsWith("heroui-agent:")&&n.removeItem(l)}}catch{}}function Ee(e,t){return e.has(t)?!1:(e.add(t),e.size>2048&&e.delete(e.values().next().value),!0)}function He(e,t){if(t){let n=new URL(t);if(n.protocol!=="http:"&&n.protocol!=="https:")throw new Error("HeroUI Agent embed origin must use HTTP or HTTPS");return n.origin}return/^https?:\/\/(?:localhost|127\.0\.0\.1)(?::\d+)?$/i.test(e)?"http://localhost:8793":e.includes("staging")?V:J}export{pe as a,_ as b,Z as c,P as d,De as e};
@@ -0,0 +1 @@
1
+ var e={animation:"fadeIn",duration:160,easing:"ease-out",sep:"word",stagger:18};export{e as a};
@@ -0,0 +1 @@
1
+ import{b as i,k as a}from"./chunk-YPHOJDYK.js";import{z as t}from"zod";var c=["readConversationHistory","callMcpTool","composeUI","executeSandbox","generateFile","getComponentSchema","renderComponent","searchKnowledge","searchMcpTools","searchWeb"],m="mcp_",p=20,l=16*1024,d=t.object({description:t.string().trim().min(1).max(1e3),inputSchema:t.record(t.string(),t.unknown()),name:t.string().regex(/^[a-zA-Z][a-zA-Z0-9_-]{0,63}$/).refine(e=>!c.includes(e)&&!e.toLowerCase().startsWith(m),"Client tool name is reserved by the HeroUI Agent runtime"),needsApproval:t.boolean().optional()}),f=t.array(d).max(p).superRefine((e,n)=>{let o=new Set;for(let r of e)o.has(r.name)&&n.addIssue({code:"custom",message:`Duplicate client tool name: ${r.name}`}),o.add(r.name);new TextEncoder().encode(JSON.stringify(e)).byteLength>l&&n.addIssue({code:"custom",message:"Client tool manifest exceeds 16KB"})});function u(e){let n=i(e.parameters)?t.toJSONSchema(e.parameters):e.parameters;if(!a(n))throw new Error(`Client tool ${e.name} parameters must be a JSON-serializable schema`);return s(n)}function s(e){return Array.isArray(e)?e.map(s):e&&typeof e=="object"?Object.fromEntries(Object.entries(e).map(([n,o])=>[n,s(o)])):e}function y(e){return f.parse(e.map(n=>({description:n.description,inputSchema:u(n),name:n.name,...n.needsApproval?{needsApproval:!0}:{}})))}export{c as a,m as b,p as c,l as d,d as e,f,y as g};
@@ -0,0 +1 @@
1
+ var t="1.0.0-beta.7",o="https://api.heroui.pro";export{t as a,o as b};
@@ -0,0 +1 @@
1
+ import{e as S}from"./chunk-7NL3SCZA.js";import{b as d}from"./chunk-YPHOJDYK.js";import{useEffect as k,useLayoutEffect as p,useMemo as x,useRef as m,useState as O,useSyncExternalStore as w}from"react";var i=new Map,h=new Set;function f(){for(let e of h)e()}function H(e){return h.add(e),()=>h.delete(e)}function a(e,n,r){let o=e?i.get(e):[...i.values()][i.size-1];if(!o){console.warn("HeroUI Agent is not mounted yet. Add <HeroUIAgent /> to your layout.");return}n==="newConversation"?o.newConversation(r):o[n]()}function R(e){let n=w(H,()=>(e?i.get(e):[...i.values()].at(-1))?.ready??!1,()=>!1);return x(()=>({hide:()=>a(e,"hide"),newConversation:r=>a(e,"newConversation",r),preload:()=>a(e,"preload"),ready:n,refreshAuth:()=>a(e,"refreshAuth"),show:()=>a(e,"show"),shutdown:()=>a(e,"shutdown"),toggle:()=>a(e,"toggle")}),[e,n])}async function E(e){let{serializeClientTools:n}=await import("./client-tools-manifest-3LJBKDBZ.js");return n(e).map(o=>{let s=e.find(l=>l.name===o.name);return{...o,...s?.displayName?{displayName:s.displayName}:{},...s?.icon?{icon:s.icon}:{},...s?.iconColor?{iconColor:s.iconColor}:{}}})}function P(e){let n=m(e),r=m(null),o=m(null);p(()=>{n.current=e}),o.current||(o.current={getAuthToken:t=>n.current.getAuthToken(t),onError:t=>n.current.onError?.(t),onFeedback:t=>n.current.onFeedback?.(t),onReady:()=>n.current.onReady?.(),onStatusChange:t=>n.current.onStatusChange?.(t)},Object.defineProperties(o.current,{context:{enumerable:!0,get(){return n.current.context}},tools:{enumerable:!0,get(){return n.current.tools}}}));let s=T(e),l=o.current;for(let t of Object.keys(l))t!=="context"&&t!=="getAuthToken"&&t!=="onError"&&t!=="onStatusChange"&&t!=="onFeedback"&&t!=="onReady"&&t!=="tools"&&!(t in s)&&delete l[t];Object.assign(l,s,{agentId:e.agentId});let g=o.current;p(()=>{let t=S(g,E),u=t.subscribe(f);return r.current=t,i.set(e.agentId,t),f(),()=>{u(),t.destroy(),i.get(e.agentId)===t&&i.delete(e.agentId),r.current===t&&(r.current=null),f()}},[e.agentId]);let[C,c]=O("");k(()=>{let t=e.tools??[];if(!t.some(A=>d(A.parameters))){c("");return}let u=!1;return import("./client-tools-manifest-3LJBKDBZ.js").then(({serializeClientTools:A})=>{u||c(JSON.stringify(A(t).map(y=>({inputSchema:y.inputSchema,name:y.name}))))}),()=>{u=!0}},[e.tools]);let b=JSON.stringify({props:T(e),tools:(e.tools??[]).map(t=>({description:t.description,displayName:t.displayName,icon:t.icon,iconColor:t.iconColor,name:t.name,needsApproval:t.needsApproval===!0,parameters:d(t.parameters)?null:t.parameters})),zodToolsSchemasKey:C});return p(()=>{r.current?.update(g)},[b]),null}function T(e){let{context:n,getAuthToken:r,onError:o,onFeedback:s,onReady:l,onStatusChange:g,tools:C,...c}=e;return JSON.parse(JSON.stringify(c))}export{R as a,P as b};
@@ -0,0 +1 @@
1
+ function m(){return function(e){return e}}function u(t){return!!(t&&typeof t=="object"&&typeof t.safeParse=="function")}function A(t,e){return u(t.parameters)?t.parameters.parse(e):e}function y(t,e){let n=t.get(e);return!n||n.needsApproval?null:n}var x="https://agent.heroui.pro",h="https://staging-agent.heroui.pro",I=262144,S=57671680;function b(t,e,n,s,i=crypto.randomUUID()){return{nonce:e,...s===void 0?{}:{payload:s},requestId:i,sessionId:t,type:n}}function E(t){if(!t||typeof t!="object")return null;let e=t;if(typeof e.sessionId!="string"||!a(e.sessionId)||typeof e.nonce!="string"||!a(e.nonce)||typeof e.requestId!="string"||!a(e.requestId)||typeof e.type!="string"||e.type.length===0||!l.has(e.type))return null;let n=e.type==="iframe.persistence"||e.type==="host.upload-data-source"||e.type==="host.rpc-result"?57671680:262144;return p(t)>n||!f(e.type,e.payload)?null:{nonce:e.nonce,...Object.hasOwn(e,"payload")?{payload:e.payload}:{},requestId:e.requestId,sessionId:e.sessionId,type:e.type}}function d(t,e=new Set){if(t===null||typeof t=="string"||typeof t=="boolean")return!0;if(typeof t=="number")return Number.isFinite(t);if(typeof t!="object"||e.has(t))return!1;e.add(t);let n=i=>i===void 0||d(i,e),s=Array.isArray(t)?t.every(n):Object.getPrototypeOf(t)===Object.prototype&&Object.values(t).every(n);return e.delete(t),s}function p(t){return g(t,new Set)}function g(t,e){if(t==null)return 4;if(typeof t=="string")return new TextEncoder().encode(t).byteLength+2;if(typeof t=="boolean"||typeof t=="number")return 8;if(typeof t!="object"||e.has(t))return Number.POSITIVE_INFINITY;if(t instanceof ArrayBuffer||ArrayBuffer.isView(t))return t.byteLength;if(typeof Blob<"u"&&t instanceof Blob)return t.size;e.add(t);let n=2;for(let[s,i]of Object.entries(t))if(n+=g(s,e)+g(i,e),!Number.isFinite(n))break;return e.delete(t),n}function a(t){return t.length>0&&t.length<=128&&/^[A-Za-z0-9._:-]+$/.test(t)}var l=new Set(["host.command","host.init","host.update","host.rpc-result","host.rpc-error","host.upload-data-source","iframe.ready","iframe.reload","iframe.auth-request","iframe.context-request","iframe.feedback","iframe.persistence","iframe.state","iframe.storage","iframe.rpc-result","iframe.rpc-error","iframe.error","iframe.status","iframe.tool-cancel","iframe.tool-execute"]),c=["loading","authenticating","connecting","ready","generating","finishing","reconnecting","failed"],o=t=>!!(t&&typeof t=="object"&&!Array.isArray(t)),r=t=>typeof t=="string";function f(t,e){if(t==="iframe.ready"||t==="iframe.reload"||t==="iframe.auth-request"||t==="iframe.context-request")return e===void 0;if(t==="iframe.status")return c.includes(e);if(!o(e))return!1;switch(t){case"host.init":case"host.update":return o(e.props)&&o(e.localStorage)&&o(e.sessionStorage)&&Object.values(e.localStorage).every(r)&&Object.values(e.sessionStorage).every(r)&&(e.restoreSession===void 0||typeof e.restoreSession=="boolean")&&Array.isArray(e.tools)&&e.tools.every(n=>o(n)&&r(n.name)&&r(n.description)&&o(n.inputSchema));case"host.command":return["show","hide","toggle","preload","refreshAuth","shutdown","newConversation"].includes(e.name);case"host.rpc-error":case"iframe.rpc-error":return r(e.error);case"host.rpc-result":case"iframe.rpc-result":return!0;case"host.upload-data-source":return r(e.toolCallId)&&o(e.upload);case"iframe.tool-cancel":return r(e.idempotencyKey);case"iframe.tool-execute":return["name","conversationId","idempotencyKey","toolCallId"].every(n=>r(e[n]));case"iframe.error":return["authentication","connection","configuration","chunk","rate_limit","credits","deleted","approval","unknown"].includes(e.category)&&c.includes(e.phase)&&r(e.message)&&r(e.diagnosticId)&&typeof e.retryable=="boolean";case"iframe.state":return["open","ready","expanded","closing","dragging","mounted","overlayOpen","resizing"].every(n=>typeof e[n]=="boolean")&&["floating","sidebar"].includes(e.viewMode);case"iframe.storage":return["local","session"].includes(e.storage)&&(e.operation==="clear"||r(e.key)&&(e.operation==="remove"||e.operation==="set"&&r(e.value)));case"iframe.persistence":return["composer-image-drafts","message-outboxes"].includes(e.store)&&(e.operation==="deletePrefix"?r(e.prefix):["get","put","delete"].includes(e.operation)&&r(e.key));case"iframe.feedback":return r(e.conversationId)&&r(e.messageId)&&["positive","negative"].includes(e.rating)&&Array.isArray(e.reasons)}}export{m as a,u as b,A as c,y as d,x as e,h as f,I as g,S as h,b as i,E as j,d as k,p as l};
@@ -1 +1 @@
1
- import{a,b,c,d,e,f,g}from"./chunk-PKCBDTYR.js";import"./chunk-SWO2ABN5.js";export{c as MAX_CLIENT_TOOLS,d as MAX_CLIENT_TOOLS_BYTES,a as RESERVED_AGENT_TOOL_NAMES,b as RESERVED_AGENT_TOOL_PREFIX,e as clientToolManifestEntrySchema,f as clientToolsSchema,g as serializeClientTools};
1
+ import{a,b,c,d,e,f,g}from"./chunk-BDMHEOR3.js";import"./chunk-YPHOJDYK.js";export{c as MAX_CLIENT_TOOLS,d as MAX_CLIENT_TOOLS_BYTES,a as RESERVED_AGENT_TOOL_NAMES,b as RESERVED_AGENT_TOOL_PREFIX,e as clientToolManifestEntrySchema,f as clientToolsSchema,g as serializeClientTools};
package/dist/index.d.ts CHANGED
@@ -1,6 +1,6 @@
1
- import { a3 as HeroUIAgentProps, l as AgentController } from './types-BdAn3HPv.js';
2
- export { A as AGENT_DESIGN_THEMES, a as AGENT_MODEL_IDS, b as AGENT_MODEL_OPTIONS, c as AgentApiOverrides, d as AgentAppearance, e as AgentAttachmentContentType, f as AgentAuthToken, g as AgentCapabilities, h as AgentColorScheme, i as AgentComponentExportFormat, j as AgentComposerOptions, k as AgentContext, m as AgentDataSource, n as AgentDataSourceFormat, o as AgentDesignTheme, p as AgentFeedbackReason, q as AgentLauncherOptions, r as AgentLauncherPosition, s as AgentMarkdownAnimation, t as AgentMarkdownAnimationOptions, u as AgentMarkdownCaret, v as AgentMarkdownOptions, w as AgentMessageAction, x as AgentModelId, y as AgentModelOption, z as AgentModelTier, B as AgentPanelOptions, C as AgentPermissionMode, D as AgentPermissionOptions, E as AgentRadius, F as AgentResponseFeedback, G as AgentSharedContext, H as AgentShouldCloseOnInteractOutside, I as AgentStartScreenOptions, J as AgentSurfaceVariant, K as AgentThemeColor, L as AgentThemeColors, M as AgentThemeOptions, N as AgentTypography, O as AgentViewMode, P as ClientTool, Q as ClientToolExecutionContext, R as ClientToolIcon, S as ClientToolStatus, T as DEFAULT_AGENT_PICKER_MODEL_ID, U as DEFAULT_MARKDOWN_ANIMATION, V as GetAuthToken, W as GetAuthTokenContext, X as HEROUI_AGENT_ATTACHMENT_ACCEPT, Y as HEROUI_AGENT_ATTACHMENT_CONTENT_TYPES, Z as HEROUI_AGENT_ATTACHMENT_CONTENT_TYPE_BY_EXTENSION, _ as HEROUI_AGENT_ATTACHMENT_EXTENSION_BY_CONTENT_TYPE, $ as HEROUI_AGENT_ATTACHMENT_MAX_BYTES, a0 as HEROUI_AGENT_MAX_ATTACHMENTS, a1 as HEROUI_AGENT_TEXT_ATTACHMENT_CONTENT_TYPES, a2 as HeroUIAgentAttachmentContentType, a4 as LEGACY_AGENT_MODEL_IDS, a5 as UploadAgentDataSourceInput, a6 as createToolHelper, a7 as getAgentModelTier, a8 as isAgentModelId, a9 as isHeroUIAgentAttachmentContentType, ab as resolveAgentModelId, ad as resolveHeroUIAgentAttachmentContentType } from './types-BdAn3HPv.js';
3
- export { H as HEROUI_AGENT_API_BASE_URL, a as HEROUI_AGENT_SDK_VERSION } from './version-CIfRqjWe.js';
1
+ import { T as HeroUIAgentProps, i as AgentController } from './types-ZXWEIhzk.js';
2
+ export { A as AgentApiOverrides, a as AgentAppearance, b as AgentAttachmentContentType, c as AgentAuthToken, d as AgentCapabilities, e as AgentColorScheme, f as AgentComponentExportFormat, g as AgentComposerOptions, h as AgentContext, j as AgentDataSource, k as AgentDataSourceFormat, l as AgentDesignTheme, m as AgentError, n as AgentFeedbackReason, o as AgentLauncherOptions, p as AgentLauncherPosition, q as AgentMarkdownAnimation, r as AgentMarkdownAnimationOptions, s as AgentMarkdownCaret, t as AgentMarkdownOptions, u as AgentMessageAction, v as AgentModelId, w as AgentPanelOptions, x as AgentPermissionMode, y as AgentPermissionOptions, z as AgentRadius, B as AgentResponseFeedback, C as AgentSharedContext, D as AgentShouldCloseOnInteractOutside, E as AgentStartScreenOptions, F as AgentStatus, G as AgentSurfaceVariant, H as AgentThemeColor, I as AgentThemeColors, J as AgentThemeOptions, K as AgentTypography, L as AgentViewMode, M as ClientTool, N as ClientToolExecutionContext, O as ClientToolIcon, P as ClientToolStatus, Q as DEFAULT_MARKDOWN_ANIMATION, R as GetAuthToken, S as GetAuthTokenContext, U as UploadAgentDataSourceInput, V as createToolHelper } from './types-ZXWEIhzk.js';
3
+ export { H as HEROUI_AGENT_API_BASE_URL, a as HEROUI_AGENT_SDK_VERSION } from './version-0m_IH9PW.js';
4
4
  import 'react';
5
5
 
6
6
  /** Imperative controls for the hosted iframe Agent. */
package/dist/index.js CHANGED
@@ -1 +1 @@
1
- import{a as d,b as e,c as f,d as g,e as h,f as i,g as j,h as k,i as l,j as m}from"./chunk-PX3X4VP2.js";import"./chunk-6O4WPQKO.js";import{a as n,b as o,c as p,d as q,e as r,f as s,g as t,h as u,i as v,j as w}from"./chunk-7OTMWVOC.js";import{a as b,b as c}from"./chunk-KGJ6UDTY.js";import{a}from"./chunk-SWO2ABN5.js";export{m as AGENT_DESIGN_THEMES,f as AGENT_MODEL_IDS,j as AGENT_MODEL_OPTIONS,i as DEFAULT_AGENT_PICKER_MODEL_ID,n as DEFAULT_MARKDOWN_ANIMATION,c as HEROUI_AGENT_API_BASE_URL,s as HEROUI_AGENT_ATTACHMENT_ACCEPT,r as HEROUI_AGENT_ATTACHMENT_CONTENT_TYPES,t as HEROUI_AGENT_ATTACHMENT_CONTENT_TYPE_BY_EXTENSION,q as HEROUI_AGENT_ATTACHMENT_EXTENSION_BY_CONTENT_TYPE,p as HEROUI_AGENT_ATTACHMENT_MAX_BYTES,o as HEROUI_AGENT_MAX_ATTACHMENTS,b as HEROUI_AGENT_SDK_VERSION,u as HEROUI_AGENT_TEXT_ATTACHMENT_CONTENT_TYPES,e as HeroUIAgent,g as LEGACY_AGENT_MODEL_IDS,a as createToolHelper,l as getAgentModelTier,k as isAgentModelId,v as isHeroUIAgentAttachmentContentType,h as resolveAgentModelId,w as resolveHeroUIAgentAttachmentContentType,d as useAgent};
1
+ import{a as d,b as e}from"./chunk-MVHWCBZK.js";import"./chunk-7NL3SCZA.js";import{a as f}from"./chunk-AR424OVX.js";import{a as b,b as c}from"./chunk-MPJ6AAXH.js";import{a}from"./chunk-YPHOJDYK.js";export{f as DEFAULT_MARKDOWN_ANIMATION,c as HEROUI_AGENT_API_BASE_URL,b as HEROUI_AGENT_SDK_VERSION,e as HeroUIAgent,a as createToolHelper,d as useAgent};
@@ -1,43 +1,7 @@
1
- import { R as ClientToolIcon, l as AgentController, a3 as HeroUIAgentProps, P as ClientTool, V as GetAuthToken } from '../types-BdAn3HPv.js';
2
- export { aa as parseClientToolArgs, ac as resolveDirectToolAction } from '../types-BdAn3HPv.js';
1
+ import { O as ClientToolIcon, U as UploadAgentDataSourceInput, B as AgentResponseFeedback, m as AgentError, F as AgentStatus, i as AgentController, T as HeroUIAgentProps, M as ClientTool, R as GetAuthToken } from '../types-ZXWEIhzk.js';
2
+ export { W as parseClientToolArgs, X as resolveDirectToolAction } from '../types-ZXWEIhzk.js';
3
3
  import 'react';
4
4
 
5
- declare const HEROUI_AGENT_HOSTED_ORIGIN: "https://agent.heroui.pro";
6
- declare const HEROUI_AGENT_HOSTED_STAGING_ORIGIN: "https://staging-agent.heroui.pro";
7
- declare const HEROUI_AGENT_BRIDGE_MAX_MESSAGE_BYTES: number;
8
- declare const HEROUI_AGENT_BRIDGE_MAX_PERSISTENCE_BYTES: number;
9
- type AgentBridgeJsonValue = boolean | null | number | string | AgentBridgeJsonValue[] | {
10
- [key: string]: AgentBridgeJsonValue;
11
- };
12
- type HostedAgentToolManifest = {
13
- description: string;
14
- displayName?: string;
15
- icon?: ClientToolIcon;
16
- iconColor?: string;
17
- inputSchema: Record<string, unknown>;
18
- name: string;
19
- needsApproval?: boolean;
20
- };
21
- type AgentBridgeEnvelope = {
22
- nonce: string;
23
- payload?: unknown;
24
- requestId: string;
25
- sessionId: string;
26
- type: string;
27
- };
28
- declare function createAgentBridgeEnvelope(sessionId: string, nonce: string, type: string, payload?: unknown, requestId?: string): AgentBridgeEnvelope;
29
- declare function parseAgentBridgeEnvelope(value: unknown): AgentBridgeEnvelope | null;
30
- declare function isAgentBridgeJsonValue(value: unknown, seen?: Set<object>): value is AgentBridgeJsonValue;
31
- declare function estimateAgentBridgeMessageBytes(value: unknown): number;
32
-
33
- type AgentHostController = AgentController & {
34
- destroy: () => void;
35
- subscribe: (listener: () => void) => () => void;
36
- update: (options: HeroUIAgentProps) => void;
37
- };
38
- type ClientToolManifestSerializer = (tools: ClientTool[]) => HostedAgentToolManifest[] | Promise<HostedAgentToolManifest[]>;
39
- declare function mountAgent(initialOptions: HeroUIAgentProps, serializeTools: ClientToolManifestSerializer): AgentHostController;
40
-
41
5
  type HostedFrameBounds = {
42
6
  bottom: number;
43
7
  left: number;
@@ -78,6 +42,112 @@ type HostPageLayout = {
78
42
  } | null;
79
43
  };
80
44
 
45
+ declare const HEROUI_AGENT_HOSTED_ORIGIN: "https://agent.heroui.pro";
46
+ declare const HEROUI_AGENT_HOSTED_STAGING_ORIGIN: "https://staging-agent.heroui.pro";
47
+ declare const HEROUI_AGENT_BRIDGE_MAX_MESSAGE_BYTES: number;
48
+ declare const HEROUI_AGENT_BRIDGE_MAX_PERSISTENCE_BYTES: number;
49
+ type AgentBridgeJsonValue = boolean | null | number | string | AgentBridgeJsonValue[] | {
50
+ [key: string]: AgentBridgeJsonValue;
51
+ };
52
+ type HostedAgentToolManifest = {
53
+ description: string;
54
+ displayName?: string;
55
+ icon?: ClientToolIcon;
56
+ iconColor?: string;
57
+ inputSchema: Record<string, unknown>;
58
+ name: string;
59
+ needsApproval?: boolean;
60
+ };
61
+ type HostedAgentInit = {
62
+ restoreSession?: boolean;
63
+ localStorage: Record<string, string>;
64
+ sessionStorage: Record<string, string>;
65
+ props: Record<string, unknown>;
66
+ tools: HostedAgentToolManifest[];
67
+ };
68
+ type AgentPersistenceRequest = {
69
+ store: "composer-image-drafts" | "message-outboxes";
70
+ operation: "get" | "put" | "delete" | "deletePrefix";
71
+ key?: string;
72
+ prefix?: string;
73
+ value?: unknown;
74
+ };
75
+ type AgentBridgePayloads = {
76
+ "host.command": {
77
+ name: string;
78
+ payload?: unknown;
79
+ };
80
+ "host.init": HostedAgentInit;
81
+ "host.update": HostedAgentInit;
82
+ "host.rpc-result": {
83
+ value: unknown;
84
+ };
85
+ "host.rpc-error": {
86
+ error: string;
87
+ };
88
+ "host.upload-data-source": {
89
+ toolCallId: string;
90
+ upload: UploadAgentDataSourceInput;
91
+ };
92
+ "iframe.ready": undefined;
93
+ "iframe.reload": undefined;
94
+ "iframe.auth-request": undefined;
95
+ "iframe.context-request": undefined;
96
+ "iframe.feedback": AgentResponseFeedback;
97
+ "iframe.persistence": AgentPersistenceRequest;
98
+ "iframe.state": HostedFrameState;
99
+ "iframe.storage": {
100
+ operation: "set" | "remove" | "clear";
101
+ storage: "local" | "session";
102
+ key?: string;
103
+ value?: string;
104
+ };
105
+ "iframe.rpc-result": {
106
+ value: unknown;
107
+ };
108
+ "iframe.rpc-error": {
109
+ error: string;
110
+ };
111
+ "iframe.error": AgentError;
112
+ "iframe.status": AgentStatus;
113
+ "iframe.tool-cancel": {
114
+ idempotencyKey: string;
115
+ };
116
+ "iframe.tool-execute": {
117
+ args: unknown;
118
+ conversationId: string;
119
+ idempotencyKey: string;
120
+ name: string;
121
+ toolCallId: string;
122
+ };
123
+ };
124
+ type AgentBridgeMessageType = keyof AgentBridgePayloads;
125
+ type AgentBridgeEnvelope<T extends AgentBridgeMessageType = AgentBridgeMessageType> = T extends AgentBridgeMessageType ? {
126
+ nonce: string;
127
+ payload?: AgentBridgePayloads[T];
128
+ requestId: string;
129
+ sessionId: string;
130
+ type: T;
131
+ } : never;
132
+ declare function createAgentBridgeEnvelope<T extends AgentBridgeMessageType>(sessionId: string, nonce: string, type: T, payload?: AgentBridgePayloads[T], requestId?: string): AgentBridgeEnvelope<T>;
133
+ declare function parseAgentBridgeEnvelope(value: unknown): AgentBridgeEnvelope | null;
134
+ declare function isAgentBridgeJsonValue(value: unknown, seen?: Set<object>): value is AgentBridgeJsonValue;
135
+ declare function estimateAgentBridgeMessageBytes(value: unknown): number;
136
+
137
+ /** Bounds even callbacks that do not cooperate with cancellation. */
138
+ declare function abortable<T>(signal: AbortSignal, work: () => Promise<T>): Promise<T>;
139
+ declare function withDeadline<T>(milliseconds: number, work: (signal: AbortSignal) => Promise<T>, parent?: AbortSignal): Promise<T>;
140
+
141
+ declare function createAgentError(cause: unknown, phase?: AgentStatus): AgentError;
142
+
143
+ type AgentHostController = AgentController & {
144
+ destroy: () => void;
145
+ subscribe: (listener: () => void) => () => void;
146
+ update: (options: HeroUIAgentProps) => void;
147
+ };
148
+ type ClientToolManifestSerializer = (tools: ClientTool[]) => HostedAgentToolManifest[] | Promise<HostedAgentToolManifest[]>;
149
+ declare function mountAgent(initialOptions: HeroUIAgentProps, serializeTools: ClientToolManifestSerializer): AgentHostController;
150
+
81
151
  /**
82
152
  * Requests a short-lived HeroUI Agent credential through the host
83
153
  * application's server callback. Refresh and request de-duplication are
@@ -90,6 +160,7 @@ declare class EmbedSessionManager {
90
160
  private failure;
91
161
  private generation;
92
162
  private pending;
163
+ private controller;
93
164
  constructor(agentId: string, getAuthToken: GetAuthToken);
94
165
  clear(): void;
95
166
  /**
@@ -105,4 +176,4 @@ declare class EmbedSessionManager {
105
176
  private refresh;
106
177
  }
107
178
 
108
- export { type AgentBridgeEnvelope, type AgentBridgeJsonValue, type AgentHostController, type ClientToolManifestSerializer, EmbedSessionManager, HEROUI_AGENT_BRIDGE_MAX_MESSAGE_BYTES, HEROUI_AGENT_BRIDGE_MAX_PERSISTENCE_BYTES, HEROUI_AGENT_HOSTED_ORIGIN, HEROUI_AGENT_HOSTED_STAGING_ORIGIN, type HostPageLayout, type HostedAgentToolManifest, type HostedFrameState, createAgentBridgeEnvelope, estimateAgentBridgeMessageBytes, isAgentBridgeJsonValue, mountAgent, parseAgentBridgeEnvelope };
179
+ export { type AgentBridgeEnvelope, type AgentBridgeJsonValue, type AgentBridgeMessageType, type AgentBridgePayloads, type AgentHostController, type AgentPersistenceRequest, type ClientToolManifestSerializer, EmbedSessionManager, HEROUI_AGENT_BRIDGE_MAX_MESSAGE_BYTES, HEROUI_AGENT_BRIDGE_MAX_PERSISTENCE_BYTES, HEROUI_AGENT_HOSTED_ORIGIN, HEROUI_AGENT_HOSTED_STAGING_ORIGIN, type HostPageLayout, type HostedAgentInit, type HostedAgentToolManifest, type HostedFrameState, abortable, createAgentBridgeEnvelope, createAgentError, estimateAgentBridgeMessageBytes, isAgentBridgeJsonValue, mountAgent, parseAgentBridgeEnvelope, withDeadline };
@@ -1 +1 @@
1
- import{a as t,b as r}from"../chunk-6O4WPQKO.js";import"../chunk-KGJ6UDTY.js";import{c as o,d as e,e as s,f as a,g as l,h as n,i as m,j as p,k as i,l as f}from"../chunk-SWO2ABN5.js";export{t as EmbedSessionManager,l as HEROUI_AGENT_BRIDGE_MAX_MESSAGE_BYTES,n as HEROUI_AGENT_BRIDGE_MAX_PERSISTENCE_BYTES,s as HEROUI_AGENT_HOSTED_ORIGIN,a as HEROUI_AGENT_HOSTED_STAGING_ORIGIN,m as createAgentBridgeEnvelope,f as estimateAgentBridgeMessageBytes,i as isAgentBridgeJsonValue,r as mountAgent,p as parseAgentBridgeEnvelope,o as parseClientToolArgs,e as resolveDirectToolAction};
1
+ import{a as r,b as t,c as a,d as l,e as n}from"../chunk-7NL3SCZA.js";import"../chunk-MPJ6AAXH.js";import{c as o,d as e,e as m,f as p,g as s,h as i,i as f,j as x,k as g,l as A}from"../chunk-YPHOJDYK.js";export{l as EmbedSessionManager,s as HEROUI_AGENT_BRIDGE_MAX_MESSAGE_BYTES,i as HEROUI_AGENT_BRIDGE_MAX_PERSISTENCE_BYTES,m as HEROUI_AGENT_HOSTED_ORIGIN,p as HEROUI_AGENT_HOSTED_STAGING_ORIGIN,r as abortable,f as createAgentBridgeEnvelope,a as createAgentError,A as estimateAgentBridgeMessageBytes,g as isAgentBridgeJsonValue,n as mountAgent,x as parseAgentBridgeEnvelope,o as parseClientToolArgs,e as resolveDirectToolAction,t as withDeadline};
@@ -1,7 +1,7 @@
1
- import { P as ClientTool } from '../types-BdAn3HPv.js';
2
- export { U as DEFAULT_MARKDOWN_ANIMATION, X as HEROUI_AGENT_ATTACHMENT_ACCEPT, Y as HEROUI_AGENT_ATTACHMENT_CONTENT_TYPES, a9 as isHeroUIAgentAttachmentContentType } from '../types-BdAn3HPv.js';
3
- export { H as HEROUI_AGENT_API_BASE_URL, a as HEROUI_AGENT_SDK_VERSION } from '../version-CIfRqjWe.js';
1
+ export { H as HEROUI_AGENT_API_BASE_URL, a as HEROUI_AGENT_SDK_VERSION } from '../version-0m_IH9PW.js';
4
2
  import { z } from 'zod';
3
+ import { M as ClientTool } from '../types-ZXWEIhzk.js';
4
+ export { Q as DEFAULT_MARKDOWN_ANIMATION } from '../types-ZXWEIhzk.js';
5
5
  import 'react';
6
6
 
7
7
  declare const agentIdentityIdSchema: z.ZodString;
@@ -41,7 +41,7 @@ type AgentAuthProfile = z.infer<typeof agentAuthProfileSchema>;
41
41
  type AgentAuthToken = z.infer<typeof agentAuthTokenSchema>;
42
42
  type CreateAgentAuthTokenRequest = z.infer<typeof createAgentAuthTokenRequestSchema>;
43
43
 
44
- declare const RESERVED_AGENT_TOOL_NAMES: readonly ["callMcpTool", "composeUI", "executeSandbox", "generateFile", "getComponentSchema", "renderComponent", "searchKnowledge", "searchMcpTools", "searchWeb"];
44
+ declare const RESERVED_AGENT_TOOL_NAMES: readonly ["readConversationHistory", "callMcpTool", "composeUI", "executeSandbox", "generateFile", "getComponentSchema", "renderComponent", "searchKnowledge", "searchMcpTools", "searchWeb"];
45
45
  declare const RESERVED_AGENT_TOOL_PREFIX = "mcp_";
46
46
  declare const MAX_CLIENT_TOOLS = 20;
47
47
  declare const MAX_CLIENT_TOOLS_BYTES: number;
@@ -1 +1 @@
1
- import{a as u,e as E,f as l,i as _}from"../chunk-7OTMWVOC.js";import{a as r,b as a}from"../chunk-KGJ6UDTY.js";import{a as A,b as m,c as p,d as T,e as s,f as c,g as h}from"../chunk-PKCBDTYR.js";import"../chunk-SWO2ABN5.js";import{z as e}from"zod";var g=new Set(["[object object]","0","anonymous","distinct_id","distinctid","email","false","guest","id","nan","none","not_authenticated","null","true","undefined"]),t=e.string().trim().min(1).max(200).refine(i=>!g.has(i.toLowerCase()),{message:"Identity id is reserved"}),n=e.discriminatedUnion("type",[e.object({id:t,type:e.literal("anonymous")}),e.object({id:t,type:e.literal("user")})]),o=e.object({avatarUrl:e.string().trim().pipe(e.url()).optional(),email:e.string().trim().max(320).pipe(e.email()).optional(),name:e.string().trim().max(120).optional()}),S=e.object({anonymousId:t.optional(),identity:n,profile:o.optional()}),f=e.object({expiresAt:e.number().int().positive(),token:e.string().trim().min(1)});export{u as DEFAULT_MARKDOWN_ANIMATION,a as HEROUI_AGENT_API_BASE_URL,l as HEROUI_AGENT_ATTACHMENT_ACCEPT,E as HEROUI_AGENT_ATTACHMENT_CONTENT_TYPES,r as HEROUI_AGENT_SDK_VERSION,p as MAX_CLIENT_TOOLS,T as MAX_CLIENT_TOOLS_BYTES,A as RESERVED_AGENT_TOOL_NAMES,m as RESERVED_AGENT_TOOL_PREFIX,n as agentAuthIdentitySchema,o as agentAuthProfileSchema,f as agentAuthTokenSchema,t as agentIdentityIdSchema,s as clientToolManifestEntrySchema,c as clientToolsSchema,S as createAgentAuthTokenRequestSchema,_ as isHeroUIAgentAttachmentContentType,h as serializeClientTools};
1
+ import{a as l}from"../chunk-AR424OVX.js";import{a,b as r}from"../chunk-MPJ6AAXH.js";import{a as m,b as A,c as p,d as s,e as c,f as h,g as u}from"../chunk-BDMHEOR3.js";import"../chunk-YPHOJDYK.js";import{z as e}from"zod";var g=new Set(["[object object]","0","anonymous","distinct_id","distinctid","email","false","guest","id","nan","none","not_authenticated","null","true","undefined"]),t=e.string().trim().min(1).max(200).refine(i=>!g.has(i.toLowerCase()),{message:"Identity id is reserved"}),n=e.discriminatedUnion("type",[e.object({id:t,type:e.literal("anonymous")}),e.object({id:t,type:e.literal("user")})]),o=e.object({avatarUrl:e.string().trim().pipe(e.url()).optional(),email:e.string().trim().max(320).pipe(e.email()).optional(),name:e.string().trim().max(120).optional()}),T=e.object({anonymousId:t.optional(),identity:n,profile:o.optional()}),S=e.object({expiresAt:e.number().int().positive(),token:e.string().trim().min(1)});export{l as DEFAULT_MARKDOWN_ANIMATION,r as HEROUI_AGENT_API_BASE_URL,a as HEROUI_AGENT_SDK_VERSION,p as MAX_CLIENT_TOOLS,s as MAX_CLIENT_TOOLS_BYTES,m as RESERVED_AGENT_TOOL_NAMES,A as RESERVED_AGENT_TOOL_PREFIX,n as agentAuthIdentitySchema,o as agentAuthProfileSchema,S as agentAuthTokenSchema,t as agentIdentityIdSchema,c as clientToolManifestEntrySchema,h as clientToolsSchema,T as createAgentAuthTokenRequestSchema,u as serializeClientTools};
package/dist/next.d.ts CHANGED
@@ -1,4 +1,4 @@
1
- export { A as AGENT_DESIGN_THEMES, a as AGENT_MODEL_IDS, b as AGENT_MODEL_OPTIONS, c as AgentApiOverrides, d as AgentAppearance, e as AgentAttachmentContentType, f as AgentAuthToken, g as AgentCapabilities, h as AgentColorScheme, i as AgentComponentExportFormat, j as AgentComposerOptions, k as AgentContext, l as AgentController, m as AgentDataSource, n as AgentDataSourceFormat, o as AgentDesignTheme, p as AgentFeedbackReason, q as AgentLauncherOptions, r as AgentLauncherPosition, s as AgentMarkdownAnimation, t as AgentMarkdownAnimationOptions, u as AgentMarkdownCaret, v as AgentMarkdownOptions, w as AgentMessageAction, x as AgentModelId, y as AgentModelOption, z as AgentModelTier, B as AgentPanelOptions, C as AgentPermissionMode, D as AgentPermissionOptions, E as AgentRadius, F as AgentResponseFeedback, G as AgentSharedContext, H as AgentShouldCloseOnInteractOutside, I as AgentStartScreenOptions, J as AgentSurfaceVariant, K as AgentThemeColor, L as AgentThemeColors, M as AgentThemeOptions, N as AgentTypography, O as AgentViewMode, P as ClientTool, Q as ClientToolExecutionContext, R as ClientToolIcon, S as ClientToolStatus, T as DEFAULT_AGENT_PICKER_MODEL_ID, U as DEFAULT_MARKDOWN_ANIMATION, V as GetAuthToken, W as GetAuthTokenContext, X as HEROUI_AGENT_ATTACHMENT_ACCEPT, Y as HEROUI_AGENT_ATTACHMENT_CONTENT_TYPES, Z as HEROUI_AGENT_ATTACHMENT_CONTENT_TYPE_BY_EXTENSION, _ as HEROUI_AGENT_ATTACHMENT_EXTENSION_BY_CONTENT_TYPE, $ as HEROUI_AGENT_ATTACHMENT_MAX_BYTES, a0 as HEROUI_AGENT_MAX_ATTACHMENTS, a1 as HEROUI_AGENT_TEXT_ATTACHMENT_CONTENT_TYPES, a2 as HeroUIAgentAttachmentContentType, a3 as HeroUIAgentProps, a4 as LEGACY_AGENT_MODEL_IDS, a5 as UploadAgentDataSourceInput, a6 as createToolHelper, a7 as getAgentModelTier, a8 as isAgentModelId, a9 as isHeroUIAgentAttachmentContentType, ab as resolveAgentModelId, ad as resolveHeroUIAgentAttachmentContentType } from './types-BdAn3HPv.js';
1
+ export { A as AgentApiOverrides, a as AgentAppearance, b as AgentAttachmentContentType, c as AgentAuthToken, d as AgentCapabilities, e as AgentColorScheme, f as AgentComponentExportFormat, g as AgentComposerOptions, h as AgentContext, i as AgentController, j as AgentDataSource, k as AgentDataSourceFormat, l as AgentDesignTheme, m as AgentError, n as AgentFeedbackReason, o as AgentLauncherOptions, p as AgentLauncherPosition, q as AgentMarkdownAnimation, r as AgentMarkdownAnimationOptions, s as AgentMarkdownCaret, t as AgentMarkdownOptions, u as AgentMessageAction, v as AgentModelId, w as AgentPanelOptions, x as AgentPermissionMode, y as AgentPermissionOptions, z as AgentRadius, B as AgentResponseFeedback, C as AgentSharedContext, D as AgentShouldCloseOnInteractOutside, E as AgentStartScreenOptions, F as AgentStatus, G as AgentSurfaceVariant, H as AgentThemeColor, I as AgentThemeColors, J as AgentThemeOptions, K as AgentTypography, L as AgentViewMode, M as ClientTool, N as ClientToolExecutionContext, O as ClientToolIcon, P as ClientToolStatus, Q as DEFAULT_MARKDOWN_ANIMATION, R as GetAuthToken, S as GetAuthTokenContext, T as HeroUIAgentProps, U as UploadAgentDataSourceInput, V as createToolHelper } from './types-ZXWEIhzk.js';
2
2
  export { HeroUIAgent, useAgent } from './index.js';
3
- export { H as HEROUI_AGENT_API_BASE_URL, a as HEROUI_AGENT_SDK_VERSION } from './version-CIfRqjWe.js';
3
+ export { H as HEROUI_AGENT_API_BASE_URL, a as HEROUI_AGENT_SDK_VERSION } from './version-0m_IH9PW.js';
4
4
  import 'react';
package/dist/next.js CHANGED
@@ -1 +1 @@
1
- import{a as f,b as m,c as p,d as t,e as x,f as a,g as b,h as c,i as d,j as g}from"./chunk-PX3X4VP2.js";import"./chunk-6O4WPQKO.js";import{a as h,b as i,c as j,d as k,e as l,f as n,g as q,h as s,i as u,j as v}from"./chunk-7OTMWVOC.js";import{a as r,b as e}from"./chunk-KGJ6UDTY.js";import{a as o}from"./chunk-SWO2ABN5.js";export{g as AGENT_DESIGN_THEMES,p as AGENT_MODEL_IDS,b as AGENT_MODEL_OPTIONS,a as DEFAULT_AGENT_PICKER_MODEL_ID,h as DEFAULT_MARKDOWN_ANIMATION,e as HEROUI_AGENT_API_BASE_URL,n as HEROUI_AGENT_ATTACHMENT_ACCEPT,l as HEROUI_AGENT_ATTACHMENT_CONTENT_TYPES,q as HEROUI_AGENT_ATTACHMENT_CONTENT_TYPE_BY_EXTENSION,k as HEROUI_AGENT_ATTACHMENT_EXTENSION_BY_CONTENT_TYPE,j as HEROUI_AGENT_ATTACHMENT_MAX_BYTES,i as HEROUI_AGENT_MAX_ATTACHMENTS,r as HEROUI_AGENT_SDK_VERSION,s as HEROUI_AGENT_TEXT_ATTACHMENT_CONTENT_TYPES,m as HeroUIAgent,t as LEGACY_AGENT_MODEL_IDS,o as createToolHelper,d as getAgentModelTier,c as isAgentModelId,u as isHeroUIAgentAttachmentContentType,x as resolveAgentModelId,v as resolveHeroUIAgentAttachmentContentType,f as useAgent};
1
+ import{a as f,b as m}from"./chunk-MVHWCBZK.js";import"./chunk-7NL3SCZA.js";import{a as p}from"./chunk-AR424OVX.js";import{a as r,b as e}from"./chunk-MPJ6AAXH.js";import{a as o}from"./chunk-YPHOJDYK.js";export{p as DEFAULT_MARKDOWN_ANIMATION,e as HEROUI_AGENT_API_BASE_URL,r as HEROUI_AGENT_SDK_VERSION,m as HeroUIAgent,o as createToolHelper,f as useAgent};
@@ -35,6 +35,7 @@ type UploadAgentDataSourceInput = Readonly<{
35
35
  * return the original result instead of applying the side effect twice.
36
36
  */
37
37
  type ClientToolExecutionContext = Readonly<{
38
+ signal: AbortSignal;
38
39
  conversationId: string;
39
40
  idempotencyKey: string;
40
41
  toolCallId: string;
@@ -80,137 +81,6 @@ declare function parseClientToolArgs(tool: ClientTool, input: unknown): unknown;
80
81
  */
81
82
  declare function resolveDirectToolAction(tools: ReadonlyMap<string, ClientTool>, toolName: string): ClientTool | null;
82
83
 
83
- /** Maximum number of files accepted on one HeroUI Agent message. */
84
- declare const HEROUI_AGENT_MAX_ATTACHMENTS = 5;
85
- /** Maximum stored size for one HeroUI Agent attachment (10 MiB). */
86
- declare const HEROUI_AGENT_ATTACHMENT_MAX_BYTES: number;
87
- /**
88
- * File types that the hosted model pipeline can process consistently.
89
- *
90
- * SVG is intentionally excluded because it can carry active content. Hosted
91
- * document parsing handles the remaining office and publishing formats.
92
- */
93
- declare const HEROUI_AGENT_ATTACHMENT_EXTENSION_BY_CONTENT_TYPE: {
94
- readonly "application/epub+zip": "epub";
95
- readonly "application/json": "json";
96
- readonly "application/msword": "doc";
97
- readonly "application/pdf": "pdf";
98
- readonly "application/rtf": "rtf";
99
- readonly "application/vnd.ms-excel": "xls";
100
- readonly "application/vnd.ms-excel.sheet.binary.macroenabled.12": "xlsb";
101
- readonly "application/vnd.ms-excel.sheet.macroenabled.12": "xlsm";
102
- readonly "application/vnd.ms-powerpoint": "ppt";
103
- readonly "application/vnd.ms-powerpoint.presentation.macroenabled.12": "pptm";
104
- readonly "application/vnd.ms-word.document.macroenabled.12": "docm";
105
- readonly "application/vnd.oasis.opendocument.presentation": "odp";
106
- readonly "application/vnd.oasis.opendocument.spreadsheet": "ods";
107
- readonly "application/vnd.oasis.opendocument.text": "odt";
108
- readonly "application/vnd.openxmlformats-officedocument.presentationml.presentation": "pptx";
109
- readonly "application/vnd.openxmlformats-officedocument.spreadsheetml.sheet": "xlsx";
110
- readonly "application/vnd.openxmlformats-officedocument.wordprocessingml.document": "docx";
111
- readonly "image/gif": "gif";
112
- readonly "image/jpeg": "jpg";
113
- readonly "image/png": "png";
114
- readonly "image/webp": "webp";
115
- readonly "text/csv": "csv";
116
- readonly "text/html": "html";
117
- readonly "text/markdown": "md";
118
- readonly "text/plain": "txt";
119
- readonly "text/rtf": "rtf";
120
- readonly "text/tab-separated-values": "tsv";
121
- };
122
- type HeroUIAgentAttachmentContentType = keyof typeof HEROUI_AGENT_ATTACHMENT_EXTENSION_BY_CONTENT_TYPE;
123
- declare const HEROUI_AGENT_ATTACHMENT_CONTENT_TYPES: readonly ("application/json" | "text/csv" | "text/tab-separated-values" | "application/epub+zip" | "application/msword" | "application/pdf" | "application/rtf" | "application/vnd.ms-excel" | "application/vnd.ms-excel.sheet.binary.macroenabled.12" | "application/vnd.ms-excel.sheet.macroenabled.12" | "application/vnd.ms-powerpoint" | "application/vnd.ms-powerpoint.presentation.macroenabled.12" | "application/vnd.ms-word.document.macroenabled.12" | "application/vnd.oasis.opendocument.presentation" | "application/vnd.oasis.opendocument.spreadsheet" | "application/vnd.oasis.opendocument.text" | "application/vnd.openxmlformats-officedocument.presentationml.presentation" | "application/vnd.openxmlformats-officedocument.spreadsheetml.sheet" | "application/vnd.openxmlformats-officedocument.wordprocessingml.document" | "image/gif" | "image/jpeg" | "image/png" | "image/webp" | "text/html" | "text/markdown" | "text/plain" | "text/rtf")[];
124
- declare const HEROUI_AGENT_ATTACHMENT_ACCEPT: string;
125
- declare const HEROUI_AGENT_ATTACHMENT_CONTENT_TYPE_BY_EXTENSION: Readonly<Record<string, "application/json" | "text/csv" | "text/tab-separated-values" | "application/epub+zip" | "application/msword" | "application/pdf" | "application/rtf" | "application/vnd.ms-excel" | "application/vnd.ms-excel.sheet.binary.macroenabled.12" | "application/vnd.ms-excel.sheet.macroenabled.12" | "application/vnd.ms-powerpoint" | "application/vnd.ms-powerpoint.presentation.macroenabled.12" | "application/vnd.ms-word.document.macroenabled.12" | "application/vnd.oasis.opendocument.presentation" | "application/vnd.oasis.opendocument.spreadsheet" | "application/vnd.oasis.opendocument.text" | "application/vnd.openxmlformats-officedocument.presentationml.presentation" | "application/vnd.openxmlformats-officedocument.spreadsheetml.sheet" | "application/vnd.openxmlformats-officedocument.wordprocessingml.document" | "image/gif" | "image/jpeg" | "image/png" | "image/webp" | "text/html" | "text/markdown" | "text/plain" | "text/rtf">>;
126
- declare const HEROUI_AGENT_TEXT_ATTACHMENT_CONTENT_TYPES: ReadonlySet<string>;
127
- declare function isHeroUIAgentAttachmentContentType(value: string): value is HeroUIAgentAttachmentContentType;
128
- /** Browsers sometimes omit Office MIME types; fall back to the file extension. */
129
- declare function resolveHeroUIAgentAttachmentContentType(contentType: string, filename: string): HeroUIAgentAttachmentContentType | null;
130
-
131
- /**
132
- * Deliberately Zod-free: the model catalogue is re-exported from the package
133
- * root, so importing Zod here would pull the whole validation library into the
134
- * panel shell's first-paint graph. The matching schema lives in
135
- * `./models.schema`, which only server and contract consumers need.
136
- */
137
- /** Model ids the hosted agent accepts from the browser picker. */
138
- declare const AGENT_MODEL_IDS: readonly ["moonshotai/Kimi-K3", "openai/gpt-5.6-luna", "openai/gpt-5.6-terra", "openai/gpt-5.6-sol", "google/gemini-3.7-flash", "anthropic/claude-sonnet-5", "anthropic/claude-opus-4.8"];
139
- type AgentModelId = (typeof AGENT_MODEL_IDS)[number];
140
- /**
141
- * Retired ids mapped to their replacement. Model ids are a public part of the
142
- * embed API — a customer pins one in their own code and projects store one as
143
- * their default — so a retired id keeps resolving instead of failing the
144
- * session with an "Invalid agent model" error.
145
- */
146
- declare const LEGACY_AGENT_MODEL_IDS: Record<string, AgentModelId>;
147
- /** Resolves a possibly-retired model id to the id the runtime should use. */
148
- declare function resolveAgentModelId(value: string): string;
149
- type AgentModelTier = "codegen" | "complex" | "light";
150
- type AgentModelOption = {
151
- description: string;
152
- id: AgentModelId;
153
- label: string;
154
- provider: "Anthropic" | "Google" | "Moonshot AI" | "OpenAI";
155
- tier: AgentModelTier;
156
- };
157
- /**
158
- * Recommended default selected when the optional picker first opens. Gemini 3.7 Flash
159
- * matches the hosted runtime's baked-in default (`DEFAULT_CHAT_MODEL_IDS.herouiAgent`),
160
- * so what users see in the picker is what actually runs by default.
161
- */
162
- declare const DEFAULT_AGENT_PICKER_MODEL_ID = "google/gemini-3.7-flash";
163
- /**
164
- * Small, tool-capable model catalog for HeroUI Agent. These ids are the
165
- * server-side allowlist as well as the browser picker source of truth.
166
- */
167
- declare const AGENT_MODEL_OPTIONS: readonly [{
168
- readonly description: "Flagship model for coding, reasoning, and knowledge work";
169
- readonly id: "moonshotai/Kimi-K3";
170
- readonly label: "Kimi K3";
171
- readonly provider: "Moonshot AI";
172
- readonly tier: "light";
173
- }, {
174
- readonly description: "Fast answers and lightweight agent workflows";
175
- readonly id: "openai/gpt-5.6-luna";
176
- readonly label: "GPT-5.6 Luna";
177
- readonly provider: "OpenAI";
178
- readonly tier: "light";
179
- }, {
180
- readonly description: "Balanced reasoning for everyday agent tasks";
181
- readonly id: "openai/gpt-5.6-terra";
182
- readonly label: "GPT-5.6 Terra";
183
- readonly provider: "OpenAI";
184
- readonly tier: "codegen";
185
- }, {
186
- readonly description: "Deep reasoning for complex, multi-step analysis";
187
- readonly id: "openai/gpt-5.6-sol";
188
- readonly label: "GPT-5.6 Sol";
189
- readonly provider: "OpenAI";
190
- readonly tier: "complex";
191
- }, {
192
- readonly description: "Fast multimodal analysis with a large context window";
193
- readonly id: "google/gemini-3.7-flash";
194
- readonly label: "Gemini 3.7 Flash";
195
- readonly provider: "Google";
196
- readonly tier: "light";
197
- }, {
198
- readonly description: "Strong agentic reasoning and polished UI decisions";
199
- readonly id: "anthropic/claude-sonnet-5";
200
- readonly label: "Claude Sonnet 5";
201
- readonly provider: "Anthropic";
202
- readonly tier: "codegen";
203
- }, {
204
- readonly description: "Highest-capability Claude for difficult research and analysis";
205
- readonly id: "anthropic/claude-opus-4.8";
206
- readonly label: "Claude Opus 4.8";
207
- readonly provider: "Anthropic";
208
- readonly tier: "complex";
209
- }];
210
- declare function isAgentModelId(value: unknown): value is AgentModelId;
211
- /** Unknown/env-overridden models keep the hosted agent's historical light tier. */
212
- declare function getAgentModelTier(modelId?: string): AgentModelTier;
213
-
214
84
  /**
215
85
  * Light/dark color scheme selection for the embed. `"system"` follows the
216
86
  * OS preference and updates live when it changes.
@@ -258,13 +128,14 @@ type AgentTypography = {
258
128
  fontFamily?: string;
259
129
  };
260
130
  /**
261
- * HeroUI Pro theme variant applied to the agent surface.
131
+ * HeroUI Pro theme variant applied to the agent surface, e.g. `"base"`,
132
+ * `"brutalism"`, `"glass"`, or `"mouve"`.
262
133
  *
263
- * Hosted Agent deployments include all supported variants; the selected one
264
- * is activated inside the iframe.
134
+ * Hosted Agent deployments own the list of supported variants and activate the
135
+ * selected one inside the iframe; unknown values fall back to `"base"`, so new
136
+ * variants never require an SDK update.
265
137
  */
266
- type AgentDesignTheme = "base" | "brutalism" | "glass" | "mouve";
267
- declare const AGENT_DESIGN_THEMES: readonly AgentDesignTheme[];
138
+ type AgentDesignTheme = string;
268
139
  /**
269
140
  * Intentionally small theme surface: one color scheme, one Pro variant, four
270
141
  * radius presets, seven color tokens, and basic typography. No named themes,
@@ -286,8 +157,20 @@ type AgentThemeOptions = {
286
157
 
287
158
  type AgentComponentExportFormat = "csv" | "png" | "svg";
288
159
  type AgentPermissionMode = "ask" | "auto" | "full";
289
- /** MIME type accepted by the hosted HeroUI Agent attachment pipeline. */
290
- type AgentAttachmentContentType = HeroUIAgentAttachmentContentType;
160
+ /**
161
+ * MIME type accepted by the hosted HeroUI Agent attachment pipeline, e.g.
162
+ * `"application/pdf"` or `"text/csv"`. The hosted Agent owns the supported
163
+ * list and ignores unknown types, so new formats never require an SDK update.
164
+ * See https://heroui.pro/docs/agents/api-reference/configuration.
165
+ */
166
+ type AgentAttachmentContentType = string;
167
+ /**
168
+ * Model id from the hosted HeroUI Agent catalog, e.g. `"google/gemini-3.8-flash"`.
169
+ * The hosted Agent owns the catalog: retired ids resolve to their replacement
170
+ * and unknown ids fall back to the default model, so new models never require
171
+ * an SDK update. See https://heroui.pro/docs/agents/api-reference/models.
172
+ */
173
+ type AgentModelId = string;
291
174
  type AgentMessageAction = "copy" | "feedback" | "retry";
292
175
  type AgentFeedbackReason = "did_not_follow_instructions" | "incomplete" | "incorrect" | "not_relevant" | "other" | "unclear";
293
176
  type AgentResponseFeedback = {
@@ -543,11 +426,22 @@ type AgentAuthToken = {
543
426
  };
544
427
  /** Context supplied whenever the SDK needs a fresh browser credential. */
545
428
  type GetAuthTokenContext = {
429
+ signal: AbortSignal;
546
430
  anonymousId: string;
547
431
  agentId: string;
548
432
  };
549
433
  type GetAuthToken = (context: GetAuthTokenContext) => Promise<AgentAuthToken>;
434
+ type AgentStatus = "loading" | "authenticating" | "connecting" | "ready" | "generating" | "finishing" | "reconnecting" | "failed";
435
+ type AgentError = {
436
+ category: "authentication" | "connection" | "configuration" | "chunk" | "rate_limit" | "credits" | "deleted" | "approval" | "unknown";
437
+ diagnosticId: string;
438
+ message: string;
439
+ phase: AgentStatus;
440
+ retryable: boolean;
441
+ };
550
442
  type HeroUIAgentProps = {
443
+ onError?: (error: AgentError) => void;
444
+ onStatusChange?: (status: AgentStatus) => void;
551
445
  /** Internal — for HeroUI platform development only. */
552
446
  _api?: AgentApiOverrides;
553
447
  appearance?: AgentAppearance;
@@ -562,7 +456,7 @@ type HeroUIAgentProps = {
562
456
  context?: AgentSharedContext;
563
457
  /**
564
458
  * Fetches a short-lived browser credential from the host application's
565
- * server. Never expose a HeroUI Agent API key in browser code.
459
+ * server. Never expose a workspace API key in browser code.
566
460
  */
567
461
  getAuthToken: GetAuthToken;
568
462
  /** Streaming Markdown animation and caret preferences. */
@@ -664,4 +558,4 @@ type AgentController = {
664
558
  toggle: () => void;
665
559
  };
666
560
 
667
- export { HEROUI_AGENT_ATTACHMENT_MAX_BYTES as $, AGENT_DESIGN_THEMES as A, type AgentPanelOptions as B, type AgentPermissionMode as C, type AgentPermissionOptions as D, type AgentRadius as E, type AgentResponseFeedback as F, type AgentSharedContext as G, type AgentShouldCloseOnInteractOutside as H, type AgentStartScreenOptions as I, type AgentSurfaceVariant as J, type AgentThemeColor as K, type AgentThemeColors as L, type AgentThemeOptions as M, type AgentTypography as N, type AgentViewMode as O, type ClientTool as P, type ClientToolExecutionContext as Q, type ClientToolIcon as R, type ClientToolStatus as S, DEFAULT_AGENT_PICKER_MODEL_ID as T, DEFAULT_MARKDOWN_ANIMATION as U, type GetAuthToken as V, type GetAuthTokenContext as W, HEROUI_AGENT_ATTACHMENT_ACCEPT as X, HEROUI_AGENT_ATTACHMENT_CONTENT_TYPES as Y, HEROUI_AGENT_ATTACHMENT_CONTENT_TYPE_BY_EXTENSION as Z, HEROUI_AGENT_ATTACHMENT_EXTENSION_BY_CONTENT_TYPE as _, AGENT_MODEL_IDS as a, HEROUI_AGENT_MAX_ATTACHMENTS as a0, HEROUI_AGENT_TEXT_ATTACHMENT_CONTENT_TYPES as a1, type HeroUIAgentAttachmentContentType as a2, type HeroUIAgentProps as a3, LEGACY_AGENT_MODEL_IDS as a4, type UploadAgentDataSourceInput as a5, createToolHelper as a6, getAgentModelTier as a7, isAgentModelId as a8, isHeroUIAgentAttachmentContentType as a9, parseClientToolArgs as aa, resolveAgentModelId as ab, resolveDirectToolAction as ac, resolveHeroUIAgentAttachmentContentType as ad, AGENT_MODEL_OPTIONS as b, type AgentApiOverrides as c, type AgentAppearance as d, type AgentAttachmentContentType as e, type AgentAuthToken as f, type AgentCapabilities as g, type AgentColorScheme as h, type AgentComponentExportFormat as i, type AgentComposerOptions as j, type AgentContext as k, type AgentController as l, type AgentDataSource as m, type AgentDataSourceFormat as n, type AgentDesignTheme as o, type AgentFeedbackReason as p, type AgentLauncherOptions as q, type AgentLauncherPosition as r, type AgentMarkdownAnimation as s, type AgentMarkdownAnimationOptions as t, type AgentMarkdownCaret as u, type AgentMarkdownOptions as v, type AgentMessageAction as w, type AgentModelId as x, type AgentModelOption as y, type AgentModelTier as z };
561
+ export { type AgentApiOverrides as A, type AgentResponseFeedback as B, type AgentSharedContext as C, type AgentShouldCloseOnInteractOutside as D, type AgentStartScreenOptions as E, type AgentStatus as F, type AgentSurfaceVariant as G, type AgentThemeColor as H, type AgentThemeColors as I, type AgentThemeOptions as J, type AgentTypography as K, type AgentViewMode as L, type ClientTool as M, type ClientToolExecutionContext as N, type ClientToolIcon as O, type ClientToolStatus as P, DEFAULT_MARKDOWN_ANIMATION as Q, type GetAuthToken as R, type GetAuthTokenContext as S, type HeroUIAgentProps as T, type UploadAgentDataSourceInput as U, createToolHelper as V, parseClientToolArgs as W, resolveDirectToolAction as X, type AgentAppearance as a, type AgentAttachmentContentType as b, type AgentAuthToken as c, type AgentCapabilities as d, type AgentColorScheme as e, type AgentComponentExportFormat as f, type AgentComposerOptions as g, type AgentContext as h, type AgentController as i, type AgentDataSource as j, type AgentDataSourceFormat as k, type AgentDesignTheme as l, type AgentError as m, type AgentFeedbackReason as n, type AgentLauncherOptions as o, type AgentLauncherPosition as p, type AgentMarkdownAnimation as q, type AgentMarkdownAnimationOptions as r, type AgentMarkdownCaret as s, type AgentMarkdownOptions as t, type AgentMessageAction as u, type AgentModelId as v, type AgentPanelOptions as w, type AgentPermissionMode as x, type AgentPermissionOptions as y, type AgentRadius as z };
@@ -1,4 +1,4 @@
1
- declare const HEROUI_AGENT_SDK_VERSION: "1.0.0-beta.5";
1
+ declare const HEROUI_AGENT_SDK_VERSION: "1.0.0-beta.7";
2
2
  /** Production Agent API origin used when hosts omit `_api.baseUrl` / `apiBaseUrl`. */
3
3
  declare const HEROUI_AGENT_API_BASE_URL: "https://api.heroui.pro";
4
4
 
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@heroui/agent",
3
- "version": "1.0.0-beta.5",
3
+ "version": "1.0.0-beta.7",
4
4
  "description": "Embed a hosted HeroUI Agent that turns application data into interactive UI.",
5
5
  "homepage": "https://heroui.pro/agents",
6
6
  "bugs": {
@@ -1 +0,0 @@
1
- import{b as B}from"./chunk-KGJ6UDTY.js";import{c as q,e as G,f as K,i as J,j as V,k as Y}from"./chunk-SWO2ABN5.js";function X(e){return`heroui-agent:anonymous:${e}`}function de(e){return e instanceof Error?e:new Error("Auth token request failed")}var S=class{constructor(t,n){this.agentId=t;this.getAuthToken=n}cached=null;failure=null;generation=0;pending=null;clear(){this.generation+=1,this.cached=null,this.failure=null,this.pending=null}reset(){this.clear();try{localStorage.removeItem(X(this.agentId))}catch{}}async get(){if(this.cached&&this.expiresAt(this.cached)>Date.now()+6e4)return this.cached.token;if(!this.pending&&this.failure&&Date.now()<this.failure.retryAt)throw this.failure.error;let t=this.generation,n=this.pending??this.refresh();this.pending||(this.pending=n);try{let i=await n;return t!==this.generation?this.get():(this.cached=i,this.failure=null,i.token)}catch(i){throw t===this.generation&&(this.failure={error:de(i),retryAt:Date.now()+5e3}),i}finally{this.pending===n&&(this.pending=null)}}async subjectHash(){let t=await this.get(),n=ce(t),i=typeof n.sub=="string"?n.sub:"anonymous",l=await crypto.subtle.digest("SHA-256",new TextEncoder().encode(`${this.agentId}:${i}`));return Array.from(new Uint8Array(l),u=>u.toString(16).padStart(2,"0")).join("").slice(0,24)}anonymousId(){let t=X(this.agentId);try{let n=localStorage.getItem(t);if(n)return n;let i=crypto.randomUUID();return localStorage.setItem(t,i),i}catch{return crypto.randomUUID()}}expiresAt(t){return t.expiresAt}async refresh(){let t=await this.getAuthToken({agentId:this.agentId,anonymousId:this.anonymousId()});if(!t||typeof t.token!="string"||!t.token.trim()||typeof t.expiresAt!="number"||!Number.isFinite(t.expiresAt)||t.expiresAt<=0)throw new Error("Auth token callback returned invalid data");return{expiresAt:t.expiresAt,token:t.token}}};function ce(e){try{let t=e.split(".")[1];if(!t)return{};let n=t.replace(/-/g,"+").replace(/_/g,"/"),i=n.padEnd(Math.ceil(n.length/4)*4,"=");return JSON.parse(atob(i))}catch{return{}}}function Q(e){return{bounds:null,closing:!1,dragging:!1,expanded:e.appearance?.panel?.expanded??!1,mounted:!1,open:!1,overlayOpen:!1,ready:!1,resizing:!1,sidebarWidth:null,viewMode:e.appearance?.viewMode??"floating"}}function y(e,t,n){return{background:"transparent",border:"0",clipPath:ue(e,t,n),colorScheme:"normal",height:"100dvh",inset:"0",position:"fixed",width:"100vw",zIndex:t.appearance?.zIndex??40}}function Z(e){if(!e||typeof e!="object")return null;let t=e;return typeof t.open!="boolean"||typeof t.ready!="boolean"||typeof t.expanded!="boolean"||t.viewMode!=="floating"&&t.viewMode!=="sidebar"?null:{bounds:pe(t.bounds),closing:t.closing===!0,dragging:t.dragging===!0,expanded:t.expanded,mounted:t.mounted!==!1,open:t.open,overlayOpen:t.overlayOpen===!0,ready:t.ready,resizing:t.resizing===!0,sidebarWidth:H(t.sidebarWidth)?t.sidebarWidth:null,viewMode:t.viewMode}}function ee(){let e=document.documentElement,t=document.body;return{active:!1,body:t,original:{bodyLeft:t.style.left,bodyOverflow:t.style.overflow,bodyPosition:t.style.position,bodyRight:t.style.right,bodyTop:t.style.top,bodyWidth:t.style.width,rootMarginRight:e.style.marginRight,rootOverflow:e.style.overflow,rootTransition:e.style.transition},root:e,scrollLock:null}}function x(e,t,n,i){let l=t.open||t.closing;if(!l&&!e.active)return;l&&(e.active=!0);let u=l&&(i||t.viewMode==="sidebar"&&t.expanded);ne(e,u);let a=l&&t.viewMode==="sidebar"&&!t.expanded&&!i?ge(t,n):e.original.rootMarginRight;e.root.style.transition=e.original.rootTransition,e.root.style.marginRight=a,l||(e.active=!1)}function te(e){ne(e,!1),e.root.style.marginRight=e.original.rootMarginRight,e.root.style.transition=e.original.rootTransition,e.active=!1}function ue(e,t,n){let i=e.open||e.closing;if(i&&(n||e.overlayOpen))return"inset(0px)";if(e.bounds)return`inset(${e.bounds.top}px calc(100% - ${e.bounds.right}px) calc(100% - ${e.bounds.bottom}px) ${e.bounds.left}px)`;let l=t.appearance?.launcher,u=l?.position==="bottom-left",p=(l?.offset?.x??24)+60,a=(l?.offset?.y??24)+60;if(!i)return u?`inset(calc(100% - ${a}px) calc(100% - ${p}px) 0px 0px)`:`inset(calc(100% - ${a}px) 0px 0px calc(100% - ${p}px))`;if(e.viewMode==="sidebar")return`inset(0px 0px 0px calc(100% - (${M(t.appearance?.panel?.initialWidth??420)} + 16px)))`;let h=M(t.appearance?.panel?.initialWidth??440),E=`calc(100% - min(calc(${M(t.appearance?.panel?.initialHeight??"max(420px, 56dvh)")} + 32px), 100dvh))`;return u?`inset(${E} calc(100% - min(calc(${h} + 32px), 100vw)) 0px 0px)`:`inset(${E} 0px 0px calc(100% - min(calc(${h} + 32px), 100vw)))`}function pe(e){if(!e||typeof e!="object")return null;let t=e;return!H(t.top)||!H(t.right)||!H(t.bottom)||!H(t.left)||t.right<t.left||t.bottom<t.top?null:{bottom:t.bottom,left:t.left,right:t.right,top:t.top}}function H(e){return typeof e=="number"&&Number.isFinite(e)&&e>=0&&e<=1e5}function ge(e,t){return e.sidebarWidth===null?M(t.appearance?.panel?.initialWidth??420):`${Math.round(e.sidebarWidth)}px`}function M(e){return typeof e=="number"?`${Math.round(e)}px`:e}function ne(e,t){if(t&&!e.scrollLock){e.scrollLock={x:window.scrollX,y:window.scrollY},e.root.style.overflow="hidden",e.body.style.overflow="hidden",e.body.style.position="fixed",e.body.style.top=`${-e.scrollLock.y}px`,e.body.style.left=`${-e.scrollLock.x}px`,e.body.style.right="0",e.body.style.width="100%";return}if(!t&&e.scrollLock){let{x:n,y:i}=e.scrollLock;e.root.style.overflow=e.original.rootOverflow,e.body.style.overflow=e.original.bodyOverflow,e.body.style.position=e.original.bodyPosition,e.body.style.top=e.original.bodyTop,e.body.style.left=e.original.bodyLeft,e.body.style.right=e.original.bodyRight,e.body.style.width=e.original.bodyWidth,e.scrollLock=null;try{window.scrollTo(n,i)}catch{}}}var fe=16*1024,he=64*1024;function Oe(e,t){let n=e;if(!n?.agentId||typeof n.getAuthToken!="function")throw new Error("HeroUIAgent.mount requires agentId and getAuthToken");let i=crypto.randomUUID(),l=crypto.randomUUID(),u=(n._api?.baseUrl??B).replace(/\/$/,""),p=Ie(u,n._api?.embedOrigin),a=document.createElement("iframe"),h=new Map,w=[],E=new Set,b=new Map,k=new Set,v=ee(),P=new S(n.agentId,n.getAuthToken),s=Q(n),W=null,m=!1,A=!1,I=null,U=!1,C=!1,_=new URL("/embed",p);_.searchParams.set("agentId",n.agentId),_.hash=new URLSearchParams({nonce:l,parentOrigin:window.location.origin,sessionId:i}).toString(),a.allow="microphone; clipboard-write",a.referrerPolicy="origin",a.setAttribute("sandbox","allow-downloads allow-forms allow-popups allow-popups-to-escape-sandbox allow-same-origin allow-scripts"),a.src=_.toString(),a.title="HeroUI Agent",Object.assign(a.style,y(s,n,window.innerWidth<640)),document.body.append(a);let g=(o,r,d)=>{C||a.contentWindow?.postMessage(J(i,l,o,r,d),p)},ie=(o,r)=>{let d=crypto.randomUUID();return new Promise((c,f)=>{let F=window.setTimeout(()=>{h.delete(d),f(new Error(`HeroUI Agent iframe request timed out: ${o}`))},3e4);h.set(d,{reject:f,resolve:c,timer:F}),g(o,r,d)})},$=0,N="",z=async(o,r=!1)=>{let d=++$,c=await ye(n,t);if(C||d!==$)return;let f=JSON.stringify({props:c.props,tools:c.tools});!r&&f===N||(N=f,g(o,c))},T=(o,r)=>{if(!s.mounted){w.push({name:o,payload:r}),w.length>32&&w.shift();return}g("host.command",{name:o,payload:r})},O=o=>{m=o,o||(A=!1),T(o?"show":"hide")},se=()=>{if(s.mounted)for(let o of w.splice(0))g("host.command",o)},ae=()=>{A=s.mounted&&m&&!s.closing,s={...s,bounds:null,closing:!1,mounted:!1,open:A,ready:!1},U=!1;for(let o of k)o();Object.assign(a.style,y(s,n,window.innerWidth<640)),x(v,s,n,window.innerWidth<640)},D=o=>{if(o.origin!==p||o.source!==a.contentWindow)return;let r=V(o.data);if(!(!r||r.sessionId!==i||r.nonce!==l)){if(r.type==="iframe.rpc-result"||r.type==="iframe.rpc-error"){we(r,h);return}Ae(E,r.requestId)&&le(r)}},le=async o=>{try{if(o.type==="iframe.ready"){(s.mounted||s.ready)&&ae(),await z("host.init",!0);return}if(o.type==="iframe.state"){let r=Z(o.payload);if(r){let d=s.open||s.closing,c=r;A?r.mounted?(A=!1,r.open||(g("host.command",{name:"show"}),c={...r,bounds:null,closing:!1,open:!0,sidebarWidth:r.sidebarWidth??s.sidebarWidth})):c={...r,bounds:null,closing:!1,open:!0,sidebarWidth:r.sidebarWidth??s.sidebarWidth}:r.open?m=!0:(r.closing||s.open||s.closing)&&(m=!1);let f=c.open||c.closing;f&&!d&&(W=document.activeElement),!f&&d&&W?.focus({preventScroll:!0}),s=c,f&&s.expanded?a.dataset.expanded="true":a.removeAttribute("data-expanded");for(let F of k)F();Object.assign(a.style,y(s,n,window.innerWidth<640)),x(v,s,n,window.innerWidth<640),se(),s.ready&&!U&&(U=!0,n.onReady?.())}return}if(o.type==="iframe.auth-request"){let r=await P.get(),d=await fetch(`${u}/v1/agents/${encodeURIComponent(n.agentId)}/embed-sessions`,{body:JSON.stringify({iframeOrigin:p,sessionId:i}),cache:"no-store",headers:{Authorization:`Bearer ${r}`,"Content-Type":"application/json"},method:"POST"});if(!d.ok)throw new Error("Unable to create HeroUI Agent iframe session");g("host.rpc-result",{value:await d.json()},o.requestId);return}if(o.type==="iframe.context-request"){let r=await n.context?.page?.()??{};re(r,fe,"Agent page context"),g("host.rpc-result",{value:r},o.requestId);return}if(o.type==="iframe.tool-execute"){let r=be(o.payload),d=n.tools?.find(f=>f.name===r.name);if(!d)throw new Error(`Unknown client tool: ${r.name}`);let c=b.get(r.idempotencyKey);c||(c=me(d,r,n,ie),b.set(r.idempotencyKey,c),b.size>2048&&b.delete(b.keys().next().value)),g("host.rpc-result",{value:await c},o.requestId);return}if(o.type==="iframe.feedback"){await n.onFeedback?.(o.payload);return}if(o.type==="iframe.storage"){ve(o.payload);return}if(o.type==="iframe.persistence"){let r=await import("./persistence-YI6JSYCT.js").then(({executeAgentHostPersistence:d})=>d(n.agentId,o.payload));g("host.rpc-result",{value:r},o.requestId)}}catch(r){console.error("HeroUI Agent bridge request failed",r),g("host.rpc-error",{error:r instanceof Error?r.message:"Request failed"},o.requestId)}},j=o=>{o.composedPath().includes(a)||s.open&&s.viewMode==="floating"&&(n.appearance?.shouldCloseOnInteractOutside??!0)&&O(!1)},L=()=>{s={...s,bounds:null},Object.assign(a.style,y(s,n,window.innerWidth<640)),x(v,s,n,window.innerWidth<640)},R=()=>{document.visibilityState==="visible"&&(s={...s,bounds:null},Object.assign(a.style,y(s,n,window.innerWidth<640)),x(v,s,n,window.innerWidth<640),m&&s.mounted&&g("host.command",{name:"show"}),I!==null&&window.cancelAnimationFrame(I),I=window.requestAnimationFrame(()=>{I=null,Object.assign(a.style,y(s,n,window.innerWidth<640))}))};return window.addEventListener("message",D),window.addEventListener("pointerdown",j,!0),window.addEventListener("resize",L),window.addEventListener("pageshow",R),window.visualViewport?.addEventListener("resize",L),document.addEventListener("visibilitychange",R),{destroy:()=>{C=!0,window.removeEventListener("message",D),window.removeEventListener("pointerdown",j,!0),window.removeEventListener("resize",L),window.removeEventListener("pageshow",R),window.visualViewport?.removeEventListener("resize",L),document.removeEventListener("visibilitychange",R),I!==null&&window.cancelAnimationFrame(I);for(let o of h.values())window.clearTimeout(o.timer),o.reject(new Error("HeroUI Agent iframe was removed"));h.clear(),w.length=0,k.clear(),te(v),a.remove()},hide:()=>O(!1),newConversation:o=>{m=!0,T("newConversation",{prompt:o})},preload:()=>T("preload"),get ready(){return s.ready},refreshAuth:()=>{P.clear(),T("refreshAuth")},show:()=>O(!0),shutdown:()=>{m=!1,A=!1,P.reset(),T("shutdown")},subscribe:o=>(k.add(o),()=>k.delete(o)),toggle:()=>O(!m),update:o=>{if(o.agentId!==n.agentId)throw new Error("HeroUI Agent agentId cannot change without remounting");o.getAuthToken!==n.getAuthToken&&(P=new S(o.agentId,o.getAuthToken)),n=o,Object.assign(a.style,y(s,n,window.innerWidth<640)),x(v,s,n,window.innerWidth<640),s.ready&&z("host.update")}}}async function me(e,t,n,i){let l={conversationId:t.conversationId,idempotencyKey:t.idempotencyKey,toolCallId:t.toolCallId,uploadDataSource:async p=>await i("host.upload-data-source",{toolCallId:t.toolCallId,upload:p})},u=await e.execute(q(e,t.args),n.context??{},l)??null;return re(u,he,`Client tool ${e.name} result`),u}async function ye(e,t){let{context:n,getAuthToken:i,onFeedback:l,onReady:u,tools:p,...a}=e,h=await t(p??[]);return{localStorage:oe(window.localStorage),props:JSON.parse(JSON.stringify(a)),sessionStorage:oe(window.sessionStorage),tools:h}}function we(e,t){let n=t.get(e.requestId);if(n)if(t.delete(e.requestId),window.clearTimeout(n.timer),e.type==="iframe.rpc-error"){let i=e.payload;n.reject(new Error(typeof i?.error=="string"?i.error:"Iframe request failed"))}else{let i=e.payload;n.resolve(i?.value)}}function be(e){if(!e||typeof e!="object")throw new Error("Invalid client tool request");let t=e;if(typeof t.conversationId!="string"||typeof t.idempotencyKey!="string"||typeof t.name!="string"||typeof t.toolCallId!="string")throw new Error("Invalid client tool request");return t}function re(e,t,n){if(!Y(e))throw new Error(`${n} must be JSON-serializable`);if(new TextEncoder().encode(JSON.stringify(e)).byteLength>t)throw new Error(`${n} exceeds ${Math.round(t/1024)} KiB`)}function oe(e){let t={};try{for(let n=0;n<e.length;n+=1){let i=e.key(n);i?.startsWith("heroui-agent:")&&(t[i]=e.getItem(i)??"")}}catch{}return t}function ve(e){if(!e||typeof e!="object")return;let t=e;if(typeof t.key=="string"&&!t.key.startsWith("heroui-agent:"))return;let n=t.storage==="session"?sessionStorage:localStorage;try{if(t.operation==="set"&&typeof t.key=="string"&&typeof t.value=="string")n.setItem(t.key,t.value);else if(t.operation==="remove"&&typeof t.key=="string")n.removeItem(t.key);else if(t.operation==="clear")for(let i=n.length-1;i>=0;i-=1){let l=n.key(i);l?.startsWith("heroui-agent:")&&n.removeItem(l)}}catch{}}function Ae(e,t){return e.has(t)?!1:(e.add(t),e.size>2048&&e.delete(e.values().next().value),!0)}function Ie(e,t){if(t){let n=new URL(t);if(n.protocol!=="http:"&&n.protocol!=="https:")throw new Error("HeroUI Agent embed origin must use HTTP or HTTPS");return n.origin}return/^https?:\/\/(?:localhost|127\.0\.0\.1)(?::\d+)?$/i.test(e)?"http://localhost:8793":e.includes("staging")?K:G}export{S as a,Oe as b};
@@ -1 +0,0 @@
1
- var c={animation:"fadeIn",duration:160,easing:"ease-out",sep:"word",stagger:18};var A=5,l=10485760,r={"application/epub+zip":"epub","application/json":"json","application/msword":"doc","application/pdf":"pdf","application/rtf":"rtf","application/vnd.ms-excel":"xls","application/vnd.ms-excel.sheet.binary.macroenabled.12":"xlsb","application/vnd.ms-excel.sheet.macroenabled.12":"xlsm","application/vnd.ms-powerpoint":"ppt","application/vnd.ms-powerpoint.presentation.macroenabled.12":"pptm","application/vnd.ms-word.document.macroenabled.12":"docm","application/vnd.oasis.opendocument.presentation":"odp","application/vnd.oasis.opendocument.spreadsheet":"ods","application/vnd.oasis.opendocument.text":"odt","application/vnd.openxmlformats-officedocument.presentationml.presentation":"pptx","application/vnd.openxmlformats-officedocument.spreadsheetml.sheet":"xlsx","application/vnd.openxmlformats-officedocument.wordprocessingml.document":"docx","image/gif":"gif","image/jpeg":"jpg","image/png":"png","image/webp":"webp","text/csv":"csv","text/html":"html","text/markdown":"md","text/plain":"txt","text/rtf":"rtf","text/tab-separated-values":"tsv"},a=Object.freeze(Object.keys(r)),d=a.join(","),i=Object.freeze({...Object.fromEntries(Object.entries(r).map(([e,t])=>[t,e])),htm:"text/html",xhtml:"text/html"}),p=new Set(a),m=new Set(["application/json","text/csv","text/markdown","text/plain","text/tab-separated-values"]);function s(e){return p.has(e.trim().toLowerCase())}function T(e,t){let n=e.trim().toLowerCase();if(s(n))return n;let o=t.trim().toLowerCase().match(/\.([a-z0-9]+)$/)?.[1];return o?i[o]??null:null}export{c as a,A as b,l as c,r as d,a as e,d as f,i as g,m as h,s as i,T as j};
@@ -1 +0,0 @@
1
- var t="1.0.0-beta.5",o="https://api.heroui.pro";export{t as a,o as b};
@@ -1 +0,0 @@
1
- import{b as i,k as a}from"./chunk-SWO2ABN5.js";import{z as t}from"zod";var c=["callMcpTool","composeUI","executeSandbox","generateFile","getComponentSchema","renderComponent","searchKnowledge","searchMcpTools","searchWeb"],m="mcp_",p=20,l=16*1024,d=t.object({description:t.string().trim().min(1).max(1e3),inputSchema:t.record(t.string(),t.unknown()),name:t.string().regex(/^[a-zA-Z][a-zA-Z0-9_-]{0,63}$/).refine(e=>!c.includes(e)&&!e.toLowerCase().startsWith(m),"Client tool name is reserved by the HeroUI Agent runtime"),needsApproval:t.boolean().optional()}),f=t.array(d).max(p).superRefine((e,n)=>{let o=new Set;for(let r of e)o.has(r.name)&&n.addIssue({code:"custom",message:`Duplicate client tool name: ${r.name}`}),o.add(r.name);new TextEncoder().encode(JSON.stringify(e)).byteLength>l&&n.addIssue({code:"custom",message:"Client tool manifest exceeds 16KB"})});function u(e){let n=i(e.parameters)?t.toJSONSchema(e.parameters):e.parameters;if(!a(n))throw new Error(`Client tool ${e.name} parameters must be a JSON-serializable schema`);return s(n)}function s(e){return Array.isArray(e)?e.map(s):e&&typeof e=="object"?Object.fromEntries(Object.entries(e).map(([n,o])=>[n,s(o)])):e}function E(e){return f.parse(e.map(n=>({description:n.description,inputSchema:u(n),name:n.name,...n.needsApproval?{needsApproval:!0}:{}})))}export{c as a,m as b,p as c,l as d,d as e,f,E as g};
@@ -1 +0,0 @@
1
- import{b as E}from"./chunk-6O4WPQKO.js";import{b as p}from"./chunk-SWO2ABN5.js";import{useEffect as S,useLayoutEffect as d,useMemo as x,useRef as u,useState as b,useSyncExternalStore as H}from"react";var s=new Map,m=new Set;function T(){for(let e of m)e()}function k(e){return m.add(e),()=>m.delete(e)}function l(e,o,r){let n=e?s.get(e):[...s.values()][s.size-1];if(!n){console.warn("HeroUI Agent is not mounted yet. Add <HeroUIAgent /> to your layout.");return}o==="newConversation"?n.newConversation(r):n[o]()}function D(e){let o=H(k,()=>(e?s.get(e):[...s.values()].at(-1))?.ready??!1,()=>!1);return x(()=>({hide:()=>l(e,"hide"),newConversation:r=>l(e,"newConversation",r),preload:()=>l(e,"preload"),ready:o,refreshAuth:()=>l(e,"refreshAuth"),show:()=>l(e,"show"),shutdown:()=>l(e,"shutdown"),toggle:()=>l(e,"toggle")}),[e,o])}async function G(e){let{serializeClientTools:o}=await import("./client-tools-manifest-62CRLCZY.js");return o(e).map(n=>{let i=e.find(a=>a.name===n.name);return{...n,...i?.displayName?{displayName:i.displayName}:{},...i?.icon?{icon:i.icon}:{},...i?.iconColor?{iconColor:i.iconColor}:{}}})}function R(e){let o=u(e),r=u(null),n=u(null);d(()=>{o.current=e}),n.current||(n.current={getAuthToken:t=>o.current.getAuthToken(t),onFeedback:t=>o.current.onFeedback?.(t),onReady:()=>o.current.onReady?.()},Object.defineProperties(n.current,{context:{enumerable:!0,get(){return o.current.context}},tools:{enumerable:!0,get(){return o.current.tools}}}));let i=y(e),a=n.current;for(let t of Object.keys(a))t!=="context"&&t!=="getAuthToken"&&t!=="onFeedback"&&t!=="onReady"&&t!=="tools"&&!(t in i)&&delete a[t];Object.assign(a,i,{agentId:e.agentId});let g=n.current;d(()=>{let t=E(g,G),A=t.subscribe(T);return r.current=t,s.set(e.agentId,t),T(),()=>{A(),t.destroy(),s.get(e.agentId)===t&&s.delete(e.agentId),r.current===t&&(r.current=null),T()}},[e.agentId]);let[N,h]=b("");S(()=>{let t=e.tools??[];if(!t.some(c=>p(c.parameters))){h("");return}let A=!1;return import("./client-tools-manifest-62CRLCZY.js").then(({serializeClientTools:c})=>{A||h(JSON.stringify(c(t).map(f=>({inputSchema:f.inputSchema,name:f.name}))))}),()=>{A=!0}},[e.tools]);let M=JSON.stringify({props:y(e),tools:(e.tools??[]).map(t=>({description:t.description,displayName:t.displayName,icon:t.icon,iconColor:t.iconColor,name:t.name,needsApproval:t.needsApproval===!0,parameters:p(t.parameters)?null:t.parameters})),zodToolsSchemasKey:N});return d(()=>{r.current?.update(g)},[M]),null}function y(e){let{context:o,getAuthToken:r,onFeedback:n,onReady:i,tools:a,...g}=e;return JSON.parse(JSON.stringify(g))}var _=["moonshotai/Kimi-K3","openai/gpt-5.6-luna","openai/gpt-5.6-terra","openai/gpt-5.6-sol","google/gemini-3.7-flash","anthropic/claude-sonnet-5","anthropic/claude-opus-4.8"],C={"google/gemini-3.5-flash":"google/gemini-3.7-flash","google/gemini-3.6-flash":"google/gemini-3.7-flash"};function I(e){return C[e]??e}var w="google/gemini-3.7-flash",O=[{description:"Flagship model for coding, reasoning, and knowledge work",id:"moonshotai/Kimi-K3",label:"Kimi K3",provider:"Moonshot AI",tier:"light"},{description:"Fast answers and lightweight agent workflows",id:"openai/gpt-5.6-luna",label:"GPT-5.6 Luna",provider:"OpenAI",tier:"light"},{description:"Balanced reasoning for everyday agent tasks",id:"openai/gpt-5.6-terra",label:"GPT-5.6 Terra",provider:"OpenAI",tier:"codegen"},{description:"Deep reasoning for complex, multi-step analysis",id:"openai/gpt-5.6-sol",label:"GPT-5.6 Sol",provider:"OpenAI",tier:"complex"},{description:"Fast multimodal analysis with a large context window",id:"google/gemini-3.7-flash",label:"Gemini 3.7 Flash",provider:"Google",tier:"light"},{description:"Strong agentic reasoning and polished UI decisions",id:"anthropic/claude-sonnet-5",label:"Claude Sonnet 5",provider:"Anthropic",tier:"codegen"},{description:"Highest-capability Claude for difficult research and analysis",id:"anthropic/claude-opus-4.8",label:"Claude Opus 4.8",provider:"Anthropic",tier:"complex"}],P=new Set(_);function U(e){return typeof e=="string"&&P.has(e)}function v(e){let o=e?I(e):void 0;return O.find(r=>r.id===o)?.tier??"light"}var L=["base","brutalism","glass","mouve"];export{D as a,R as b,_ as c,C as d,I as e,w as f,O as g,U as h,v as i,L as j};
@@ -1 +0,0 @@
1
- function g(){return function(t){return t}}function a(e){return!!(e&&typeof e=="object"&&typeof e.safeParse=="function")}function u(e,t){return a(e.parameters)?e.parameters.parse(t):t}function l(e,t){let n=e.get(t);return!n||n.needsApproval?null:n}var f="https://agent.heroui.pro",y="https://staging-agent.heroui.pro",T=262144,A=57671680;function m(e,t,n,o,r=crypto.randomUUID()){return{nonce:t,...o===void 0?{}:{payload:o},requestId:r,sessionId:e,type:n}}function E(e){if(!e||typeof e!="object")return null;let t=e;if(typeof t.sessionId!="string"||!i(t.sessionId)||typeof t.nonce!="string"||!i(t.nonce)||typeof t.requestId!="string"||!i(t.requestId)||typeof t.type!="string"||t.type.length===0||t.type.length>80)return null;let n=t.type==="iframe.persistence"||t.type==="host.upload-data-source"||t.type==="host.rpc-result"?57671680:262144;return c(e)>n?null:{nonce:t.nonce,...Object.hasOwn(t,"payload")?{payload:t.payload}:{},requestId:t.requestId,sessionId:t.sessionId,type:t.type}}function p(e,t=new Set){if(e===null||typeof e=="string"||typeof e=="boolean")return!0;if(typeof e=="number")return Number.isFinite(e);if(typeof e!="object"||t.has(e))return!1;t.add(e);let n=Array.isArray(e)?e.every(o=>p(o,t)):Object.getPrototypeOf(e)===Object.prototype&&Object.values(e).every(o=>p(o,t));return t.delete(e),n}function c(e){return s(e,new Set)}function s(e,t){if(e==null)return 4;if(typeof e=="string")return new TextEncoder().encode(e).byteLength+2;if(typeof e=="boolean"||typeof e=="number")return 8;if(typeof e!="object"||t.has(e))return Number.POSITIVE_INFINITY;if(e instanceof ArrayBuffer||ArrayBuffer.isView(e))return e.byteLength;if(typeof Blob<"u"&&e instanceof Blob)return e.size;t.add(e);let n=2;for(let[o,r]of Object.entries(e))if(n+=s(o,t)+s(r,t),!Number.isFinite(n))break;return t.delete(e),n}function i(e){return e.length>0&&e.length<=128&&/^[A-Za-z0-9._:-]+$/.test(e)}export{g as a,a as b,u as c,l as d,f as e,y as f,T as g,A as h,m as i,E as j,p as k,c as l};