@artooi/ag-ui-web-component 0.8.0 → 0.8.1
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/CHANGELOG.md +12 -1
- package/dist/ag-ui-web-component.bundle.js +15 -1
- package/dist/ag-ui-web-component.bundle.js.map +2 -2
- package/dist/index.js +15 -1
- package/dist/index.js.map +2 -2
- package/dist/ui/styles.d.ts +1 -1
- package/dist/ui/styles.d.ts.map +1 -1
- package/package.json +1 -1
- package/src/ui/styles.ts +14 -0
- package/src/version.ts +1 -1
package/CHANGELOG.md
CHANGED
|
@@ -7,6 +7,16 @@ and this project adheres to [Semantic Versioning](https://semver.org/spec/v2.0.0
|
|
|
7
7
|
|
|
8
8
|
## [Unreleased]
|
|
9
9
|
|
|
10
|
+
## [0.8.1] — 2026-06-30
|
|
11
|
+
|
|
12
|
+
### Fixed
|
|
13
|
+
|
|
14
|
+
- **Page-mode column alignment.** In `placement="page"`, the rows between the
|
|
15
|
+
message list and the composer — skill chips, the `/`-command palette, the
|
|
16
|
+
missing-placeholder hint, and the upload tray — stayed left-anchored while
|
|
17
|
+
`.messages` and `.input-row` centred on `--ag-ui-content-max-width`. They now
|
|
18
|
+
share the same column gutter, so the whole page reads as one centred column.
|
|
19
|
+
|
|
10
20
|
## [0.8.0] — 2026-06-30
|
|
11
21
|
|
|
12
22
|
### Added
|
|
@@ -367,7 +377,8 @@ and this project adheres to [Semantic Versioning](https://semver.org/spec/v2.0.0
|
|
|
367
377
|
### Notes
|
|
368
378
|
- First release — exercising the automated npm OIDC publish pipeline end-to-end.
|
|
369
379
|
|
|
370
|
-
[Unreleased]: https://github.com/Artui/ag-ui-web-component/compare/v0.8.
|
|
380
|
+
[Unreleased]: https://github.com/Artui/ag-ui-web-component/compare/v0.8.1...HEAD
|
|
381
|
+
[0.8.1]: https://github.com/Artui/ag-ui-web-component/compare/v0.8.0...v0.8.1
|
|
371
382
|
[0.8.0]: https://github.com/Artui/ag-ui-web-component/compare/v0.7.0...v0.8.0
|
|
372
383
|
[0.7.0]: https://github.com/Artui/ag-ui-web-component/compare/v0.6.0...v0.7.0
|
|
373
384
|
[0.6.0]: https://github.com/Artui/ag-ui-web-component/compare/v0.5.0...v0.6.0
|
|
@@ -239,6 +239,20 @@ Please report this to https://github.com/markedjs/marked.`,t){let r="<p>An error
|
|
|
239
239
|
padding-inline: max(12px, calc((100% - var(--ag-ui-content-max-width)) / 2));
|
|
240
240
|
}
|
|
241
241
|
|
|
242
|
+
/* The rows between the message list and the composer (skill chips, the
|
|
243
|
+
/-command palette, the missing-placeholder hint, the upload tray) line up
|
|
244
|
+
with the column too \u2014 chips are padding-based, the palette/hint/tray are
|
|
245
|
+
margin-based, so each gets its own inline axis nudged by the same gutter. */
|
|
246
|
+
:host([placement="page"]) .skill-chips,
|
|
247
|
+
:host([placement="page"]) .attachment-tray {
|
|
248
|
+
padding-inline: max(12px, calc((100% - var(--ag-ui-content-max-width)) / 2));
|
|
249
|
+
}
|
|
250
|
+
|
|
251
|
+
:host([placement="page"]) .skill-palette,
|
|
252
|
+
:host([placement="page"]) .skill-hint {
|
|
253
|
+
margin-inline: max(12px, calc((100% - var(--ag-ui-content-max-width)) / 2));
|
|
254
|
+
}
|
|
255
|
+
|
|
242
256
|
/* In the reading column the assistant well uses the full width; the user
|
|
243
257
|
message stays a right-aligned pill (its default align-self + max-width). */
|
|
244
258
|
:host([placement="page"]) .message--assistant {
|
|
@@ -1234,7 +1248,7 @@ Please report this to https://github.com/markedjs/marked.`,t){let r="<p>An error
|
|
|
1234
1248
|
|
|
1235
1249
|
${n}`):(r.textContent=gg(this.#o)[e],o.textContent=n),r.addEventListener("click",()=>{let i=o.hidden;o.hidden=!i,r.setAttribute("aria-expanded",String(i))}),this.element.append(r,o)}};var li=class extends Error{constructor(e){super(e),this.name="ConnectionLostError"}},ir=class{#t;#e;#n;#o;#l;#i;#s;#r=!1;constructor(e){this.#t=e.agent,this.#e=e.handlers,this.#n=e.getTools??(()=>[]),this.#o=e.getContext??(()=>[]),this.#l=e.executeTool??null,this.#i=e.onPersist??(()=>{}),this.#s=e.connectionLostMessage??"Connection lost"}get running(){return this.#t.isRunning}get messages(){return this.#t.messages}async send(e,n=[]){let r={id:Re(),role:"user",content:e};n.length>0&&(r.attachments=n),this.#t.addMessage(r),this.#i(this.#t.messages),await this.#a()}async resume(){await this.#a()}addToolResult(e,n){this.#t.addMessage({id:Re(),role:"tool",content:n,toolCallId:e}),this.#i(this.#t.messages)}cancel(){this.#r=!0,this.#t.abortRun()}async#a(){this.#r=!1;try{await this.#h(),this.#r&&this.#c()}catch(e){this.#r||vg(e)?this.#c():this.#e.onError(e instanceof Error?e.message:String(e))}finally{this.#e.onSettled()}}#c(){this.#i(this.#t.messages),this.#e.onCancelled()}async#h(){for(let e=0;e<Ii;e+=1){if(this.#r)return;let n=[],r={terminal:!1};if(await this.#t.runAgent({tools:this.#n(),context:this.#o()},this.#d(n,r)),this.#i(this.#t.messages),this.#r)return;if(!r.terminal)throw new li(this.#s);if(this.#l===null||n.length===0)return;let o=!1;for(let i of n){let s=await this.#l(i);if(s!==null){if(s.halt===!0)return;this.#t.addMessage({id:Re(),role:"tool",content:s.content,toolCallId:i.id}),this.#i(this.#t.messages),o=!0}}if(!o)return}}#d(e,n){let r=this.#e;return{onRunInitialized(){r.onRunStart()},onTextMessageContentEvent({textMessageBuffer:o}){r.onTextDelta(o)},onTextMessageEndEvent({textMessageBuffer:o}){r.onTextEnd(o)},onToolCallEndEvent({event:o,toolCallName:i,toolCallArgs:s}){let a={id:o.toolCallId,name:i,args:s};e.push(a),r.onToolCall(a)},onToolCallResultEvent({event:o}){r.onToolResult(o.toolCallId,o.content)},onRunErrorEvent({event:o}){n.terminal=!0,r.onError(o.message)},onRunFinalized(){n.terminal=!0,r.onRunEnd()}}}};function vg(t){return t instanceof Error&&t.name==="AbortError"}function oa(t){let e=t.attachments;return Array.isArray(e)?e:[]}var sr="ag-ui-chat:thread",ia="ag-ui-chat:threads",sa="ag-ui-chat:messages:",aa="ag-ui-chat:checkpoint:",yg=60,bg=100,xg="New conversation",Jt=class{threadId(){let e=sessionStorage.getItem(sr);if(e!==null)return e;let n=Re();return sessionStorage.setItem(sr,n),n}loadMessages(e){return Promise.resolve(this.#o(sa+e))}saveMessages(e,n){sessionStorage.setItem(sa+e,JSON.stringify(n)),this.#t(e,n)}loadCheckpoint(e){return this.#o(aa+e)}saveCheckpoint(e,n){let r=aa+e;if(n===null){sessionStorage.removeItem(r);return}sessionStorage.setItem(r,JSON.stringify(n))}clear(e){sessionStorage.removeItem(sa+e),sessionStorage.removeItem(aa+e),this.#n(this.#e().filter(n=>n.threadId!==e)),sessionStorage.getItem(sr)===e&&sessionStorage.removeItem(sr)}listThreads(){let e=this.#e().sort((n,r)=>r.updatedAt-n.updatedAt).map(({threadId:n,title:r,updatedAt:o,preview:i})=>({threadId:n,title:r,updatedAt:o,preview:i}));return Promise.resolve(e)}setActiveThread(e){sessionStorage.setItem(sr,e)}renameThread(e,n){let r=this.#e(),o=r.find(i=>i.threadId===e);o!==void 0&&(o.title=n,o.titleCustom=!0,this.#n(r))}#t(e,n){let r=this.#e(),o=r.find(a=>a.threadId===e),i=Eg(n),s=Date.now();o===void 0?r.push({threadId:e,title:gu(n),titleCustom:!1,preview:i,updatedAt:s}):(o.preview=i,o.updatedAt=s,o.titleCustom||(o.title=gu(n))),this.#n(r)}#e(){return this.#o(ia)??[]}#n(e){if(e.length===0){sessionStorage.removeItem(ia);return}sessionStorage.setItem(ia,JSON.stringify(e))}#o(e){let n=sessionStorage.getItem(e);if(n===null)return null;try{return JSON.parse(n)}catch{return null}}};function gu(t){for(let e of t)if(e.role==="user"){let n=vu(e.content);if(n!=="")return yu(n,yg)}return xg}function Eg(t){for(let e of[...t].reverse()){let n=vu(e.content);if(n!=="")return yu(n,bg)}return""}function vu(t){return typeof t=="string"?t.replace(/\s+/g," ").trim():""}function yu(t,e){return t.length<=e?t:`${t.slice(0,e-1).trimEnd()}\u2026`}function la(t){return new kc({url:t.endpoint,headers:t.headers??{},fetch:(e,n)=>{let r=t.getHeaders?.();if(r===void 0)return fetch(e,n);let o=new Headers(n?.headers);for(let[i,s]of Object.entries(r))o.set(i,s);return fetch(e,{...n,headers:o})},...t.threadId!==void 0?{threadId:t.threadId}:{},...t.initialMessages!==void 0?{initialMessages:[...t.initialMessages]}:{}})}var ar=class{#t;#e;#n;#o=new Set;#l=new Map;constructor(e,n=()=>({}),r=new Jt){this.#t=e.endsWith("/")?e:`${e}/`,this.#e=n,this.#n=r}threadId(){return this.#n.threadId()}setActiveThread(e){this.#n.setActiveThread(e)}saveMessages(e,n){this.#n.saveMessages(e,n)}loadCheckpoint(e){return this.#n.loadCheckpoint(e)}saveCheckpoint(e,n){this.#n.saveCheckpoint(e,n)}renameThread(e,n){this.#n.renameThread(e,n),this.#l.set(e,n),this.#a(e,"PATCH",{title:n})}clear(e){this.#n.clear(e),this.#o.add(e),this.#a(e,"DELETE")}async listThreads(){let e=await this.#i();return e===null?this.#n.listThreads():e.filter(n=>!this.#o.has(n.thread_id)).map(n=>this.#s(n))}async loadMessages(e){let n=await this.#r(this.#t+encodeURIComponent(e)+"/");return n===null||!n.ok?this.#n.loadMessages(e):(await n.json()).messages??null}async#i(){let e=await this.#r(this.#t);return e===null||!e.ok?null:(await e.json()).threads??[]}#s(e){return{threadId:e.thread_id,title:this.#l.get(e.thread_id)??e.title,updatedAt:e.updated_at===null?0:Date.parse(e.updated_at),preview:e.preview}}async#r(e){try{return await fetch(e,{headers:this.#e()})}catch{return null}}async#a(e,n,r){let o=this.#e();try{await fetch(this.#t+encodeURIComponent(e)+"/",{method:n,headers:r===void 0?o:{...o,"content-type":"application/json"},body:r===void 0?null:JSON.stringify(r)})}catch{}}};function ca(t,e){return new Promise((n,r)=>{let o=new FormData;o.append("file",t);let i=new XMLHttpRequest;i.open("POST",e.url);for(let[l,c]of Object.entries(e.headers??{}))i.setRequestHeader(l,c);let s=e.onProgress;s!==void 0&&i.upload.addEventListener("progress",l=>{l.lengthComputable&&s(l.total===0?0:l.loaded/l.total)}),i.addEventListener("load",()=>{if(i.status>=200&&i.status<300)try{n(Tg(JSON.parse(i.responseText)))}catch{r(new Error("upload returned an unreadable response"))}else r(new Error(Sg(i)))}),i.addEventListener("error",()=>r(new Error("upload failed"))),i.addEventListener("abort",()=>r(new Error("upload cancelled")));let a=e.signal;a!==void 0&&a.addEventListener("abort",()=>i.abort()),i.send(o)})}function Tg(t){if(typeof t!="object"||t===null)throw new Error("not an object");let e=t,n=e.id,r=e.name,o=e.mime,i=e.size,s=e.url;if(typeof n!="string"||typeof r!="string"||typeof o!="string"||typeof i!="number")throw new Error("missing fields");return typeof s=="string"?{id:n,name:r,mime:o,size:i,url:s}:{id:n,name:r,mime:o,size:i}}function Sg(t){try{let e=JSON.parse(t.responseText);if(typeof e.error=="string")return e.error}catch{}return`upload failed (${t.status})`}var bu="ag-ui-chat:collapsed",lr=class extends HTMLElement{agentFactory=la;headers={};allowImages=!1;autoConfirm=!1;confirmPredicate=null;getTools=()=>[...this.#V().map(e=>({name:e.name,description:e.description,parameters:e.parameters})),...this.#n.tools()];getContext=()=>[...zi(this.getPageMap,this.autoInjectPageMap),...this.#le()];routeMap=[];navigate=null;getPageMap=null;autoInjectPageMap=!0;conversationStore=new Jt;uploadHandler=null;navigationResult=()=>({navigated:!0,url:window.location.href});skillContext=()=>({});toolSummaries={};strings={};resolvePageTarget=e=>document.querySelector(e);#t={};#e=Ie;#n=new Pn;#o=new Map;#l=new Set;#i;#s;#r;#a;#c;#h;#d;#S;#y;#p;#f;#C;#g;#x;#E=null;#_=[];#w=null;#L=!1;#N=null;#m=null;#P=0;#R=null;#v=null;#u="";#D=[];#z=[];#B=[];#j=[];constructor(){super(),this.#i=this.attachShadow({mode:"open"}),this.#s=document.createElement("div"),this.#r=document.createElement("div"),this.#a=document.createElement("textarea"),this.#c=document.createElement("button"),this.#h=document.createElement("span"),this.#y=document.createElement("div"),this.#p=document.createElement("button"),this.#f=document.createElement("input"),this.#C=document.createElement("div"),this.#g=document.createElement("button"),this.#x=document.createElement("div"),this.#d=new si(e=>this.#he(e)),this.#S=new ai({onSelect:e=>{this.#me(e)},onNew:()=>{this.newChat(),this.#O()},onRename:(e,n)=>{this.conversationStore.renameThread(e,n),this.#O()},onDelete:e=>{this.#ge(e)}})}static get observedAttributes(){return["title-text"]}attributeChangedCallback(e,n,r){this.#h.textContent=r??this.#e.title}registerTool(e){this.#n.register(e)}registerStateHook(e){for(let n of Vi(e))this.#n.register(n)}#Q(){return this.routeMap.length===0?[]:ji(()=>this.routeMap,()=>this.navigate)}#ee(){let e=this.getPageMap;return e===null?[]:[{name:"read_page",description:"Read the current page's structure (fields, buttons, route). Call after acting to observe the result within the same turn.",parameters:{type:"object",properties:{},required:[],[Ce]:"Read the page"},handler:()=>e()}]}#te(){let e=this.getAttribute("data-page-actions");if(e===null)return[];let n=new Set(e.split(",").map(r=>r.trim()).filter(r=>r!==""));return $i(n,r=>this.resolvePageTarget(r))}#V(){return[...this.#Q(),...this.#ee(),...this.#te()]}#W(e){let n=this.#V().find(r=>r.name===e);return n!==void 0?n:this.#n.has(e)?this.#n.get(e):null}get endpoint(){return this.getAttribute("endpoint")??""}set endpoint(e){this.setAttribute("endpoint",e)}get toolDisplay(){let e=this.getAttribute("data-tool-display");return e===$e.INLINE||e===$e.MINIMAL||e===$e.COMPACT?e:$e.FULL}set toolDisplay(e){this.setAttribute("data-tool-display",e)}connectedCallback(){this.#e=Ps({...this.#ne(),...this.strings}),this.#xe(),this.#S.setStrings(this.#e),sessionStorage.getItem(bu)==="1"&&this.setAttribute("collapsed",""),this.#Y(),this.#de(),this.#ue(),this.#ce(),this.#re(),this.#u=this.conversationStore.threadId(),this.#X()}#ne(){let e=this.getAttribute("data-strings");if(e===null)return{};try{let n=JSON.parse(e);if(typeof n=="object"&&n!==null)return n}catch{}return{}}#re(){let e=this.getAttribute("data-attachments-url"),n=this.uploadHandler??this.#oe(e);if(n===null)return;let r=this.getAttribute("data-attachment-accept")??"";this.#E=new qo({upload:n,maxBytes:this.#ie(),accept:r,strings:this.#e}),this.#C.appendChild(this.#E.element),this.#f.accept=r,this.#p.hidden=!1,this.#ae()}#oe(e){return e===null?null:(n,r)=>ca(n,{url:e,headers:this.headers,onProgress:r})}#ie(){let e=this.getAttribute("data-attachment-max-bytes");if(e===null)return Ci;let n=Number.parseInt(e,10);return Number.isFinite(n)&&n>=0?n:Ci}#se(){let e=this.#f.files;if(e!==null)for(let n of Array.from(e))this.#E?.add(n);this.#f.value=""}#ae(){this.#s.addEventListener("dragover",e=>{e.preventDefault(),this.#s.classList.add("chat--dragover")}),this.#s.addEventListener("dragleave",()=>{this.#s.classList.remove("chat--dragover")}),this.#s.addEventListener("drop",e=>{e.preventDefault(),this.#s.classList.remove("chat--dragover");let n=e.dataTransfer?.files;if(n!==void 0)for(let r of Array.from(n))this.#E?.add(r)})}#le(){return this.#_.length===0?[]:[{description:"Files the user attached to this message",value:`${this.#_.map(n=>`- ${n.name} (id: ${n.id}, ${n.mime||"unknown type"}, ${n.size} bytes)`).join(`
|
|
1236
1250
|
`)}
|
|
1237
|
-
Use the read_attachment tool with an id to read a file's contents.`}]}#ce(){let e=this.getAttribute("data-threads-url");e!==null&&(this.conversationStore=new ar(e,()=>this.headers,this.conversationStore))}async#ue(){let e=this.getAttribute("data-tools-url");if(e!==null)try{let n=await fetch(e,{headers:this.headers});this.#t=Bi(await n.json())}catch{}}setSkills(e){this.#j=e,this.#U()}#de(){this.#d.enableChips(this.getAttribute("data-prompt-chips")==="true"),this.#d.enableSlash(this.getAttribute("data-slash-commands")==="true"),this.#B=this.#pe(),this.#U(),this.#fe()}#pe(){let e=this.getAttribute("data-skills");if(e===null)return[];try{return Ni(JSON.parse(e))}catch{return[]}}async#fe(){let e=this.getAttribute("data-skills-url");if(e!==null)try{let n=await fetch(e,{headers:this.headers});this.#z=Ni(await n.json()),this.#U()}catch{}}#U(){let e=new Map;for(let n of[...this.#z,...this.#B,...this.#j])e.set(n.name,n);this.#d.setSkills([...e.values()])}#he(e){let{text:n,missing:r}=La(e.prompt,this.skillContext());if(r.length>0){this.#y.textContent=this.#e.skillNeeds.replace("{title}",e.title).replace("{fields}",r.join(", ")),this.#y.hidden=!1;return}this.#y.hidden=!0,this.#a.value=n,e.sendImmediately===!0?this.#F():this.#a.focus()}get collapsed(){return this.hasAttribute("collapsed")}set collapsed(e){this.setCollapsed(e)}setCollapsed(e){e?this.setAttribute("collapsed",""):this.removeAttribute("collapsed"),sessionStorage.setItem(bu,e?"1":"0"),this.#Y(),this.dispatchEvent(new CustomEvent(Ai,{detail:{collapsed:e},bubbles:!0,composed:!0}))}toggleCollapsed(){this.setCollapsed(!this.collapsed)}newChat(){this.#k(),this.conversationStore.clear(this.#u),this.#G(),this.#u=this.conversationStore.threadId(),this.#I(!1)}#G(){this.#w=null,this.#m=null,this.#v=null,this.#T(),this.#o.clear(),this.#l.clear(),this.#D=[],this.#_=[],this.#E?.clear(),this.#r.replaceChildren(this.#x),this.#b()}async#me(e){e!==this.#u&&(this.#k(),this.#G(),this.conversationStore.setActiveThread(e),this.#u=e,this.#I(!1),await this.#X())}#ge(e){let n=e===this.#u;n&&this.#k(),this.conversationStore.clear(e),n&&(this.#G(),this.#u=this.conversationStore.threadId(),this.#I(!1)),this.#O()}async#O(){this.#S.setThreads(await this.conversationStore.listThreads(),this.#u)}async#X(){let e=await this.conversationStore.loadMessages(this.#u);if(e!==null){this.#D=e;for(let r of e)this.#ve(r)}let n=this.conversationStore.loadCheckpoint(this.#u);n!==null&&await this.#be(n)}#ve(e){let n=typeof e.content=="string"?e.content:"";if(e.role===Ye.USER){let r=oa(e);if(n!==""||r.length>0){let o=this.appendMessage(Ye.USER,n);r.length>0&&o.appendChild(Wi(r))}return}if(e.role===Ye.ASSISTANT){n!==""&&this.appendMessage(Ye.ASSISTANT,n).classList.add("message--restored");let r=e.toolCalls;if(r!==void 0)for(let o of r)this.#$({id:o.id,name:o.function.name,args:this.#ye(o.function.arguments)});return}if(e.role==="tool"){let r=this.#o.get(e.toolCallId);r!==void 0&&r.settle(ce.DONE,e.content)}}#ye(e){try{let n=JSON.parse(e);if(typeof n=="object"&&n!==null)return n}catch{}return{}}#Z(e){this.getAttribute("data-text-animation")==="word"&&pu(e)}async#be(e){this.conversationStore.saveCheckpoint(this.#u,null);let n=this.#q();n.addToolResult(e.toolCallId,JSON.stringify(this.navigationResult(e))),await n.resume()}appendMessage(e,n){let r=document.createElement("div");return r.className=`message message--${e}`,r.setAttribute("part",`message message-${e}`),e===Ye.ASSISTANT?(r.innerHTML=ii(n,{allowImages:this.allowImages}),this.#A().appendChild(r)):(this.#v=null,r.textContent=n,this.#r.appendChild(r)),this.#b(),this.#r.scrollTop=this.#r.scrollHeight,r}#A(){if(this.#v===null){let e=document.createElement("div");e.className="answer",e.setAttribute("part","answer"),this.#v=e,this.#r.appendChild(e),this.#b()}return this.#v}#xe(){let e=document.createElement("style");e.textContent=fu,this.#s.className="chat",this.#s.setAttribute("part","panel");let n=document.createElement("div");n.className="header",n.setAttribute("part","header");let r=this.#h;r.className="header-title",r.setAttribute("part","title"),r.textContent=this.getAttribute("title-text")??this.#e.title,(this.querySelector('[slot="icon"]')!==null||this.getAttribute("data-icon-url")!==null)&&n.append(this.#K("icon","icon",null));let o=document.createElement("slot");o.name="header-actions";let i=document.createElement("div");i.className="header-controls",i.setAttribute("part","header-controls");let s=this.#H("history",this.#e.chatHistory,"\u2630");s.addEventListener("click",()=>{this.#O(),this.#S.open()});let a=this.#H("new",this.#e.newChat,"\u271A");a.addEventListener("click",()=>this.newChat());let l=this.#H("collapse",this.#e.collapse,"\u2014");l.addEventListener("click",()=>this.toggleCollapsed()),i.append(s,a,l),n.append(r,o,i),this.#r.className="messages",this.#r.setAttribute("part","messages"),this.#r.setAttribute("role","log"),this.#r.setAttribute("aria-live","polite"),this.#r.setAttribute("aria-label",this.#e.conversation),this.#x.className="empty",this.#x.setAttribute("part","empty");let c=document.createElement("slot");c.name="empty",this.#x.append(c),this.#r.append(this.#x);let p=document.createElement("div");p.className="input-row",p.setAttribute("part","composer"),this.#a.className="input",this.#a.setAttribute("part","input"),this.#a.setAttribute("aria-label",this.#e.message),this.#a.rows=2,this.#a.placeholder=this.#e.inputPlaceholder,this.#a.addEventListener("keydown",x=>this.#Te(x)),this.#a.addEventListener("input",()=>this.#Ee()),this.#c.className="send",this.#c.type="button",this.#c.setAttribute("part","send"),this.#c.textContent=this.#e.send,this.#c.setAttribute("aria-label",this.#e.send),this.#c.dataset.state="idle",this.#c.addEventListener("click",()=>{if(this.#L){this.#k();return}this.#F()}),this.#y.className="skill-hint",this.#y.hidden=!0,this.#p.className="attach-btn",this.#p.type="button",this.#p.setAttribute("part","attach-button"),this.#p.textContent="\u{1F4CE}",this.#p.title=this.#e.attachFiles,this.#p.setAttribute("aria-label",this.#e.attachFiles),this.#p.hidden=!0,this.#p.addEventListener("click",()=>this.#f.click()),this.#f.className="attach-input",this.#f.type="file",this.#f.multiple=!0,this.#f.hidden=!0,this.#f.addEventListener("change",()=>this.#se()),this.#C.className="attachment-slot";let m=document.createElement("slot");m.name="footer",p.append(this.#p,this.#a,this.#c,this.#f),this.#s.append(n,this.#r,this.#d.palette,this.#d.chips,this.#y,this.#C,p,m,this.#S.element),this.#g.className="rail",this.#g.type="button",this.#g.setAttribute("part","launcher"),this.#g.setAttribute("aria-label",this.#e.expand),this.#g.append(this.#K("launcher","launcher-icon","\u{1F4AC}")),this.#g.addEventListener("click",()=>this.setCollapsed(!1)),this.#i.append(e,this.#s,this.#g)}#H(e,n,r){let o=document.createElement("button");return o.type="button",o.className=`header-btn header-btn--${e}`,o.setAttribute("part",`header-button ${e}-button`),o.title=n,o.setAttribute("aria-label",n),o.textContent=r,o}#K(e,n,r){let o=document.createElement("span");o.className="icon-holder",o.setAttribute("part",n);let i=document.createElement("slot");i.name=e;let s=this.getAttribute("data-icon-url");if(s!==null){let a=document.createElement("img");a.className="icon-img",a.src=s,a.alt="",i.append(a)}else r!==null&&i.append(document.createTextNode(r));return o.append(i),o}#Y(){this.#g.setAttribute("aria-expanded",String(!this.collapsed))}#b(){this.#x.hidden=this.#r.childElementCount>1}#Ee(){this.#d.onInput(this.#a.value),this.#y.hidden=!0}#Te(e){if(this.#d.onKeydown(e)){e.preventDefault();return}if(e.key==="Escape"&&this.#L){e.preventDefault(),this.#k();return}e.key==="Enter"&&!e.shiftKey&&(e.preventDefault(),this.#F())}#k(){this.#N?.abort(),this.#w?.cancel()}#I(e){this.#L=e;let n=e?this.#e.stop:this.#e.send;this.#c.textContent=n,this.#c.setAttribute("aria-label",n),this.#c.dataset.state=e?"running":"idle"}async#F(){let e=this.#a.value.trim(),n=this.#E?.readyRefs()??[];if(e===""&&n.length===0)return;let r=this.appendMessage(Ye.USER,e);n.length>0&&r.appendChild(Wi(n)),this.#a.value="",this.#E?.clearReady(),this.#_=n,this.dispatchEvent(new CustomEvent(wi,{detail:{content:e,attachments:n},bubbles:!0,composed:!0})),await this.#Se(e,n)}async#Se(e,n){this.endpoint!==""&&await this.#q().send(e,n)}#q(){if(this.#w===null){let e=this.agentFactory({endpoint:this.endpoint,headers:this.headers,getHeaders:()=>this.headers,threadId:this.#u,initialMessages:this.#D});this.#w=new ir({agent:e,handlers:this.#Ae(),getTools:()=>this.getTools(),getContext:()=>this.getContext(),executeTool:n=>this.#we(n),onPersist:n=>this.conversationStore.saveMessages(this.#u,n),connectionLostMessage:this.#e.connectionLost})}return this.#w}async#_e(e,n){return this.autoConfirm?!1:this.confirmPredicate!==null?await this.confirmPredicate(e.name,e.args)===!0:Ri(n.parameters)}async#we(e){let n=this.#$(e);this.#o.delete(e.id);let r=this.#W(e.name);if(r===null)return this.#l.has(e.id)||n.settle(ce.DONE,this.#e.noResult),null;if(await this.#_e(e,r)){let i={toolName:e.name,args:e.args},s=r.parameters[ki];typeof s=="string"&&(i.message=s),this.#N=new AbortController;let a=Ds(this.#r,i,{signal:this.#N.signal,strings:this.#e});this.#b(),this.#r.scrollTop=this.#r.scrollHeight;let l=await a;if(this.#N=null,!l){let c=this.#e.declinedAction;return n.settle(ce.DECLINED,c),this.#M(),{content:c}}}let o=Oi(r.parameters)&&this.navigate===null;o&&this.conversationStore.saveCheckpoint(this.#u,{toolCallId:e.id});try{let i=await r.handler(e.args);if(o)return n.settle(ce.DONE,this.#e.navigating),{content:"",halt:!0};let s=JSON.stringify(i??null);return n.settle(ce.DONE,s),this.#M(),{content:s}}catch(i){o&&this.conversationStore.saveCheckpoint(this.#u,null);let s=i instanceof Error?i.message:String(i);return n.settle(ce.ERROR,s),this.#M(),{content:`Error: ${s}`,error:s}}}#Ae(){return{onRunStart:()=>{this.#I(!0),this.#A(),this.#M()},onTextDelta:e=>{this.#T(),this.#J(e),this.#P+=1},onTextEnd:e=>{let n=this.#J(e);this.#P<=1&&this.#Z(n),this.#m=null},onToolCall:e=>{this.#T(),this.#$(e)},onToolResult:(e,n)=>{let r=this.#o.get(e);r!==void 0&&(r.settle(ce.DONE,n),this.#l.add(e))},onRunEnd:()=>{this.#T(),this.#m=null},onError:e=>{this.#T(),this.#Z(this.appendMessage(Ye.ASSISTANT,`\u26A0\uFE0F ${e}`)),this.#m=null},onCancelled:()=>{this.#T(),this.#ke(),this.#m=null},onSettled:()=>{this.#T(),this.#I(!1),this.#m=null,this.#_=[];for(let e of this.#o.values())e.settled||e.settle(ce.DONE,this.#e.noResult);this.#v!==null&&this.#v.childElementCount===0&&(this.#v.remove(),this.#b()),this.#v=null}}}#ke(){let e=document.createElement("div");e.className="stopped-note",e.setAttribute("part","stopped"),e.setAttribute("role","status"),e.textContent=this.#e.stopped,this.#A().appendChild(e),this.#b(),this.#r.scrollTop=this.#r.scrollHeight}#M(){if(this.#R!==null)return;let e=document.createElement("div");e.className="pending",e.setAttribute("part","pending"),e.setAttribute("role","status"),e.setAttribute("aria-label",this.#e.thinking);for(let n=0;n<3;n+=1){let r=document.createElement("span");r.className="pending-dot",e.appendChild(r)}this.#R=e,this.#A().appendChild(e),this.#b(),this.#r.scrollTop=this.#r.scrollHeight}#T(){this.#R?.remove(),this.#R=null}#J(e){return this.#m===null&&(this.#m=this.appendMessage(Ye.ASSISTANT,""),this.#P=0),this.#m.innerHTML=ii(e,{allowImages:this.allowImages}),this.#r.scrollTop=this.#r.scrollHeight,this.#m}#$(e){let n=this.#o.get(e.id);if(n!==void 0)return n;let r=this.#W(e.name)?.parameters[Ce],o=typeof r=="string"?r:this.toolSummaries[e.name]??this.#t[e.name]??Us(e.name),i=new or(e.name,e.args,this.toolDisplay,o,this.#e);return this.#o.set(e.id,i),this.#A().appendChild(i.element),this.#b(),this.#r.scrollTop=this.#r.scrollHeight,i}};function _g(){customElements.get(Er)===void 0&&customElements.define(Er,lr)}async function wg(t,e,n={}){at(t),await Pi(t,{flashMs:n.flashMs??0}),await Mi(t,e,n)}async function Ag(t,e={}){at(t),await Li(t,e)}async function kg(t,e={}){at(t),await Ui(t,e)}async function Ig(t,e,n={}){at(t),await Gi(t,e,n)}async function Cg(t,e,n={}){at(t),await Hi(t,e,n)}function Ng(t,e){t instanceof HTMLInputElement&&t.type==="checkbox"?Dn(t,!!e):wt(t,String(e)),t.dispatchEvent(new Event("input",{bubbles:!0})),t.dispatchEvent(new Event("change",{bubbles:!0}))}var Rg="0.8.0";export{lr as AgUiChat,ir as AgUiClient,Pn as ClientToolRegistry,li as ConnectionLostError,Ie as DEFAULT_UI_STRINGS,Er as ELEMENT_TAG,Ii as MAX_TOOL_ROUNDS,Ye as MESSAGE_ROLE,Fi as PAGE_ACTIONS,ar as RemoteConversationStore,wi as SUBMIT_EVENT,Jt as SessionStorageStore,Ai as TOGGLE_EVENT,ce as TOOL_CALL_STATUS,$e as TOOL_DISPLAY,or as ToolCallCard,Rg as VERSION,ki as X_CONFIRM_KEY,Mn as X_DESTRUCTIVE_KEY,Ln as X_NAVIGATES_KEY,Ce as X_SUMMARY_KEY,Ag as clickElement,la as createHttpAgent,$i as createPageActionTools,zi as createPageMapContext,ji as createRouteTools,Vi as createStateHookTools,_g as defineAgUiChat,wg as fillField,Pi as focusWithFlash,Li as highlightThenClick,Ri as isDestructive,Oi as isNavigates,Ps as mergeUiStrings,oa as messageAttachments,Bi as parseToolCatalog,Ua as prefersReducedMotion,kg as pressButton,Ui as pressThenClick,Us as prettifyToolName,ii as renderMarkdown,Ds as requestConfirmation,at as scrollIntoCenterView,Ig as selectControl,Gi as selectOption,Ng as setControlValue,Dn as setNativeChecked,wt as setNativeValue,Cg as toggleCheckbox,Hi as toggleControl,Mi as typeInto,ca as uploadAttachment};
|
|
1251
|
+
Use the read_attachment tool with an id to read a file's contents.`}]}#ce(){let e=this.getAttribute("data-threads-url");e!==null&&(this.conversationStore=new ar(e,()=>this.headers,this.conversationStore))}async#ue(){let e=this.getAttribute("data-tools-url");if(e!==null)try{let n=await fetch(e,{headers:this.headers});this.#t=Bi(await n.json())}catch{}}setSkills(e){this.#j=e,this.#U()}#de(){this.#d.enableChips(this.getAttribute("data-prompt-chips")==="true"),this.#d.enableSlash(this.getAttribute("data-slash-commands")==="true"),this.#B=this.#pe(),this.#U(),this.#fe()}#pe(){let e=this.getAttribute("data-skills");if(e===null)return[];try{return Ni(JSON.parse(e))}catch{return[]}}async#fe(){let e=this.getAttribute("data-skills-url");if(e!==null)try{let n=await fetch(e,{headers:this.headers});this.#z=Ni(await n.json()),this.#U()}catch{}}#U(){let e=new Map;for(let n of[...this.#z,...this.#B,...this.#j])e.set(n.name,n);this.#d.setSkills([...e.values()])}#he(e){let{text:n,missing:r}=La(e.prompt,this.skillContext());if(r.length>0){this.#y.textContent=this.#e.skillNeeds.replace("{title}",e.title).replace("{fields}",r.join(", ")),this.#y.hidden=!1;return}this.#y.hidden=!0,this.#a.value=n,e.sendImmediately===!0?this.#F():this.#a.focus()}get collapsed(){return this.hasAttribute("collapsed")}set collapsed(e){this.setCollapsed(e)}setCollapsed(e){e?this.setAttribute("collapsed",""):this.removeAttribute("collapsed"),sessionStorage.setItem(bu,e?"1":"0"),this.#Y(),this.dispatchEvent(new CustomEvent(Ai,{detail:{collapsed:e},bubbles:!0,composed:!0}))}toggleCollapsed(){this.setCollapsed(!this.collapsed)}newChat(){this.#k(),this.conversationStore.clear(this.#u),this.#G(),this.#u=this.conversationStore.threadId(),this.#I(!1)}#G(){this.#w=null,this.#m=null,this.#v=null,this.#T(),this.#o.clear(),this.#l.clear(),this.#D=[],this.#_=[],this.#E?.clear(),this.#r.replaceChildren(this.#x),this.#b()}async#me(e){e!==this.#u&&(this.#k(),this.#G(),this.conversationStore.setActiveThread(e),this.#u=e,this.#I(!1),await this.#X())}#ge(e){let n=e===this.#u;n&&this.#k(),this.conversationStore.clear(e),n&&(this.#G(),this.#u=this.conversationStore.threadId(),this.#I(!1)),this.#O()}async#O(){this.#S.setThreads(await this.conversationStore.listThreads(),this.#u)}async#X(){let e=await this.conversationStore.loadMessages(this.#u);if(e!==null){this.#D=e;for(let r of e)this.#ve(r)}let n=this.conversationStore.loadCheckpoint(this.#u);n!==null&&await this.#be(n)}#ve(e){let n=typeof e.content=="string"?e.content:"";if(e.role===Ye.USER){let r=oa(e);if(n!==""||r.length>0){let o=this.appendMessage(Ye.USER,n);r.length>0&&o.appendChild(Wi(r))}return}if(e.role===Ye.ASSISTANT){n!==""&&this.appendMessage(Ye.ASSISTANT,n).classList.add("message--restored");let r=e.toolCalls;if(r!==void 0)for(let o of r)this.#$({id:o.id,name:o.function.name,args:this.#ye(o.function.arguments)});return}if(e.role==="tool"){let r=this.#o.get(e.toolCallId);r!==void 0&&r.settle(ce.DONE,e.content)}}#ye(e){try{let n=JSON.parse(e);if(typeof n=="object"&&n!==null)return n}catch{}return{}}#Z(e){this.getAttribute("data-text-animation")==="word"&&pu(e)}async#be(e){this.conversationStore.saveCheckpoint(this.#u,null);let n=this.#q();n.addToolResult(e.toolCallId,JSON.stringify(this.navigationResult(e))),await n.resume()}appendMessage(e,n){let r=document.createElement("div");return r.className=`message message--${e}`,r.setAttribute("part",`message message-${e}`),e===Ye.ASSISTANT?(r.innerHTML=ii(n,{allowImages:this.allowImages}),this.#A().appendChild(r)):(this.#v=null,r.textContent=n,this.#r.appendChild(r)),this.#b(),this.#r.scrollTop=this.#r.scrollHeight,r}#A(){if(this.#v===null){let e=document.createElement("div");e.className="answer",e.setAttribute("part","answer"),this.#v=e,this.#r.appendChild(e),this.#b()}return this.#v}#xe(){let e=document.createElement("style");e.textContent=fu,this.#s.className="chat",this.#s.setAttribute("part","panel");let n=document.createElement("div");n.className="header",n.setAttribute("part","header");let r=this.#h;r.className="header-title",r.setAttribute("part","title"),r.textContent=this.getAttribute("title-text")??this.#e.title,(this.querySelector('[slot="icon"]')!==null||this.getAttribute("data-icon-url")!==null)&&n.append(this.#K("icon","icon",null));let o=document.createElement("slot");o.name="header-actions";let i=document.createElement("div");i.className="header-controls",i.setAttribute("part","header-controls");let s=this.#H("history",this.#e.chatHistory,"\u2630");s.addEventListener("click",()=>{this.#O(),this.#S.open()});let a=this.#H("new",this.#e.newChat,"\u271A");a.addEventListener("click",()=>this.newChat());let l=this.#H("collapse",this.#e.collapse,"\u2014");l.addEventListener("click",()=>this.toggleCollapsed()),i.append(s,a,l),n.append(r,o,i),this.#r.className="messages",this.#r.setAttribute("part","messages"),this.#r.setAttribute("role","log"),this.#r.setAttribute("aria-live","polite"),this.#r.setAttribute("aria-label",this.#e.conversation),this.#x.className="empty",this.#x.setAttribute("part","empty");let c=document.createElement("slot");c.name="empty",this.#x.append(c),this.#r.append(this.#x);let p=document.createElement("div");p.className="input-row",p.setAttribute("part","composer"),this.#a.className="input",this.#a.setAttribute("part","input"),this.#a.setAttribute("aria-label",this.#e.message),this.#a.rows=2,this.#a.placeholder=this.#e.inputPlaceholder,this.#a.addEventListener("keydown",x=>this.#Te(x)),this.#a.addEventListener("input",()=>this.#Ee()),this.#c.className="send",this.#c.type="button",this.#c.setAttribute("part","send"),this.#c.textContent=this.#e.send,this.#c.setAttribute("aria-label",this.#e.send),this.#c.dataset.state="idle",this.#c.addEventListener("click",()=>{if(this.#L){this.#k();return}this.#F()}),this.#y.className="skill-hint",this.#y.hidden=!0,this.#p.className="attach-btn",this.#p.type="button",this.#p.setAttribute("part","attach-button"),this.#p.textContent="\u{1F4CE}",this.#p.title=this.#e.attachFiles,this.#p.setAttribute("aria-label",this.#e.attachFiles),this.#p.hidden=!0,this.#p.addEventListener("click",()=>this.#f.click()),this.#f.className="attach-input",this.#f.type="file",this.#f.multiple=!0,this.#f.hidden=!0,this.#f.addEventListener("change",()=>this.#se()),this.#C.className="attachment-slot";let m=document.createElement("slot");m.name="footer",p.append(this.#p,this.#a,this.#c,this.#f),this.#s.append(n,this.#r,this.#d.palette,this.#d.chips,this.#y,this.#C,p,m,this.#S.element),this.#g.className="rail",this.#g.type="button",this.#g.setAttribute("part","launcher"),this.#g.setAttribute("aria-label",this.#e.expand),this.#g.append(this.#K("launcher","launcher-icon","\u{1F4AC}")),this.#g.addEventListener("click",()=>this.setCollapsed(!1)),this.#i.append(e,this.#s,this.#g)}#H(e,n,r){let o=document.createElement("button");return o.type="button",o.className=`header-btn header-btn--${e}`,o.setAttribute("part",`header-button ${e}-button`),o.title=n,o.setAttribute("aria-label",n),o.textContent=r,o}#K(e,n,r){let o=document.createElement("span");o.className="icon-holder",o.setAttribute("part",n);let i=document.createElement("slot");i.name=e;let s=this.getAttribute("data-icon-url");if(s!==null){let a=document.createElement("img");a.className="icon-img",a.src=s,a.alt="",i.append(a)}else r!==null&&i.append(document.createTextNode(r));return o.append(i),o}#Y(){this.#g.setAttribute("aria-expanded",String(!this.collapsed))}#b(){this.#x.hidden=this.#r.childElementCount>1}#Ee(){this.#d.onInput(this.#a.value),this.#y.hidden=!0}#Te(e){if(this.#d.onKeydown(e)){e.preventDefault();return}if(e.key==="Escape"&&this.#L){e.preventDefault(),this.#k();return}e.key==="Enter"&&!e.shiftKey&&(e.preventDefault(),this.#F())}#k(){this.#N?.abort(),this.#w?.cancel()}#I(e){this.#L=e;let n=e?this.#e.stop:this.#e.send;this.#c.textContent=n,this.#c.setAttribute("aria-label",n),this.#c.dataset.state=e?"running":"idle"}async#F(){let e=this.#a.value.trim(),n=this.#E?.readyRefs()??[];if(e===""&&n.length===0)return;let r=this.appendMessage(Ye.USER,e);n.length>0&&r.appendChild(Wi(n)),this.#a.value="",this.#E?.clearReady(),this.#_=n,this.dispatchEvent(new CustomEvent(wi,{detail:{content:e,attachments:n},bubbles:!0,composed:!0})),await this.#Se(e,n)}async#Se(e,n){this.endpoint!==""&&await this.#q().send(e,n)}#q(){if(this.#w===null){let e=this.agentFactory({endpoint:this.endpoint,headers:this.headers,getHeaders:()=>this.headers,threadId:this.#u,initialMessages:this.#D});this.#w=new ir({agent:e,handlers:this.#Ae(),getTools:()=>this.getTools(),getContext:()=>this.getContext(),executeTool:n=>this.#we(n),onPersist:n=>this.conversationStore.saveMessages(this.#u,n),connectionLostMessage:this.#e.connectionLost})}return this.#w}async#_e(e,n){return this.autoConfirm?!1:this.confirmPredicate!==null?await this.confirmPredicate(e.name,e.args)===!0:Ri(n.parameters)}async#we(e){let n=this.#$(e);this.#o.delete(e.id);let r=this.#W(e.name);if(r===null)return this.#l.has(e.id)||n.settle(ce.DONE,this.#e.noResult),null;if(await this.#_e(e,r)){let i={toolName:e.name,args:e.args},s=r.parameters[ki];typeof s=="string"&&(i.message=s),this.#N=new AbortController;let a=Ds(this.#r,i,{signal:this.#N.signal,strings:this.#e});this.#b(),this.#r.scrollTop=this.#r.scrollHeight;let l=await a;if(this.#N=null,!l){let c=this.#e.declinedAction;return n.settle(ce.DECLINED,c),this.#M(),{content:c}}}let o=Oi(r.parameters)&&this.navigate===null;o&&this.conversationStore.saveCheckpoint(this.#u,{toolCallId:e.id});try{let i=await r.handler(e.args);if(o)return n.settle(ce.DONE,this.#e.navigating),{content:"",halt:!0};let s=JSON.stringify(i??null);return n.settle(ce.DONE,s),this.#M(),{content:s}}catch(i){o&&this.conversationStore.saveCheckpoint(this.#u,null);let s=i instanceof Error?i.message:String(i);return n.settle(ce.ERROR,s),this.#M(),{content:`Error: ${s}`,error:s}}}#Ae(){return{onRunStart:()=>{this.#I(!0),this.#A(),this.#M()},onTextDelta:e=>{this.#T(),this.#J(e),this.#P+=1},onTextEnd:e=>{let n=this.#J(e);this.#P<=1&&this.#Z(n),this.#m=null},onToolCall:e=>{this.#T(),this.#$(e)},onToolResult:(e,n)=>{let r=this.#o.get(e);r!==void 0&&(r.settle(ce.DONE,n),this.#l.add(e))},onRunEnd:()=>{this.#T(),this.#m=null},onError:e=>{this.#T(),this.#Z(this.appendMessage(Ye.ASSISTANT,`\u26A0\uFE0F ${e}`)),this.#m=null},onCancelled:()=>{this.#T(),this.#ke(),this.#m=null},onSettled:()=>{this.#T(),this.#I(!1),this.#m=null,this.#_=[];for(let e of this.#o.values())e.settled||e.settle(ce.DONE,this.#e.noResult);this.#v!==null&&this.#v.childElementCount===0&&(this.#v.remove(),this.#b()),this.#v=null}}}#ke(){let e=document.createElement("div");e.className="stopped-note",e.setAttribute("part","stopped"),e.setAttribute("role","status"),e.textContent=this.#e.stopped,this.#A().appendChild(e),this.#b(),this.#r.scrollTop=this.#r.scrollHeight}#M(){if(this.#R!==null)return;let e=document.createElement("div");e.className="pending",e.setAttribute("part","pending"),e.setAttribute("role","status"),e.setAttribute("aria-label",this.#e.thinking);for(let n=0;n<3;n+=1){let r=document.createElement("span");r.className="pending-dot",e.appendChild(r)}this.#R=e,this.#A().appendChild(e),this.#b(),this.#r.scrollTop=this.#r.scrollHeight}#T(){this.#R?.remove(),this.#R=null}#J(e){return this.#m===null&&(this.#m=this.appendMessage(Ye.ASSISTANT,""),this.#P=0),this.#m.innerHTML=ii(e,{allowImages:this.allowImages}),this.#r.scrollTop=this.#r.scrollHeight,this.#m}#$(e){let n=this.#o.get(e.id);if(n!==void 0)return n;let r=this.#W(e.name)?.parameters[Ce],o=typeof r=="string"?r:this.toolSummaries[e.name]??this.#t[e.name]??Us(e.name),i=new or(e.name,e.args,this.toolDisplay,o,this.#e);return this.#o.set(e.id,i),this.#A().appendChild(i.element),this.#b(),this.#r.scrollTop=this.#r.scrollHeight,i}};function _g(){customElements.get(Er)===void 0&&customElements.define(Er,lr)}async function wg(t,e,n={}){at(t),await Pi(t,{flashMs:n.flashMs??0}),await Mi(t,e,n)}async function Ag(t,e={}){at(t),await Li(t,e)}async function kg(t,e={}){at(t),await Ui(t,e)}async function Ig(t,e,n={}){at(t),await Gi(t,e,n)}async function Cg(t,e,n={}){at(t),await Hi(t,e,n)}function Ng(t,e){t instanceof HTMLInputElement&&t.type==="checkbox"?Dn(t,!!e):wt(t,String(e)),t.dispatchEvent(new Event("input",{bubbles:!0})),t.dispatchEvent(new Event("change",{bubbles:!0}))}var Rg="0.8.1";export{lr as AgUiChat,ir as AgUiClient,Pn as ClientToolRegistry,li as ConnectionLostError,Ie as DEFAULT_UI_STRINGS,Er as ELEMENT_TAG,Ii as MAX_TOOL_ROUNDS,Ye as MESSAGE_ROLE,Fi as PAGE_ACTIONS,ar as RemoteConversationStore,wi as SUBMIT_EVENT,Jt as SessionStorageStore,Ai as TOGGLE_EVENT,ce as TOOL_CALL_STATUS,$e as TOOL_DISPLAY,or as ToolCallCard,Rg as VERSION,ki as X_CONFIRM_KEY,Mn as X_DESTRUCTIVE_KEY,Ln as X_NAVIGATES_KEY,Ce as X_SUMMARY_KEY,Ag as clickElement,la as createHttpAgent,$i as createPageActionTools,zi as createPageMapContext,ji as createRouteTools,Vi as createStateHookTools,_g as defineAgUiChat,wg as fillField,Pi as focusWithFlash,Li as highlightThenClick,Ri as isDestructive,Oi as isNavigates,Ps as mergeUiStrings,oa as messageAttachments,Bi as parseToolCatalog,Ua as prefersReducedMotion,kg as pressButton,Ui as pressThenClick,Us as prettifyToolName,ii as renderMarkdown,Ds as requestConfirmation,at as scrollIntoCenterView,Ig as selectControl,Gi as selectOption,Ng as setControlValue,Dn as setNativeChecked,wt as setNativeValue,Cg as toggleCheckbox,Hi as toggleControl,Mi as typeInto,ca as uploadAttachment};
|
|
1238
1252
|
/*! Bundled license information:
|
|
1239
1253
|
|
|
1240
1254
|
fast-json-patch/module/helpers.mjs:
|