@arcgis/ai-components 5.1.0-next.5 → 5.1.0-next.7

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
@@ -1,5 +1,5 @@
1
1
  /* COPYRIGHT Esri - https://js.arcgis.com/5.1/LICENSE.txt */
2
- import a from"./R3LASMEM.js";export default $arcgis.t(([mt,he,De,ft,{addressToLocations:gt},Pe,V,Y,me,fe,Ge,Be,ge,Qe,{createRenderer:yt},{getSchemesByTag:pt,getSchemes:wt},{getBackgroundColorTheme:ke},{createAgeRenderer:bt,createContinuousRenderer:vt},{getSchemesByTag:ye},{createContinuousRenderer:St},{createRenderer:Tt},{getSchemesByTag:Et},{createRenderer:xt},{getSchemesByTag:It},{createRenderer:Lt},{getSchemesByTag:$t},{createRenderer:Ft},{getSchemesByTag:_t},{createAgeRenderer:Nt,createContinuousRenderer:kt},{createRenderer:qt},{getSchemesByTag:At},We,qe,Ae,P,{executeQueryStreaming:Rt},Mt,{a:xe,b:Ie,c:O,d:te,e:re,f:j,g:D,h:N,i:p,j:y,k:k,l:E,m:Le,n:U,o:J,p:$e,q:L,r:q,s:s,t:h,u:x,v:ae,w:Fe,x:z}])=>{var Ne=e=>Array.isArray(e)&&e.every(O),ct=e=>typeof e=="object"&&e!=null&&"messages"in e&&Ne(e.messages),dt=e=>typeof e=="object"&&e!=null&&"lg_tool_call"in e,A=class extends $e{tools;handleToolErrors=!0;trace=!1;constructor(e,r){let{name:t,tags:a,handleToolErrors:o}=r??{};super({name:t,tags:a,func:(i,n)=>this.run(i,n)}),this.tools=e,this.handleToolErrors=o??this.handleToolErrors}async runTool(e,r){let t=this.tools.find(a=>a.name===e.name);try{if(t===void 0)throw new Error(`Tool "${e.name}" not found.`);let a=await t.invoke({...e,type:"tool_call"},r);return O(a)&&a.getType()==="tool"||J(a)?a:new te({status:"success",name:t.name,content:typeof a=="string"?a:JSON.stringify(a),tool_call_id:e.id})}catch(a){if(!this.handleToolErrors||Ie(a))throw a;return new te({status:"error",content:`Error: ${a.message}
2
+ import a from"./2PLHSU7P.js";export default $arcgis.t(([mt,he,De,ft,{addressToLocations:gt},Pe,V,Y,me,fe,Ge,Be,ge,Qe,{createRenderer:yt},{getSchemesByTag:pt,getSchemes:wt},{getBackgroundColorTheme:ke},{createAgeRenderer:bt,createContinuousRenderer:vt},{getSchemesByTag:ye},{createContinuousRenderer:St},{createRenderer:Tt},{getSchemesByTag:Et},{createRenderer:xt},{getSchemesByTag:It},{createRenderer:Lt},{getSchemesByTag:$t},{createRenderer:Ft},{getSchemesByTag:_t},{createAgeRenderer:Nt,createContinuousRenderer:kt},{createRenderer:qt},{getSchemesByTag:At},We,qe,Ae,P,{executeQueryStreaming:Rt},Mt,{a:xe,b:Ie,c:O,d:te,e:re,f:j,g:D,h:N,i:p,j:y,k:k,l:E,m:Le,n:U,o:J,p:$e,q:L,r:q,s:s,t:h,u:x,v:ae,w:Fe,x:z}])=>{var Ne=e=>Array.isArray(e)&&e.every(O),ct=e=>typeof e=="object"&&e!=null&&"messages"in e&&Ne(e.messages),dt=e=>typeof e=="object"&&e!=null&&"lg_tool_call"in e,A=class extends $e{tools;handleToolErrors=!0;trace=!1;constructor(e,r){let{name:t,tags:a,handleToolErrors:o}=r??{};super({name:t,tags:a,func:(i,n)=>this.run(i,n)}),this.tools=e,this.handleToolErrors=o??this.handleToolErrors}async runTool(e,r){let t=this.tools.find(a=>a.name===e.name);try{if(t===void 0)throw new Error(`Tool "${e.name}" not found.`);let a=await t.invoke({...e,type:"tool_call"},r);return O(a)&&a.getType()==="tool"||J(a)?a:new te({status:"success",name:t.name,content:typeof a=="string"?a:JSON.stringify(a),tool_call_id:e.id})}catch(a){if(!this.handleToolErrors||Ie(a))throw a;return new te({status:"error",content:`Error: ${a.message}
3
3
  Please fix your mistakes.`,name:e.name,tool_call_id:e.id??""})}}async run(e,r){let t;if(dt(e))t=[await this.runTool(e.lg_tool_call,r)];else{let i;if(Ne(e))i=e;else if(ct(e))i=e.messages;else throw new Error("ToolNode only accepts BaseMessage[] or { messages: BaseMessage[] } as input.");let n=new Set(i.filter(c=>c.getType()==="tool").map(c=>c.tool_call_id)),l;for(let c=i.length-1;c>=0;c-=1){let d=i[c];if(D(d)){l=d;break}}if(l==null||!D(l))throw new Error("ToolNode only accepts AIMessages as input.");t=await Promise.all(l.tool_calls?.filter(c=>c.id==null||!n.has(c.id)).map(c=>this.runTool(c,r))??[])}if(!t.some(J))return Array.isArray(e)?t:{messages:t};let a=[],o=null;for(let i of t)J(i)?i.graph===U.PARENT&&Array.isArray(i.goto)&&i.goto.every(n=>Le(n))?o?o.goto.push(...i.goto):o=new U({graph:U.PARENT,goto:i.goto}):a.push(i):a.push(Array.isArray(e)?[i]:{messages:[i]});return o&&a.push(o),a}};var as=y.Root({llmInputMessages:y({reducer:(e,r)=>L([],r),default:()=>[]})});var Ke=y.Root({messages:y({reducer:L,default:()=>[]}),outputMessage:y({reducer:(e="",r)=>{let t=typeof r=="string"?r.trim():"";if(!t)return e;let a=e.trim();if(!a)return t;if(a===t)return e;let o=a.split(`
4
4
 
5
5
  `);return o[o.length-1]?.trim()===t?e:`${e}
@@ -1,4 +1,4 @@
1
1
  /* COPYRIGHT Esri - https://js.arcgis.com/5.1/LICENSE.txt */
2
- import{a as b}from"./UY4FI7AP.js";import a from"./R3LASMEM.js";import{a as f}from"./I22GHLAO.js";import"./WBSNYWJJ.js";import{g as y,h,n as g,o as u,p as v,t as _}from"./26V7SXDR.js";import"./CFDTXKJ6.js";export default $arcgis.t(([E,{whenOnce:k,watch:L,when:S},O,P,{property:c,subclass:C},{y:w}])=>{var H=y`:host{height:100%}`,M=Object.defineProperty,x=Object.getOwnPropertyDescriptor,n=(l,t,e,r)=>{for(var s=r>1?void 0:r?x(t,e):t,a=l.length-1,o;a>=0;a--)(o=l[a])&&(s=(r?o(t,e,s):o(s))||s);return r&&s&&M(t,e,s),s},i=class extends P{constructor(l){super(l),this.view=null,this.loading=!1,this.processing=!1,this.processingStep=""}async load(){this._set("loading",!0);try{await this._initialize()}finally{this._set("loading",!1)}}destroy(){this.orchestrator?.dispose(),super.destroy()}async _initialize(){this.removeHandles(),await Promise.all([this.portal.load(),this.view?.when()]),this.view&&await k(()=>!this.view.updating),this._set("orchestrator",await w.init({agents:[...this.agents],portal:this.portal,view:this.view??void 0})),this.addHandles([L(()=>[this.view,this.agents],()=>void this._initialize())])}async*ask(l,t){if(!this.orchestrator)throw new Error("Orchestrator not initialized yet.");this._set("processing",!0),this._set("processingStep","");let e="";try{let r=this.orchestrator.ask(l);for await(let s of r){if(t?.aborted){yield{type:"cancelled"};break}switch(s.type){case"trace":{this._set("processingStep",s.data.text),e+=`${s.data.text}
2
+ import{a as b}from"./UY4FI7AP.js";import a from"./2PLHSU7P.js";import{a as f}from"./I22GHLAO.js";import"./WBSNYWJJ.js";import{g as y,h,n as g,o as u,p as v,t as _}from"./26V7SXDR.js";import"./CFDTXKJ6.js";export default $arcgis.t(([E,{whenOnce:k,watch:L,when:S},O,P,{property:c,subclass:C},{y:w}])=>{var H=y`:host{height:100%}`,M=Object.defineProperty,x=Object.getOwnPropertyDescriptor,n=(l,t,e,r)=>{for(var s=r>1?void 0:r?x(t,e):t,a=l.length-1,o;a>=0;a--)(o=l[a])&&(s=(r?o(t,e,s):o(s))||s);return r&&s&&M(t,e,s),s},i=class extends P{constructor(l){super(l),this.view=null,this.loading=!1,this.processing=!1,this.processingStep=""}async load(){this._set("loading",!0);try{await this._initialize()}finally{this._set("loading",!1)}}destroy(){this.orchestrator?.dispose(),super.destroy()}async _initialize(){this.removeHandles(),await Promise.all([this.portal.load(),this.view?.when()]),this.view&&await k(()=>!this.view.updating),this._set("orchestrator",await w.init({agents:[...this.agents],portal:this.portal,view:this.view??void 0})),this.addHandles([L(()=>[this.view,this.agents],()=>void this._initialize())])}async*ask(l,t){if(!this.orchestrator)throw new Error("Orchestrator not initialized yet.");this._set("processing",!0),this._set("processingStep","");let e="";try{let r=this.orchestrator.ask(l);for await(let s of r){if(t?.aborted){yield{type:"cancelled"};break}switch(s.type){case"trace":{this._set("processingStep",s.data.text),e+=`${s.data.text}
3
3
 
4
4
  `;break}case"completed":{if(!s.result.content.length){yield{type:"completed",error:"Could not process the request.",log:e};return}let a=s.result.content;this._set("processingStep",""),yield{type:"completed",response:a,log:e};return}case"interrupt":{console.log("Orchestrator interrupt:",s);let{kind:a,message:o,metadata:m}=s.interrupt,p=Array.isArray(m)?[...m]:[],$=(()=>{switch(a){case"booleanChoice":return{type:"boolean-choice",message:o,options:p};case"singleSelection":return{type:"single-select",message:o,options:p};case"multipleSelection":return{type:"multi-select",message:o,options:p};case"textInput":return{type:"text-input",message:o};default:return{type:a,message:o,options:p}}})();this._set("processingStep","Waiting for user input..."),yield{type:"interrupt",payload:$};break}case"cancelled":{yield{type:"cancelled"};return}default:{console.warn("Unknown event type:",s);break}}}}catch(r){console.warn("Error during message processing:",r),yield{type:"completed",error:"An error occurred during message processing.",log:e};return}finally{this._set("processing",!1)}}};n([c({readOnly:!0})],i.prototype,"orchestrator",2);n([c()],i.prototype,"agents",2);n([c()],i.prototype,"portal",2);n([c()],i.prototype,"view",2);n([c({readOnly:!0})],i.prototype,"loading",2);n([c({readOnly:!0})],i.prototype,"processing",2);n([c({readOnly:!0})],i.prototype,"processingStep",2);i=n([C("OrchestratorController")],i);var d=class extends v{constructor(){super(...arguments),this._messages=b({blocking:!0}),this.#e=g(),this.#s=g(),this.#t=null,this.#r=null,this.#a=new Map,this.#i=t=>{t.stopPropagation(),this.orchestrator?.cancelInterrupt(),this._interrupt=null},this.#o=t=>{t.stopPropagation();let e=t.detail;this.orchestrator?.resumeInterrupt(e),this._interrupt=null},this.#n=t=>{t.stopPropagation(),this.suggestedPrompts=[];let e=t.detail;this.#h(e)},this.#l=t=>{if(t.stopPropagation(),this._interrupt){this.orchestrator?.cancelInterrupt(),this._interrupt=null;return}this.#r?.abort()},this._interrupt=null,this._chatHistory=new E([]),this._error=null,this.referenceElement=null,this.portal=new O,this.suggestedPrompts=[]}static{this.properties={_interrupt:16,_chatHistory:16,_error:16,orchestrator:32,entryMessage:1,heading:1,description:1,referenceElement:1,portal:0,suggestedPrompts:0}}static{this.styles=H}#e;#s;#t;#r;#a;#i;#o;#n;#l;get orchestrator(){return this.#t?.orchestrator}register(t){this.#a.set(t.agent.id,t)}load(){this.manager.onLifecycle(()=>()=>{this.#r?.abort(),this._interrupt=null,this._chatHistory.removeAll(),this._error=null})}loaded(){this.manager.onLifecycle(()=>{this.#e.value?.addEventListener("arcgisSubmit",this.#n),this.#e.value?.addEventListener("arcgisCancel",this.#l);let t=S(()=>!!this._interrupt&&!!this.#s.value,()=>{let e=this.#s.value;e.removeEventListener("arcgisSubmit",this.#o),e.removeEventListener("arcgisCancel",this.#i),e.addEventListener("arcgisSubmit",this.#o,{once:!0}),e.addEventListener("arcgisCancel",this.#i,{once:!0})});return queueMicrotask(()=>void this.#c()),()=>{t.remove(),this.#s.value?.removeEventListener("arcgisSubmit",this.#o),this.#s.value?.removeEventListener("arcgisCancel",this.#i),this.#e.value?.removeEventListener("arcgisSubmit",this.#n),this.#e.value?.removeEventListener("arcgisCancel",this.#l),this.#t?.destroy(),this.#t=null}})}async#c(){try{let t=f(this.referenceElement);await t?.componentOnReady();let e=[...this.#a.values()];this.#t=new i({agents:e,portal:this.portal,view:t?.view}),await this.#t.load()}catch(t){console.warn(t),this._error="Error initializing orchestrator."}}async#h(t){let e=t.trim();if(!e||(this._chatHistory.push({type:"prompt",content:e}),!this.#t))return;this.#r=new AbortController;let r=this.#t.ask(e,this.#r.signal);for await(let s of r)switch(s.type){case"completed":this._chatHistory.push({type:"response",content:s.response,log:s.log,error:s.error});break;case"interrupt":this._interrupt=s.payload;break;case"cancelled":this._chatHistory.push({type:"response",error:"Request cancelled."});break}}render(){return h`<arcgis-assistant-shell .loading=${this.#t?.loading} .heading=${this.heading??this._messages.assistantLabel} .description=${this.description} .entryMessage=${this.entryMessage} .entryMessageClosed=${this._chatHistory.length>0} .awaitingResponse=${this.#t?.processing} .suggestedPrompts=${this.suggestedPrompts} .status=${this.#t?.processing?"working":this._error?"error":"ready"} ${u(this.#e)}>${this._error?h`<calcite-notice slot=entry-message open kind=danger icon width=full><div slot=message>${this._error}</div></calcite-notice>`:null}${this._interrupt?h`<arcgis-assistant-interrupt slot=entry-message .type=${this._interrupt.type} .message=${this._interrupt.message} .options=${this._interrupt.options} ${u(this.#s)}></arcgis-assistant-interrupt>`:null}<arcgis-assistant-chat .loading=${this.#t?.processing} .loadingMessage=${this.#t?.processingStep||""} .messages=${this._chatHistory} .user=${this.portal?.user?.fullName||this.portal?.user?.username}><slot></slot></arcgis-assistant-chat><slot name=header-actions-end slot=header-actions-end></slot>${this.entryMessage?null:h`<slot name=entry-message slot=entry-message></slot>`}<slot name=entry-actions-start slot=entry-actions-start></slot><slot name=footer-content slot=footer-content></slot></arcgis-assistant-shell>`}};_("arcgis-assistant",d);return d},"core/Collection","core/reactiveUtils","portal/Portal","core/Accessor","core/accessorSupport/decorators",a)
@@ -1,2 +1,2 @@
1
1
  /* COPYRIGHT Esri - https://js.arcgis.com/5.1/LICENSE.txt */
2
- import c from"./6ULHJSIQ.js";import b from"./R3LASMEM.js";import{a as e,b as i}from"./M672SFG6.js";import"./I22GHLAO.js";import"./WBSNYWJJ.js";import{p as s,t as a}from"./26V7SXDR.js";import"./CFDTXKJ6.js";export default $arcgis.t(([,{e:r}])=>{var t=class extends s{constructor(){super(...arguments),this.agent=r}static{this.properties={referenceElement:1}}#t;getContext(){if(!this.#t)throw new Error("arcgis-assistant-layer-styling-agent requires a mapView");return{mapView:this.#t}}async load(){this.#t=await e(this,"arcgis-assistant-layer-styling-agent"),i(this)}};a("arcgis-assistant-layer-styling-agent",t);return t},b,c)
2
+ import c from"./AIAY4NON.js";import b from"./2PLHSU7P.js";import{a as e,b as i}from"./M672SFG6.js";import"./I22GHLAO.js";import"./WBSNYWJJ.js";import{p as s,t as a}from"./26V7SXDR.js";import"./CFDTXKJ6.js";export default $arcgis.t(([,{e:r}])=>{var t=class extends s{constructor(){super(...arguments),this.agent=r}static{this.properties={referenceElement:1}}#t;getContext(){if(!this.#t)throw new Error("arcgis-assistant-layer-styling-agent requires a mapView");return{mapView:this.#t}}async load(){this.#t=await e(this,"arcgis-assistant-layer-styling-agent"),i(this)}};a("arcgis-assistant-layer-styling-agent",t);return t},b,c)
@@ -1,2 +1,2 @@
1
1
  /* COPYRIGHT Esri - https://js.arcgis.com/5.1/LICENSE.txt */
2
- import c from"./6ULHJSIQ.js";import b from"./R3LASMEM.js";import{a as s,b as a}from"./M672SFG6.js";import"./I22GHLAO.js";import"./WBSNYWJJ.js";import{p as r,t as e}from"./26V7SXDR.js";import"./CFDTXKJ6.js";export default $arcgis.t(([,{d:i}])=>{var t=class extends r{constructor(){super(...arguments),this.agent=i}static{this.properties={referenceElement:1}}#t;getContext(){if(!this.#t)throw new Error("arcgis-assistant-layer-query-agent requires a mapView");return{mapView:this.#t}}async load(){this.#t=await s(this,"arcgis-assistant-layer-query-agent"),a(this)}};e("arcgis-assistant-layer-query-agent",t);return t},b,c)
2
+ import c from"./AIAY4NON.js";import b from"./2PLHSU7P.js";import{a as s,b as a}from"./M672SFG6.js";import"./I22GHLAO.js";import"./WBSNYWJJ.js";import{p as r,t as e}from"./26V7SXDR.js";import"./CFDTXKJ6.js";export default $arcgis.t(([,{d:i}])=>{var t=class extends r{constructor(){super(...arguments),this.agent=i}static{this.properties={referenceElement:1}}#t;getContext(){if(!this.#t)throw new Error("arcgis-assistant-layer-query-agent requires a mapView");return{mapView:this.#t}}async load(){this.#t=await s(this,"arcgis-assistant-layer-query-agent"),a(this)}};e("arcgis-assistant-layer-query-agent",t);return t},b,c)
@@ -1,2 +1,2 @@
1
1
  /* COPYRIGHT Esri - https://js.arcgis.com/5.1/LICENSE.txt */
2
- import c from"./6ULHJSIQ.js";import b from"./R3LASMEM.js";import{a as r,b as e}from"./M672SFG6.js";import"./I22GHLAO.js";import"./WBSNYWJJ.js";import{p as a,t as s}from"./26V7SXDR.js";import"./CFDTXKJ6.js";export default $arcgis.t(([,{b:i}])=>{var t=class extends a{constructor(){super(...arguments),this.agent=i}static{this.properties={referenceElement:1}}#t;getContext(){if(!this.#t)throw new Error("arcgis-assistant-data-exploration-agent requires a mapView");return{mapView:this.#t}}async load(){this.#t=await r(this,"arcgis-assistant-data-exploration-agent"),e(this)}};s("arcgis-assistant-data-exploration-agent",t);return t},b,c)
2
+ import c from"./AIAY4NON.js";import b from"./2PLHSU7P.js";import{a as r,b as e}from"./M672SFG6.js";import"./I22GHLAO.js";import"./WBSNYWJJ.js";import{p as a,t as s}from"./26V7SXDR.js";import"./CFDTXKJ6.js";export default $arcgis.t(([,{b:i}])=>{var t=class extends a{constructor(){super(...arguments),this.agent=i}static{this.properties={referenceElement:1}}#t;getContext(){if(!this.#t)throw new Error("arcgis-assistant-data-exploration-agent requires a mapView");return{mapView:this.#t}}async load(){this.#t=await r(this,"arcgis-assistant-data-exploration-agent"),e(this)}};s("arcgis-assistant-data-exploration-agent",t);return t},b,c)
@@ -1,2 +1,2 @@
1
1
  /* COPYRIGHT Esri - https://js.arcgis.com/5.1/LICENSE.txt */
2
- import c from"./6ULHJSIQ.js";import b from"./R3LASMEM.js";import{a as i,b as e}from"./M672SFG6.js";import"./I22GHLAO.js";import"./WBSNYWJJ.js";import{p as a,t as s}from"./26V7SXDR.js";import"./CFDTXKJ6.js";export default $arcgis.t(([,{a:r}])=>{var t=class extends a{constructor(){super(...arguments),this.agent=r}static{this.properties={referenceElement:1}}#t;getContext(){if(!this.#t)throw new Error("arcgis-assistant-navigation-agent requires a mapView");return{mapView:this.#t}}async load(){this.#t=await i(this,"arcgis-assistant-navigation-agent"),e(this)}};s("arcgis-assistant-navigation-agent",t);return t},b,c)
2
+ import c from"./AIAY4NON.js";import b from"./2PLHSU7P.js";import{a as i,b as e}from"./M672SFG6.js";import"./I22GHLAO.js";import"./WBSNYWJJ.js";import{p as a,t as s}from"./26V7SXDR.js";import"./CFDTXKJ6.js";export default $arcgis.t(([,{a:r}])=>{var t=class extends a{constructor(){super(...arguments),this.agent=r}static{this.properties={referenceElement:1}}#t;getContext(){if(!this.#t)throw new Error("arcgis-assistant-navigation-agent requires a mapView");return{mapView:this.#t}}async load(){this.#t=await i(this,"arcgis-assistant-navigation-agent"),e(this)}};s("arcgis-assistant-navigation-agent",t);return t},b,c)
@@ -1,2 +1,2 @@
1
1
  /* COPYRIGHT Esri - https://js.arcgis.com/5.1/LICENSE.txt */
2
- import c from"./6ULHJSIQ.js";import b from"./R3LASMEM.js";import{a as s,b as a}from"./M672SFG6.js";import"./I22GHLAO.js";import"./WBSNYWJJ.js";import{p as r,t as e}from"./26V7SXDR.js";import"./CFDTXKJ6.js";export default $arcgis.t(([,{c:i}])=>{var t=class extends r{constructor(){super(...arguments),this.agent=i}static{this.properties={referenceElement:1}}#t;getContext(){if(!this.#t)throw new Error("arcgis-assistant-layer-filter-agent requires a mapView");return{mapView:this.#t}}async load(){this.#t=await s(this,"arcgis-assistant-layer-filter-agent"),a(this)}};e("arcgis-assistant-layer-filter-agent",t);return t},b,c)
2
+ import c from"./AIAY4NON.js";import b from"./2PLHSU7P.js";import{a as s,b as a}from"./M672SFG6.js";import"./I22GHLAO.js";import"./WBSNYWJJ.js";import{p as r,t as e}from"./26V7SXDR.js";import"./CFDTXKJ6.js";export default $arcgis.t(([,{c:i}])=>{var t=class extends r{constructor(){super(...arguments),this.agent=i}static{this.properties={referenceElement:1}}#t;getContext(){if(!this.#t)throw new Error("arcgis-assistant-layer-filter-agent requires a mapView");return{mapView:this.#t}}async load(){this.#t=await s(this,"arcgis-assistant-layer-filter-agent"),a(this)}};e("arcgis-assistant-layer-filter-agent",t);return t},b,c)