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

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.
@@ -0,0 +1 @@
1
+ function u(){return function(t){return t}}function p(e){return!!(e&&typeof e=="object"&&typeof e.safeParse=="function")}function g(e,t){return p(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 E(e,t,n,o,r=crypto.randomUUID()){return{nonce:t,...o===void 0?{}:{payload:o},requestId:r,sessionId:e,type:n}}function m(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 a(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=r=>r===void 0||a(r,t),o=Array.isArray(e)?e.every(n):Object.getPrototypeOf(e)===Object.prototype&&Object.values(e).every(n);return t.delete(e),o}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{u as a,p as b,g as c,l as d,f as e,y as f,T as g,A as h,E as i,m as j,a as k,c as l};
@@ -0,0 +1 @@
1
+ var e={animation:"fadeIn",duration:160,easing:"ease-out",sep:"word",stagger:18};export{e as a};
@@ -1 +1 @@
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
+ import{b as i,k as a}from"./chunk-3UR3CJAJ.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};
@@ -0,0 +1 @@
1
+ import{b as B}from"./chunk-ZD5U6JIE.js";import{c as q,e as G,f as K,i as J,j as V,k as Y}from"./chunk-3UR3CJAJ.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 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:de(r),retryAt:Date.now()+5e3}),r}finally{this.pending===n&&(this.pending=null)}}async subjectHash(){let t=await this.get(),n=ce(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),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 r=crypto.randomUUID();return localStorage.setItem(t,r),r}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,"/"),r=n.padEnd(Math.ceil(n.length/4)*4,"=");return JSON.parse(atob(r))}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,r){let l=t.open||t.closing;if(!l&&!e.active)return;l&&(e.active=!0);let u=l&&(r||t.viewMode==="sidebar"&&t.expanded);ne(e,u);let a=l&&t.viewMode==="sidebar"&&!t.expanded&&!r?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 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,u=l?.position==="bottom-left",p=(l?.offset?.x??24)+60,a=(l?.offset?.y??24)+60;if(!r)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: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 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 r=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: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=_.toString(),a.title="HeroUI Agent",Object.assign(a.style,y(s,n,window.innerWidth<640)),document.body.append(a);let g=(o,i,d)=>{C||a.contentWindow?.postMessage(J(r,l,o,i,d),p)},ie=(o,i)=>{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,i,d)})},$=0,N="",z=async(o,i=!1)=>{let d=++$,c=await ye(n,t);if(C||d!==$)return;let f=JSON.stringify({props:c.props,tools:c.tools});!i&&f===N||(N=f,g(o,c))},T=(o,i)=>{if(!s.mounted){w.push({name:o,payload:i}),w.length>32&&w.shift();return}g("host.command",{name:o,payload:i})},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)},j=o=>{if(o.origin!==p||o.source!==a.contentWindow)return;let i=V(o.data);if(!(!i||i.sessionId!==r||i.nonce!==l)){if(i.type==="iframe.rpc-result"||i.type==="iframe.rpc-error"){we(i,h);return}Ae(E,i.requestId)&&le(i)}},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 i=Z(o.payload);if(i){let d=s.open||s.closing,c=i;A?i.mounted?(A=!1,i.open||(g("host.command",{name:"show"}),c={...i,bounds:null,closing:!1,open:!0,sidebarWidth:i.sidebarWidth??s.sidebarWidth})):c={...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 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 i=await P.get(),d=await fetch(`${u}/v1/agents/${encodeURIComponent(n.agentId)}/embed-sessions`,{body:JSON.stringify({iframeOrigin:p,sessionId:r}),cache:"no-store",headers:{Authorization:`Bearer ${i}`,"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 i=re(await n.context?.page?.()??{},fe,"Agent page context");g("host.rpc-result",{value:i},o.requestId);return}if(o.type==="iframe.tool-execute"){let i=be(o.payload),d=n.tools?.find(f=>f.name===i.name);if(!d)throw new Error(`Unknown client tool: ${i.name}`);let c=b.get(i.idempotencyKey);c||(c=me(d,i,n,ie),b.set(i.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 i=await import("./persistence-YI6JSYCT.js").then(({executeAgentHostPersistence:d})=>d(n.agentId,o.payload));g("host.rpc-result",{value:i},o.requestId)}}catch(i){console.error("HeroUI Agent bridge request failed",i),g("host.rpc-error",{error:i instanceof Error?i.message:"Request failed"},o.requestId)}},D=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",j),window.addEventListener("pointerdown",D,!0),window.addEventListener("resize",L),window.addEventListener("pageshow",R),window.visualViewport?.addEventListener("resize",L),document.addEventListener("visibilitychange",R),{destroy:()=>{C=!0,window.removeEventListener("message",j),window.removeEventListener("pointerdown",D,!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,r){let l={conversationId:t.conversationId,idempotencyKey:t.idempotencyKey,toolCallId:t.toolCallId,uploadDataSource:async p=>await r("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`)}async function ye(e,t){let{context:n,getAuthToken:r,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 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 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`);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 oe(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 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 r=n.length-1;r>=0;r-=1){let l=n.key(r);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};
@@ -0,0 +1 @@
1
+ import{b as C}from"./chunk-L5DXTMC2.js";import{b as A}from"./chunk-3UR3CJAJ.js";import{useEffect as k,useLayoutEffect as d,useMemo as x,useRef as p,useState as O,useSyncExternalStore as w}from"react";var i=new Map,f=new Set;function m(){for(let e of f)e()}function H(e){return f.add(e),()=>f.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 P(e){let{serializeClientTools:n}=await import("./client-tools-manifest-2T23ADUM.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 I(e){let n=p(e),r=p(null),o=p(null);d(()=>{n.current=e}),o.current||(o.current={getAuthToken:t=>n.current.getAuthToken(t),onFeedback:t=>n.current.onFeedback?.(t),onReady:()=>n.current.onReady?.()},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!=="onFeedback"&&t!=="onReady"&&t!=="tools"&&!(t in s)&&delete l[t];Object.assign(l,s,{agentId:e.agentId});let c=o.current;d(()=>{let t=C(c,P),u=t.subscribe(m);return r.current=t,i.set(e.agentId,t),m(),()=>{u(),t.destroy(),i.get(e.agentId)===t&&i.delete(e.agentId),r.current===t&&(r.current=null),m()}},[e.agentId]);let[S,y]=O("");k(()=>{let t=e.tools??[];if(!t.some(g=>A(g.parameters))){y("");return}let u=!1;return import("./client-tools-manifest-2T23ADUM.js").then(({serializeClientTools:g})=>{u||y(JSON.stringify(g(t).map(h=>({inputSchema:h.inputSchema,name:h.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:A(t.parameters)?null:t.parameters})),zodToolsSchemasKey:S});return d(()=>{r.current?.update(c)},[b]),null}function T(e){let{context:n,getAuthToken:r,onFeedback:o,onReady:s,tools:l,...c}=e;return JSON.parse(JSON.stringify(c))}export{R as a,I as b};
@@ -0,0 +1 @@
1
+ var t="1.0.0-beta.6",o="https://api.heroui.pro";export{t as a,o as b};
@@ -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-BYV3XUCN.js";import"./chunk-3UR3CJAJ.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 { R as HeroUIAgentProps, i as AgentController } from './types-BeXKAj2P.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 AgentFeedbackReason, n as AgentLauncherOptions, o as AgentLauncherPosition, p as AgentMarkdownAnimation, q as AgentMarkdownAnimationOptions, r as AgentMarkdownCaret, s as AgentMarkdownOptions, t as AgentMessageAction, u as AgentModelId, v as AgentPanelOptions, w as AgentPermissionMode, x as AgentPermissionOptions, y as AgentRadius, z as AgentResponseFeedback, B as AgentSharedContext, C as AgentShouldCloseOnInteractOutside, D as AgentStartScreenOptions, E as AgentSurfaceVariant, F as AgentThemeColor, G as AgentThemeColors, H as AgentThemeOptions, I as AgentTypography, J as AgentViewMode, K as ClientTool, L as ClientToolExecutionContext, M as ClientToolIcon, N as ClientToolStatus, O as DEFAULT_MARKDOWN_ANIMATION, P as GetAuthToken, Q as GetAuthTokenContext, U as UploadAgentDataSourceInput, S as createToolHelper } from './types-BeXKAj2P.js';
3
+ export { H as HEROUI_AGENT_API_BASE_URL, a as HEROUI_AGENT_SDK_VERSION } from './version-BOWn57s2.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-LMNV4H5B.js";import"./chunk-L5DXTMC2.js";import{a as f}from"./chunk-AR424OVX.js";import{a as b,b as c}from"./chunk-ZD5U6JIE.js";import{a}from"./chunk-3UR3CJAJ.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,5 +1,5 @@
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 { M as ClientToolIcon, i as AgentController, R as HeroUIAgentProps, K as ClientTool, P as GetAuthToken } from '../types-BeXKAj2P.js';
2
+ export { T as parseClientToolArgs, V as resolveDirectToolAction } from '../types-BeXKAj2P.js';
3
3
  import 'react';
4
4
 
5
5
  declare const HEROUI_AGENT_HOSTED_ORIGIN: "https://agent.heroui.pro";
@@ -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 t,b as r}from"../chunk-L5DXTMC2.js";import"../chunk-ZD5U6JIE.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-3UR3CJAJ.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,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-BOWn57s2.js';
4
2
  import { z } from 'zod';
3
+ import { K as ClientTool } from '../types-BeXKAj2P.js';
4
+ export { O as DEFAULT_MARKDOWN_ANIMATION } from '../types-BeXKAj2P.js';
5
5
  import 'react';
6
6
 
7
7
  declare const agentIdentityIdSchema: z.ZodString;
@@ -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-ZD5U6JIE.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-BYV3XUCN.js";import"../chunk-3UR3CJAJ.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 AgentFeedbackReason, n as AgentLauncherOptions, o as AgentLauncherPosition, p as AgentMarkdownAnimation, q as AgentMarkdownAnimationOptions, r as AgentMarkdownCaret, s as AgentMarkdownOptions, t as AgentMessageAction, u as AgentModelId, v as AgentPanelOptions, w as AgentPermissionMode, x as AgentPermissionOptions, y as AgentRadius, z as AgentResponseFeedback, B as AgentSharedContext, C as AgentShouldCloseOnInteractOutside, D as AgentStartScreenOptions, E as AgentSurfaceVariant, F as AgentThemeColor, G as AgentThemeColors, H as AgentThemeOptions, I as AgentTypography, J as AgentViewMode, K as ClientTool, L as ClientToolExecutionContext, M as ClientToolIcon, N as ClientToolStatus, O as DEFAULT_MARKDOWN_ANIMATION, P as GetAuthToken, Q as GetAuthTokenContext, R as HeroUIAgentProps, U as UploadAgentDataSourceInput, S as createToolHelper } from './types-BeXKAj2P.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-BOWn57s2.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-LMNV4H5B.js";import"./chunk-L5DXTMC2.js";import{a as p}from"./chunk-AR424OVX.js";import{a as r,b as e}from"./chunk-ZD5U6JIE.js";import{a as o}from"./chunk-3UR3CJAJ.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};
@@ -80,137 +80,6 @@ declare function parseClientToolArgs(tool: ClientTool, input: unknown): unknown;
80
80
  */
81
81
  declare function resolveDirectToolAction(tools: ReadonlyMap<string, ClientTool>, toolName: string): ClientTool | null;
82
82
 
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
83
  /**
215
84
  * Light/dark color scheme selection for the embed. `"system"` follows the
216
85
  * OS preference and updates live when it changes.
@@ -258,13 +127,14 @@ type AgentTypography = {
258
127
  fontFamily?: string;
259
128
  };
260
129
  /**
261
- * HeroUI Pro theme variant applied to the agent surface.
130
+ * HeroUI Pro theme variant applied to the agent surface, e.g. `"base"`,
131
+ * `"brutalism"`, `"glass"`, or `"mouve"`.
262
132
  *
263
- * Hosted Agent deployments include all supported variants; the selected one
264
- * is activated inside the iframe.
133
+ * Hosted Agent deployments own the list of supported variants and activate the
134
+ * selected one inside the iframe; unknown values fall back to `"base"`, so new
135
+ * variants never require an SDK update.
265
136
  */
266
- type AgentDesignTheme = "base" | "brutalism" | "glass" | "mouve";
267
- declare const AGENT_DESIGN_THEMES: readonly AgentDesignTheme[];
137
+ type AgentDesignTheme = string;
268
138
  /**
269
139
  * Intentionally small theme surface: one color scheme, one Pro variant, four
270
140
  * radius presets, seven color tokens, and basic typography. No named themes,
@@ -286,8 +156,20 @@ type AgentThemeOptions = {
286
156
 
287
157
  type AgentComponentExportFormat = "csv" | "png" | "svg";
288
158
  type AgentPermissionMode = "ask" | "auto" | "full";
289
- /** MIME type accepted by the hosted HeroUI Agent attachment pipeline. */
290
- type AgentAttachmentContentType = HeroUIAgentAttachmentContentType;
159
+ /**
160
+ * MIME type accepted by the hosted HeroUI Agent attachment pipeline, e.g.
161
+ * `"application/pdf"` or `"text/csv"`. The hosted Agent owns the supported
162
+ * list and ignores unknown types, so new formats never require an SDK update.
163
+ * See https://heroui.pro/docs/agents/api-reference/configuration.
164
+ */
165
+ type AgentAttachmentContentType = string;
166
+ /**
167
+ * Model id from the hosted HeroUI Agent catalog, e.g. `"google/gemini-3.7-flash"`.
168
+ * The hosted Agent owns the catalog: retired ids resolve to their replacement
169
+ * and unknown ids fall back to the default model, so new models never require
170
+ * an SDK update. See https://heroui.pro/docs/agents/api-reference/models.
171
+ */
172
+ type AgentModelId = string;
291
173
  type AgentMessageAction = "copy" | "feedback" | "retry";
292
174
  type AgentFeedbackReason = "did_not_follow_instructions" | "incomplete" | "incorrect" | "not_relevant" | "other" | "unclear";
293
175
  type AgentResponseFeedback = {
@@ -664,4 +546,4 @@ type AgentController = {
664
546
  toggle: () => void;
665
547
  };
666
548
 
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 };
549
+ export { type AgentApiOverrides as A, type AgentSharedContext as B, type AgentShouldCloseOnInteractOutside as C, type AgentStartScreenOptions as D, type AgentSurfaceVariant as E, type AgentThemeColor as F, type AgentThemeColors as G, type AgentThemeOptions as H, type AgentTypography as I, type AgentViewMode as J, type ClientTool as K, type ClientToolExecutionContext as L, type ClientToolIcon as M, type ClientToolStatus as N, DEFAULT_MARKDOWN_ANIMATION as O, type GetAuthToken as P, type GetAuthTokenContext as Q, type HeroUIAgentProps as R, createToolHelper as S, parseClientToolArgs as T, type UploadAgentDataSourceInput as U, resolveDirectToolAction as V, 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 AgentFeedbackReason as m, type AgentLauncherOptions as n, type AgentLauncherPosition as o, type AgentMarkdownAnimation as p, type AgentMarkdownAnimationOptions as q, type AgentMarkdownCaret as r, type AgentMarkdownOptions as s, type AgentMessageAction as t, type AgentModelId as u, type AgentPanelOptions as v, type AgentPermissionMode as w, type AgentPermissionOptions as x, type AgentRadius as y, type AgentResponseFeedback 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.6";
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.6",
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 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};