@arcgis/ai-components 5.1.0-next.85 → 5.1.0-next.87

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,2 +1,2 @@
1
1
  /* COPYRIGHT Esri - https://js.arcgis.com/5.1/LICENSE.txt */
2
- import c from"./WASYNIGU.js";import b from"./T7NKER3A.js";import"./PLPJJRCP.js";import{a as i,c as e}from"./B4DEC7PH.js";import"./KVH3PDVW.js";import"./YGW7TUNX.js";import{v as a,y as s}from"./AKEZZ3RP.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}}load(){this.#t=i(this,"arcgis-assistant-navigation-agent"),e(this)}};s("arcgis-assistant-navigation-agent",t);return t},b,c)
2
+ import c from"./ZIER3BNM.js";import b from"./FTUILS6R.js";import"./PLPJJRCP.js";import{a as i,c as e}from"./B4DEC7PH.js";import"./KVH3PDVW.js";import"./YGW7TUNX.js";import{v as a,y as s}from"./AKEZZ3RP.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}}load(){this.#t=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"./T7NKER3A.js";import{a as $}from"./VSZNNBU6.js";import"./PLPJJRCP.js";import{a as S}from"./KVH3PDVW.js";import"./YGW7TUNX.js";import{g as _,h as a,l as f,n as o,t as y,u as b,v as w,y as E}from"./AKEZZ3RP.js";import"./CFDTXKJ6.js";export default $arcgis.t(([P,{whenOnce:L,watch:x,when:R},O,M,{property:d,subclass:A},{d:k}])=>{var V=_`:host{display:block;width:var(--arcgis-internal-panel-width, 100%);height:var(--arcgis-internal-expand-max-height, 100%)}.footer-container{display:flex;flex-direction:column;flex:1 1 0;gap:var(--calcite-spacing-md)}.content-container{display:flex;flex-direction:column;flex:1 1 0;min-height:0;position:relative;overflow:auto}.suggested-prompts-container{display:flex;justify-content:center;width:100%}.suggested-prompts{display:block;padding:var(--calcite-spacing-md);max-width:100%;box-sizing:border-box}`,z=Object.defineProperty,j=Object.getOwnPropertyDescriptor,h=(g,t,e,i)=>{for(var s=i>1?void 0:i?j(t,e):t,r=g.length-1,n;r>=0;r--)(n=g[r])&&(s=(i?n(t,e,s):n(s))||s);return i&&s&&z(t,e,s),s},l=class extends M{constructor(g){super(g),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 L(()=>!this.view.updating),this._set("orchestrator",await k.init({agents:[...this.agents],view:this.view??void 0})),this.addHandles([x(()=>[this.view,this.agents],()=>{this._initialize()})])}clearChatHistory(){this.orchestrator?.newConversation()}async*ask(g,t){if(!this.orchestrator)throw new Error("Orchestrator not initialized yet.");this._set("processing",!0),this._set("processingStep","");let e=[],i;try{let s=this.orchestrator.ask(g);for await(let r of s){let n=r.runId;if(t?.aborted){yield{type:"cancelled",runId:n};break}switch(r.type){case"trace":{this._set("processingStep",r.data.text),e.push(r.data.text);break}case"completed":{let c=r.result,p=!!c.content.length,m=!!i?.length;if(!p&&!m){yield{type:"completed",error:"Could not process the request.",log:e,runId:n};return}let u=c.content;this._set("processingStep",""),yield{type:"completed",response:u,blocks:i,log:e,runId:n};return}case"ux-suggestion":{let c=r.suggestion;i=i?[...i,c]:[c];break}case"interrupt":{let{kind:c,message:p,metadata:m}=r.interrupt,u=Array.isArray(m)?m.filter(I=>typeof I=="string"):[],C=(()=>{switch(c){case"booleanChoice":return{type:"boolean-choice",message:p,options:u};case"singleSelection":return{type:"single-select",message:p,options:u};case"multipleSelection":return{type:"multi-select",message:p,options:u};case"textInput":return{type:"text-input",message:p};default:return{type:c,message:p,options:u}}})();this._set("processingStep","Waiting for user input..."),yield{type:"interrupt",payload:C,runId:n};break}case"cancelled":{yield{type:"cancelled",runId:n};return}case"error":{yield{type:"completed",error:r.error.message,log:e,runId:n};return}default:{console.warn("Unknown event type:",r);break}}}}catch(s){console.warn("Error during message processing:",s),yield{type:"completed",error:"An error occurred during message processing.",log:e,runId:"error"};return}finally{this._set("processing",!1)}}};h([d({readOnly:!0})],l.prototype,"orchestrator",2);h([d()],l.prototype,"agents",2);h([d()],l.prototype,"portal",2);h([d()],l.prototype,"view",2);h([d({readOnly:!0})],l.prototype,"loading",2);h([d({readOnly:!0})],l.prototype,"processing",2);h([d({readOnly:!0})],l.prototype,"processingStep",2);l=h([A("OrchestratorController")],l);var H="Embeddings resource 'embeddings-v01.json' not found in the webmap portal item.",F="Embeddings not found for this web map.",N="https://developers.arcgis.com/javascript/latest/agentic-apps/ai-webmap-setup/#embeddings",v=class extends w{constructor(){super(...arguments),this._messages=$({blocking:!0}),this.#t=y(),this.#n=y(),this.#e=y(),this.#s=null,this.#o=new Map,this.#r=O.getDefault(),this.#i=t=>{t.stopPropagation(),this.cancelInterrupt()},this.#a=t=>{t.stopPropagation();let e=t.detail;this.submitInterrupt(e)},this.#l=t=>{t.stopPropagation(),this.keepSuggestedPrompts||(this.suggestedPrompts=[]);let e=t.detail;this._inputValue="",this.arcgisSubmit.emit(e),this.submitMessage(e)},this.#c=t=>{if(t.stopPropagation(),this.arcgisCancel.emit(),this._interrupt){this.orchestrator?.cancelInterrupt(),this._interrupt=null;return}this.#s?.abort()},this.#h=t=>{t.stopPropagation();let e=t.detail;this.arcgisFeedback.emit(e)},this.#g=t=>{t.stopPropagation();let e=t.detail;this._inputValue=e.prompt,this.arcgisPromptSelect.emit(e)},this._orchestratorController=null,this._interrupt=null,this._error=null,this._inputValue="",this.messages=new P([]),this.referenceElement=null,this.suggestedPrompts=[],this.feedbackEnabled=!1,this.keepSuggestedPrompts=!1,this.logEnabled=!1,this.copyEnabled=!1,this.voiceInputEnabled=!1,this.readAloudEnabled=!1,this.arcgisCancel=o(),this.arcgisError=o(),this.arcgisFeedback=o(),this.arcgisInterrupt=o(),this.arcgisInterruptCancel=o(),this.arcgisInterruptSubmit=o(),this.arcgisPromptSelect=o(),this.arcgisReady=o(),this.arcgisSubmit=o()}static{this.properties={_orchestratorController:16,_interrupt:16,_error:16,_inputValue:16,_user:16,awaitingResponse:32,awaitingResponseStep:32,interrupt:32,messages:0,orchestrator:32,entryMessage:1,heading:1,description:1,referenceElement:1,suggestedPrompts:0,feedbackEnabled:5,keepSuggestedPrompts:5,logEnabled:5,copyEnabled:5,voiceInputEnabled:5,readAloudEnabled:5}}static{this.styles=V}#t;#n;#e;#s;#o;#r;#i;#a;#l;#c;#h;#g;async#p(){try{let t=S(this.el,this.referenceElement);await t?.componentOnReady();let e=[...this.#o.values()];return e.length?(this._orchestratorController=new l({agents:e,portal:this.#r,view:t?.view}),await this._orchestratorController.load(),!0):(this._error="No agents found.",!1)}catch(t){return this._error=t?.message??"Error initializing orchestrator.",f(this)(t),!1}}get _user(){return this.#r?.user?.fullName||this.#r?.user?.username}get awaitingResponse(){return this._orchestratorController?.processing??!1}get awaitingResponseStep(){return this._orchestratorController?.processingStep??""}get interrupt(){return this._interrupt}get orchestrator(){return this._orchestratorController?.orchestrator}async clearChatHistory(){this._reset(),this._orchestratorController?.clearChatHistory()}cancelInterrupt(){this.arcgisInterruptCancel.emit(),this.orchestrator?.cancelInterrupt(),this._interrupt=null}register(t){this.#o.set(t.agent.id,t)}async submitMessage(t){let e=t.trim();if(!e||(this.messages.push({id:Date.now().toString(),role:"user",content:e}),!this._orchestratorController))return;let i=this._orchestratorController.ask(e,this.#s?.signal);for await(let s of i){let r=s.runId;switch(s.type){case"completed":this.messages.push({role:"assistant",content:s.response,blocks:s.blocks,log:s.log,error:s.error,id:r});break;case"interrupt":this._interrupt={...s.payload,id:r},this.arcgisInterrupt.emit(this._interrupt);break;case"cancelled":this.messages.push({role:"assistant",error:"Request cancelled.",id:r});break}}}submitInterrupt(t){this.arcgisInterruptSubmit.emit(t),this.orchestrator?.resumeInterrupt(t),this._interrupt=null}load(){this.manager.onLifecycle(this._reset.bind(this))}loaded(){this.manager.onLifecycle(()=>{this.#t.value?.addEventListener("arcgisPromptSelect",this.#g),this.#t.value?.addEventListener("arcgisSubmit",this.#l),this.#t.value?.addEventListener("arcgisCancel",this.#c),this.#t.value?.addEventListener("arcgisFeedback",this.#h);let t=R(()=>!!this._interrupt&&!!this.#e.value,()=>{let e=this.#e.value;e.removeEventListener("arcgisSubmit",this.#a),e.removeEventListener("arcgisCancel",this.#i),e.addEventListener("arcgisSubmit",this.#a,{once:!0}),e.addEventListener("arcgisCancel",this.#i,{once:!0})});return queueMicrotask(()=>{this.#p().then(e=>{e?this.arcgisReady.emit():this._error&&this.arcgisError.emit(new Error(this._error))})}),()=>{t.remove(),this.#t.value?.removeEventListener("arcgisPromptSelect",this.#g),this.#e.value?.removeEventListener("arcgisSubmit",this.#a),this.#e.value?.removeEventListener("arcgisCancel",this.#i),this.#t.value?.removeEventListener("arcgisSubmit",this.#l),this.#t.value?.removeEventListener("arcgisCancel",this.#c),this.#t.value?.removeEventListener("arcgisFeedback",this.#h),this._orchestratorController?.destroy(),this._orchestratorController=null}})}_reset(){this.#s?.abort(),this._interrupt=null,this.messages.removeAll(),this._error=null,this._inputValue=""}_renderEntryMessage(){return this._interrupt?a`<slot name=interrupt><arcgis-assistant-interrupt .type=${this._interrupt.type} .message=${this._interrupt.message} .options=${this._interrupt.options} ${b(this.#e)}></arcgis-assistant-interrupt></slot>`:this._error?this._renderErrorNotice():this.entryMessage?this.messages.length>0?null:a`<calcite-notice open kind=info closable icon width=full><div slot=message>${this.entryMessage}</div></calcite-notice>`:a`<slot name=entry-message></slot>`}_renderErrorNotice(){return this._error?a`<calcite-notice closable slot=entry-message open kind=danger icon width=full>${this._error===H?a`<div slot=message>${F}</div><calcite-link slot=link .href=${N} target=_blank title="Learn about web map embeddings">Read more</calcite-link>`:a`<div slot=message>${this._error}</div>`}</calcite-notice>`:null}_renderSuggestedPrompts(){return this.suggestedPrompts?.length?a`<div class="suggested-prompts-container"><arcgis-assistant-suggested-prompts class="suggested-prompts" .prompts=${this.suggestedPrompts}></arcgis-assistant-suggested-prompts></div>`:null}render(){return a`<calcite-panel .loading=${!this._orchestratorController&&!this._error||this._orchestratorController?.loading} .heading=${this.heading??this._messages.assistantLabel} .description=${this.description} ${b(this.#t)}><slot name=header-actions-start slot=header-actions-start></slot><slot name=header-actions-end slot=header-actions-end></slot><div class="content-container"><arcgis-assistant-chat .loading=${this.awaitingResponse} .messages=${this.messages}><slot name=message-starter slot=message-starter></slot><slot name=messages slot=messages>${this.messages.map(t=>t.role==="assistant"?a`<arcgis-assistant-message .message=${t} .feedbackEnabled=${this.feedbackEnabled} .logEnabled=${this.logEnabled} .copyEnabled=${this.copyEnabled} .readAloudEnabled=${this.readAloudEnabled}></arcgis-assistant-message>`:a`<arcgis-assistant-user-message .message=${t} .user=${this._user}></arcgis-assistant-user-message>`)}</slot><slot name=message-loading slot=message-loading><arcgis-assistant-message-loading .loading=${this.awaitingResponse} .loadingMessage=${this.awaitingResponseStep}></arcgis-assistant-message-loading></slot></arcgis-assistant-chat></div>${this._renderSuggestedPrompts()}<div class="footer-container" slot=footer>${this._renderEntryMessage()}<slot name=chat-entry><arcgis-assistant-chat-entry .awaitingResponse=${this.awaitingResponse} .inputValue=${this._inputValue} .messages=${this.messages} .voiceInputEnabled=${this.voiceInputEnabled} ${b(this.#n)}><slot name=entry-actions-start slot=entry-actions-start></slot><slot name=entry-actions-end slot=entry-actions-end><calcite-button .iconStart=${this.awaitingResponse?"circle-stop":"send"} @click=${()=>{this.#n.value?.submitMessage()}} round>${this.awaitingResponse?this._messages.stopButtonLabel:this._messages.askButtonLabel}</calcite-button></slot></arcgis-assistant-chat-entry></slot><slot name=footer-content></slot></div></calcite-panel>`}};E("arcgis-assistant",v);return v},"core/Collection","core/reactiveUtils","portal/Portal","core/Accessor","core/accessorSupport/decorators",c)
2
+ import c from"./FTUILS6R.js";import{a as $}from"./VSZNNBU6.js";import"./PLPJJRCP.js";import{a as S}from"./KVH3PDVW.js";import"./YGW7TUNX.js";import{g as _,h as a,l as f,n as o,t as y,u as b,v as w,y as E}from"./AKEZZ3RP.js";import"./CFDTXKJ6.js";export default $arcgis.t(([P,{whenOnce:L,watch:x,when:R},O,M,{property:d,subclass:A},{d:k}])=>{var V=_`:host{display:block;width:var(--arcgis-internal-panel-width, 100%);height:var(--arcgis-internal-expand-max-height, 100%)}.footer-container{display:flex;flex-direction:column;flex:1 1 0;gap:var(--calcite-spacing-md)}.content-container{display:flex;flex-direction:column;flex:1 1 0;min-height:0;position:relative;overflow:auto}.suggested-prompts-container{display:flex;justify-content:center;width:100%}.suggested-prompts{display:block;padding:var(--calcite-spacing-md);max-width:100%;box-sizing:border-box}`,z=Object.defineProperty,j=Object.getOwnPropertyDescriptor,h=(g,t,e,i)=>{for(var s=i>1?void 0:i?j(t,e):t,r=g.length-1,n;r>=0;r--)(n=g[r])&&(s=(i?n(t,e,s):n(s))||s);return i&&s&&z(t,e,s),s},l=class extends M{constructor(g){super(g),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 L(()=>!this.view.updating),this._set("orchestrator",await k.init({agents:[...this.agents],view:this.view??void 0})),this.addHandles([x(()=>[this.view,this.agents],()=>{this._initialize()})])}clearChatHistory(){this.orchestrator?.newConversation()}async*ask(g,t){if(!this.orchestrator)throw new Error("Orchestrator not initialized yet.");this._set("processing",!0),this._set("processingStep","");let e=[],i;try{let s=this.orchestrator.ask(g);for await(let r of s){let n=r.runId;if(t?.aborted){yield{type:"cancelled",runId:n};break}switch(r.type){case"trace":{this._set("processingStep",r.data.text),e.push(r.data.text);break}case"completed":{let c=r.result,p=!!c.content.length,m=!!i?.length;if(!p&&!m){yield{type:"completed",error:"Could not process the request.",log:e,runId:n};return}let u=c.content;this._set("processingStep",""),yield{type:"completed",response:u,blocks:i,log:e,runId:n};return}case"ux-suggestion":{let c=r.suggestion;i=i?[...i,c]:[c];break}case"interrupt":{let{kind:c,message:p,metadata:m}=r.interrupt,u=Array.isArray(m)?m.filter(I=>typeof I=="string"):[],C=(()=>{switch(c){case"booleanChoice":return{type:"boolean-choice",message:p,options:u};case"singleSelection":return{type:"single-select",message:p,options:u};case"multipleSelection":return{type:"multi-select",message:p,options:u};case"textInput":return{type:"text-input",message:p};default:return{type:c,message:p,options:u}}})();this._set("processingStep","Waiting for user input..."),yield{type:"interrupt",payload:C,runId:n};break}case"cancelled":{yield{type:"cancelled",runId:n};return}case"error":{yield{type:"completed",error:r.error.message,log:e,runId:n};return}default:{console.warn("Unknown event type:",r);break}}}}catch(s){console.warn("Error during message processing:",s),yield{type:"completed",error:"An error occurred during message processing.",log:e,runId:"error"};return}finally{this._set("processing",!1)}}};h([d({readOnly:!0})],l.prototype,"orchestrator",2);h([d()],l.prototype,"agents",2);h([d()],l.prototype,"portal",2);h([d()],l.prototype,"view",2);h([d({readOnly:!0})],l.prototype,"loading",2);h([d({readOnly:!0})],l.prototype,"processing",2);h([d({readOnly:!0})],l.prototype,"processingStep",2);l=h([A("OrchestratorController")],l);var H="Embeddings resource 'embeddings-v01.json' not found in the webmap portal item.",F="Embeddings not found for this web map.",N="https://developers.arcgis.com/javascript/latest/agentic-apps/ai-webmap-setup/#embeddings",v=class extends w{constructor(){super(...arguments),this._messages=$({blocking:!0}),this.#t=y(),this.#n=y(),this.#e=y(),this.#s=null,this.#o=new Map,this.#r=O.getDefault(),this.#i=t=>{t.stopPropagation(),this.cancelInterrupt()},this.#a=t=>{t.stopPropagation();let e=t.detail;this.submitInterrupt(e)},this.#l=t=>{t.stopPropagation(),this.keepSuggestedPrompts||(this.suggestedPrompts=[]);let e=t.detail;this._inputValue="",this.arcgisSubmit.emit(e),this.submitMessage(e)},this.#c=t=>{if(t.stopPropagation(),this.arcgisCancel.emit(),this._interrupt){this.orchestrator?.cancelInterrupt(),this._interrupt=null;return}this.#s?.abort()},this.#h=t=>{t.stopPropagation();let e=t.detail;this.arcgisFeedback.emit(e)},this.#g=t=>{t.stopPropagation();let e=t.detail;this._inputValue=e.prompt,this.arcgisPromptSelect.emit(e)},this._orchestratorController=null,this._interrupt=null,this._error=null,this._inputValue="",this.messages=new P([]),this.referenceElement=null,this.suggestedPrompts=[],this.feedbackEnabled=!1,this.keepSuggestedPrompts=!1,this.logEnabled=!1,this.copyEnabled=!1,this.voiceInputEnabled=!1,this.readAloudEnabled=!1,this.arcgisCancel=o(),this.arcgisError=o(),this.arcgisFeedback=o(),this.arcgisInterrupt=o(),this.arcgisInterruptCancel=o(),this.arcgisInterruptSubmit=o(),this.arcgisPromptSelect=o(),this.arcgisReady=o(),this.arcgisSubmit=o()}static{this.properties={_orchestratorController:16,_interrupt:16,_error:16,_inputValue:16,_user:16,awaitingResponse:32,awaitingResponseStep:32,interrupt:32,messages:0,orchestrator:32,entryMessage:1,heading:1,description:1,referenceElement:1,suggestedPrompts:0,feedbackEnabled:5,keepSuggestedPrompts:5,logEnabled:5,copyEnabled:5,voiceInputEnabled:5,readAloudEnabled:5}}static{this.styles=V}#t;#n;#e;#s;#o;#r;#i;#a;#l;#c;#h;#g;async#p(){try{let t=S(this.el,this.referenceElement);await t?.componentOnReady();let e=[...this.#o.values()];return e.length?(this._orchestratorController=new l({agents:e,portal:this.#r,view:t?.view}),await this._orchestratorController.load(),!0):(this._error="No agents found.",!1)}catch(t){return this._error=t?.message??"Error initializing orchestrator.",f(this)(t),!1}}get _user(){return this.#r?.user?.fullName||this.#r?.user?.username}get awaitingResponse(){return this._orchestratorController?.processing??!1}get awaitingResponseStep(){return this._orchestratorController?.processingStep??""}get interrupt(){return this._interrupt}get orchestrator(){return this._orchestratorController?.orchestrator}async clearChatHistory(){this._reset(),this._orchestratorController?.clearChatHistory()}cancelInterrupt(){this.arcgisInterruptCancel.emit(),this.orchestrator?.cancelInterrupt(),this._interrupt=null}register(t){this.#o.set(t.agent.id,t)}async submitMessage(t){let e=t.trim();if(!e||(this.messages.push({id:Date.now().toString(),role:"user",content:e}),!this._orchestratorController))return;let i=this._orchestratorController.ask(e,this.#s?.signal);for await(let s of i){let r=s.runId;switch(s.type){case"completed":this.messages.push({role:"assistant",content:s.response,blocks:s.blocks,log:s.log,error:s.error,id:r});break;case"interrupt":this._interrupt={...s.payload,id:r},this.arcgisInterrupt.emit(this._interrupt);break;case"cancelled":this.messages.push({role:"assistant",error:"Request cancelled.",id:r});break}}}submitInterrupt(t){this.arcgisInterruptSubmit.emit(t),this.orchestrator?.resumeInterrupt(t),this._interrupt=null}load(){this.manager.onLifecycle(this._reset.bind(this))}loaded(){this.manager.onLifecycle(()=>{this.#t.value?.addEventListener("arcgisPromptSelect",this.#g),this.#t.value?.addEventListener("arcgisSubmit",this.#l),this.#t.value?.addEventListener("arcgisCancel",this.#c),this.#t.value?.addEventListener("arcgisFeedback",this.#h);let t=R(()=>!!this._interrupt&&!!this.#e.value,()=>{let e=this.#e.value;e.removeEventListener("arcgisSubmit",this.#a),e.removeEventListener("arcgisCancel",this.#i),e.addEventListener("arcgisSubmit",this.#a,{once:!0}),e.addEventListener("arcgisCancel",this.#i,{once:!0})});return queueMicrotask(()=>{this.#p().then(e=>{e?this.arcgisReady.emit():this._error&&this.arcgisError.emit(new Error(this._error))})}),()=>{t.remove(),this.#t.value?.removeEventListener("arcgisPromptSelect",this.#g),this.#e.value?.removeEventListener("arcgisSubmit",this.#a),this.#e.value?.removeEventListener("arcgisCancel",this.#i),this.#t.value?.removeEventListener("arcgisSubmit",this.#l),this.#t.value?.removeEventListener("arcgisCancel",this.#c),this.#t.value?.removeEventListener("arcgisFeedback",this.#h),this._orchestratorController?.destroy(),this._orchestratorController=null}})}_reset(){this.#s?.abort(),this._interrupt=null,this.messages.removeAll(),this._error=null,this._inputValue=""}_renderEntryMessage(){return this._interrupt?a`<slot name=interrupt><arcgis-assistant-interrupt .type=${this._interrupt.type} .message=${this._interrupt.message} .options=${this._interrupt.options} ${b(this.#e)}></arcgis-assistant-interrupt></slot>`:this._error?this._renderErrorNotice():this.entryMessage?this.messages.length>0?null:a`<calcite-notice open kind=info closable icon width=full><div slot=message>${this.entryMessage}</div></calcite-notice>`:a`<slot name=entry-message></slot>`}_renderErrorNotice(){return this._error?a`<calcite-notice closable slot=entry-message open kind=danger icon width=full>${this._error===H?a`<div slot=message>${F}</div><calcite-link slot=link .href=${N} target=_blank title="Learn about web map embeddings">Read more</calcite-link>`:a`<div slot=message>${this._error}</div>`}</calcite-notice>`:null}_renderSuggestedPrompts(){return this.suggestedPrompts?.length?a`<div class="suggested-prompts-container"><arcgis-assistant-suggested-prompts class="suggested-prompts" .prompts=${this.suggestedPrompts}></arcgis-assistant-suggested-prompts></div>`:null}render(){return a`<calcite-panel .loading=${!this._orchestratorController&&!this._error||this._orchestratorController?.loading} .heading=${this.heading??this._messages.assistantLabel} .description=${this.description} ${b(this.#t)}><slot name=header-actions-start slot=header-actions-start></slot><slot name=header-actions-end slot=header-actions-end></slot><div class="content-container"><arcgis-assistant-chat .loading=${this.awaitingResponse} .messages=${this.messages}><slot name=message-starter slot=message-starter></slot><slot name=messages slot=messages>${this.messages.map(t=>t.role==="assistant"?a`<arcgis-assistant-message .message=${t} .feedbackEnabled=${this.feedbackEnabled} .logEnabled=${this.logEnabled} .copyEnabled=${this.copyEnabled} .readAloudEnabled=${this.readAloudEnabled}></arcgis-assistant-message>`:a`<arcgis-assistant-user-message .message=${t} .user=${this._user}></arcgis-assistant-user-message>`)}</slot><slot name=message-loading slot=message-loading><arcgis-assistant-message-loading .loading=${this.awaitingResponse} .loadingMessage=${this.awaitingResponseStep}></arcgis-assistant-message-loading></slot></arcgis-assistant-chat></div>${this._renderSuggestedPrompts()}<div class="footer-container" slot=footer>${this._renderEntryMessage()}<slot name=chat-entry><arcgis-assistant-chat-entry .awaitingResponse=${this.awaitingResponse} .inputValue=${this._inputValue} .messages=${this.messages} .voiceInputEnabled=${this.voiceInputEnabled} ${b(this.#n)}><slot name=entry-actions-start slot=entry-actions-start></slot><slot name=entry-actions-end slot=entry-actions-end><calcite-button .iconStart=${this.awaitingResponse?"circle-stop":"send"} @click=${()=>{this.#n.value?.submitMessage()}} round>${this.awaitingResponse?this._messages.stopButtonLabel:this._messages.askButtonLabel}</calcite-button></slot></arcgis-assistant-chat-entry></slot><slot name=footer-content></slot></div></calcite-panel>`}};E("arcgis-assistant",v);return v},"core/Collection","core/reactiveUtils","portal/Portal","core/Accessor","core/accessorSupport/decorators",c)
@@ -1,2 +1,2 @@
1
1
  /* COPYRIGHT Esri - https://js.arcgis.com/5.1/LICENSE.txt */
2
- import c from"./WASYNIGU.js";import b from"./T7NKER3A.js";import"./PLPJJRCP.js";import{a as r,c as a}from"./B4DEC7PH.js";import"./KVH3PDVW.js";import"./YGW7TUNX.js";import{v as s,y as e}from"./AKEZZ3RP.js";import"./CFDTXKJ6.js";export default $arcgis.t(([,{d:i}])=>{var t=class extends s{constructor(){super(...arguments),this.agent=i}static{this.properties={referenceElement:1}}#t;getContext(){if(!this.#t)throw new Error("arcgis-assistant-help-agent requires a mapView");return{mapView:this.#t}}load(){this.#t=r(this,"arcgis-assistant-help-agent"),a(this)}};e("arcgis-assistant-help-agent",t);return t},b,c)
2
+ import c from"./ZIER3BNM.js";import b from"./FTUILS6R.js";import"./PLPJJRCP.js";import{a as r,c as a}from"./B4DEC7PH.js";import"./KVH3PDVW.js";import"./YGW7TUNX.js";import{v as s,y as e}from"./AKEZZ3RP.js";import"./CFDTXKJ6.js";export default $arcgis.t(([,{d:i}])=>{var t=class extends s{constructor(){super(...arguments),this.agent=i}static{this.properties={referenceElement:1}}#t;getContext(){if(!this.#t)throw new Error("arcgis-assistant-help-agent requires a mapView");return{mapView:this.#t}}load(){this.#t=r(this,"arcgis-assistant-help-agent"),a(this)}};e("arcgis-assistant-help-agent",t);return t},b,c)
@@ -1,5 +1,5 @@
1
1
  /* COPYRIGHT Esri - https://js.arcgis.com/5.1/LICENSE.txt */
2
- import a from"./T7NKER3A.js";import{Bb as H,Fb as A,L as D,M as le,Q as ce,R as V,Za as N,_a as w,a as M,b as E,g as Ie,j as W,k as K,kb as g,q as ke,qb as _e,u as $e}from"./PLPJJRCP.js";export default $arcgis.t(([ct,ye,Pe,dt,{addressToLocations:ut},O,ue,mt,Ge,Be,{formatDateOnly:pt,convertDateFormatToIntlOptions:Z,formatTimeOnly:ht,formatDate:Ae},Qe,Ue,ft,gt,{createRenderer:yt},{getSchemesByTag:wt,getSchemes:bt},{getBackgroundColorTheme:Re},{createAgeRenderer:vt,createContinuousRenderer:xt},{getSchemesByTag:we},{createContinuousRenderer:St},{createRenderer:Tt},{getSchemesByTag:Et},{createRenderer:It},{getSchemesByTag:kt},{createRenderer:$t},{getSchemesByTag:_t},{createRenderer:Ct},{getSchemesByTag:Nt},{createAgeRenderer:Ft,createContinuousRenderer:Mt},{createRenderer:At},{getSchemesByTag:Rt},We,qe,Le,{executeQueryStreaming:qt},Lt,{a:s,b:h,c:k,e:Ce,f:Ne,g:j}])=>{var Me=e=>Array.isArray(e)&&e.every(D),nt=e=>typeof e=="object"&&e!=null&&"messages"in e&&Me(e.messages),it=e=>typeof e=="object"&&e!=null&&"lg_tool_call"in e,R=class extends _e{tools;handleToolErrors=!0;trace=!1;constructor(e,t){let{name:r,tags:a,handleToolErrors:o}=t??{};super({name:r,tags:a,func:(n,l)=>this.run(n,l)}),this.tools=e,this.handleToolErrors=o??this.handleToolErrors}async runTool(e,t){let r=this.tools.find(a=>a.name===e.name);try{if(r===void 0)throw new Error(`Tool "${e.name}" not found.`);let a=await r.invoke({...e,type:"tool_call"},t);return D(a)&&a.getType()==="tool"||K(a)?a:new le({status:"success",name:r.name,content:typeof a=="string"?a:JSON.stringify(a),tool_call_id:e.id})}catch(a){if(!this.handleToolErrors||$e(a))throw a;return new le({status:"error",content:`Error: ${a.message}
2
+ import a from"./FTUILS6R.js";import{Bb as H,Fb as A,L as D,M as le,Q as ce,R as V,Za as N,_a as w,a as M,b as E,g as Ie,j as W,k as K,kb as g,q as ke,qb as _e,u as $e}from"./PLPJJRCP.js";export default $arcgis.t(([ct,ye,Pe,dt,{addressToLocations:ut},O,ue,mt,Ge,Be,{formatDateOnly:pt,convertDateFormatToIntlOptions:Z,formatTimeOnly:ht,formatDate:Ae},Qe,Ue,ft,gt,{createRenderer:yt},{getSchemesByTag:wt,getSchemes:bt},{getBackgroundColorTheme:Re},{createAgeRenderer:vt,createContinuousRenderer:xt},{getSchemesByTag:we},{createContinuousRenderer:St},{createRenderer:Tt},{getSchemesByTag:Et},{createRenderer:It},{getSchemesByTag:kt},{createRenderer:$t},{getSchemesByTag:_t},{createRenderer:Ct},{getSchemesByTag:Nt},{createAgeRenderer:Ft,createContinuousRenderer:Mt},{createRenderer:At},{getSchemesByTag:Rt},We,qe,Le,{executeQueryStreaming:qt},Lt,{a:s,b:h,c:k,e:Ce,f:Ne,g:j}])=>{var Me=e=>Array.isArray(e)&&e.every(D),nt=e=>typeof e=="object"&&e!=null&&"messages"in e&&Me(e.messages),it=e=>typeof e=="object"&&e!=null&&"lg_tool_call"in e,R=class extends _e{tools;handleToolErrors=!0;trace=!1;constructor(e,t){let{name:r,tags:a,handleToolErrors:o}=t??{};super({name:r,tags:a,func:(n,l)=>this.run(n,l)}),this.tools=e,this.handleToolErrors=o??this.handleToolErrors}async runTool(e,t){let r=this.tools.find(a=>a.name===e.name);try{if(r===void 0)throw new Error(`Tool "${e.name}" not found.`);let a=await r.invoke({...e,type:"tool_call"},t);return D(a)&&a.getType()==="tool"||K(a)?a:new le({status:"success",name:r.name,content:typeof a=="string"?a:JSON.stringify(a),tool_call_id:e.id})}catch(a){if(!this.handleToolErrors||$e(a))throw a;return new le({status:"error",content:`Error: ${a.message}
3
3
  Please fix your mistakes.`,name:e.name,tool_call_id:e.id??""})}}async run(e,t){let r;if(it(e))r=[await this.runTool(e.lg_tool_call,t)];else{let n;if(Me(e))n=e;else if(nt(e))n=e.messages;else throw new Error("ToolNode only accepts BaseMessage[] or { messages: BaseMessage[] } as input.");let l=new Set(n.filter(c=>c.getType()==="tool").map(c=>c.tool_call_id)),i;for(let c=n.length-1;c>=0;c-=1){let d=n[c];if(V(d)){i=d;break}}if(i==null||!V(i))throw new Error("ToolNode only accepts AIMessages as input.");r=await Promise.all(i.tool_calls?.filter(c=>c.id==null||!l.has(c.id)).map(c=>this.runTool(c,t))??[])}if(!r.some(K))return Array.isArray(e)?r:{messages:r};let a=[],o=null;for(let n of r)K(n)?n.graph===W.PARENT&&Array.isArray(n.goto)&&n.goto.every(l=>Ie(l))?o?o.goto.push(...n.goto):o=new W({graph:W.PARENT,goto:n.goto}):a.push(n):a.push(Array.isArray(e)?[n]:{messages:[n]});return o&&a.push(o),a}};var Ci=g.Root({llmInputMessages:g({reducer:(e,t)=>H([],t),default:()=>[]})});var B=(e,t)=>({...e,...t}),Q=(e="",t)=>{let r=typeof t=="string"?t.trim():"";if(!r)return e;let a=e.trim();if(!a)return r;if(a===r)return e;let o=a.split(`
4
4
 
5
5
  `);return o[o.length-1]?.trim()===r?e:`${e}
@@ -11,7 +11,7 @@ ${Object.keys(ze).join(`
11
11
  `):"",l=e.vectorSearchFieldResults?.length>0?JSON.stringify(e.vectorSearchFieldResults,null,2):"",i=e.intent==="goToBookmark"&&o.bookmarks?.length?`Available bookmarks:
12
12
  ${JSON.stringify(o.bookmarks,null,2)}`:"",c=(e.intent==="goToLayer"||e.intent==="goToFeatures")&&e.vectorSearchLayerResults?.length?`Candidate layers:
13
13
  ${n}`:"",d=e.intent==="goToFeatures"&&e.vectorSearchFieldResults?.length?`Candidate fields:
14
- ${l}`:"",m={intent:e.intent,bookmarksSection:i,layersSection:c,fieldsSection:d,currentZoom:a.zoom,assignedTask:e.agentExecutionContext.assignedTask,userRequest:e.agentExecutionContext.userRequest,priorSteps:e.agentExecutionContext.priorSteps},u=await j({promptText:r,modelTier:"advanced",inputVariables:m,tools:be}),p=(u.tool_calls?.length??0)>0,y=typeof u.text=="string"?u.text.trim():"",T=y.length>0;return{...e,navigationInternalState:{...e.navigationInternalState,toolCallMessage:p?u:void 0},outputMessage:p?e.outputMessage:y,status:p?e.status:T?"partial":"failed"}}var U=(e,t=300)=>{let r=e.replace(/\s+/gu," ").replace(/[*_`#>\-]/gu,"").trim();return r.length>t?`${r.slice(0,t)}...`:r};async function xr(e,t){let r=new R(be);try{let a=e.navigationInternalState.toolCallMessage;if(!a)throw new Error("navigationToolCalling: missing navigationInternalState.toolCallMessage");let o=(await r.invoke({messages:[a]},t)).messages.map(n=>n.text).join(`
14
+ ${l}`:"",m={intent:e.intent,bookmarksSection:i,layersSection:c,fieldsSection:d,currentZoom:a.zoom,assignedTask:e.agentExecutionContext.assignedTask,userRequest:e.agentExecutionContext.userRequest,priorSteps:e.agentExecutionContext.priorSteps},u=await j({promptText:r,modelTier:"advanced",inputVariables:m,tools:be}),p=(u.tool_calls?.length??0)>0,y=typeof u.text=="string"?u.text.trim():"",T=y.length>0;return{...e,navigationInternalState:{...e.navigationInternalState,toolCallMessage:p?u:void 0},outputMessage:p?e.outputMessage:y,status:p?e.status:T?"success":"failed"}}var U=(e,t=300)=>{let r=e.replace(/\s+/gu," ").replace(/[*_`#>\-]/gu,"").trim();return r.length>t?`${r.slice(0,t)}...`:r};async function xr(e,t){let r=new R(be);try{let a=e.navigationInternalState.toolCallMessage;if(!a)throw new Error("navigationToolCalling: missing navigationInternalState.toolCallMessage");let o=(await r.invoke({messages:[a]},t)).messages.map(n=>n.text).join(`
15
15
  `);return await h({text:`Finished executing navigation tool: ${o}`},t),{...e,outputMessage:o,status:"success",summary:o?U(o):"Navigation executed.",navigationInternalState:{...e.navigationInternalState,toolCallMessage:void 0}}}catch(a){let o=a instanceof Error?a.message:String(a);return await h({text:`Navigation tool execution failed: ${o}`},t),{...e,outputMessage:`Navigation tool execution failed: ${o}`,status:"failed",summary:`Navigation tool execution failed: ${o}`,navigationInternalState:{...e.navigationInternalState,toolCallMessage:void 0}}}}async function Sr(e,t){let r=await q("navigation_intent_prompt"),{mapView:a}=_(t),o=be.map(u=>({name:u.name,description:u.description,schema:u.schema})),n=a.map,l=n.bookmarks?.length?`Available bookmarks:
16
16
  ${JSON.stringify(n.bookmarks,null,2)}`:"",i={tools:o.map(({name:u,description:p,schema:y})=>`${u}: ${p}, ${JSON.stringify(y)}`).join(`
17
17
  `),bookmarks:l,assignedTask:e.agentExecutionContext.assignedTask,userRequest:e.agentExecutionContext.userRequest,priorSteps:e.agentExecutionContext.priorSteps},c=s.object({intent:s.string()}),d=await Ne({promptText:r,inputVariables:i,schema:c}),m=typeof d.intent=="string"?d.intent.trim().replace(/^"|"$/gu,""):"";return{...e,intent:m||""}}var x=(e,t)=>{let r=e?.configurable?.services?.[t];if(r==null)throw new Error(`${t} missing in config.configurable.services`);return r},Tr=.7,Er=async(e,t)=>{try{await h({text:`Similarity search to find layers: ${e.agentExecutionContext.assignedTask}`},t);let r=x(t,"layerSearch"),a=x(t,"layersAndFieldsRegistry"),o=x(t,"embeddingCache"),n=(await r.searchLayers({text:e.agentExecutionContext.assignedTask,minScore:Tr,embeddingCache:o})).map(({id:i,score:c})=>{let d=a.get(i)?.layerItem;return{id:i,title:d?.title,name:d?.name??void 0,score:c}}),l;return n.length>0?l=`Vector search completed. Matching layers:
@@ -60,7 +60,7 @@ USE THIS TOOL FOR:
60
60
  - Spatial queries \u2014 finding features near/within/intersecting other features
61
61
  - Any question where the user wants to SEE or COUNT matching features
62
62
 
63
- This is the DEFAULT tool for most queries. When in doubt, use this tool.`,schema:ga}),Je=[Xr,na,ua,ya],Ye=[Qr,zr,Rr],wa=async(e,t)=>{await h({text:"Requesting LLM for layer filter results"},t);let r=await q("data_explore_filter_prompt");if(!t?.configurable)throw new Error("config.configurable is required for layer filter tools");let{userTimezone:a,userTimezoneOffset:o}=Ze(),n={layerFieldInfo:e.layerFieldInfo,userTimezone:a,userTimezoneOffset:o,queryResponse:e.queryResponse,assignedTask:e.agentExecutionContext.assignedTask,userRequest:e.agentExecutionContext.userRequest,priorSteps:e.agentExecutionContext.priorSteps},l=await j({promptText:r,modelTier:"advanced",messages:e.dataExplorationMessages,inputVariables:n,tools:Ye}),i=[...e.dataExplorationMessages,l];if(!((l.tool_calls?.length??0)>0))return await h({text:"LLM determined no filter changes needed"},t),{...e,dataExplorationMessages:i};let c=[...i,l],d=l.content.toString();return await ve(l,t),{...e,dataExplorationMessages:c,outputMessage:d}},ba=async(e,t)=>{await h({text:"Requesting LLM for layer query results"},t);let r=await q("data_explore_query_prompt");if(!t?.configurable)throw new Error("config.configurable is required for layer query tools");let{userTimezone:a,userTimezoneOffset:o}=Ze(),n={layerFieldInfo:e.layerFieldInfo,userTimezone:a,userTimezoneOffset:o,assignedTask:e.agentExecutionContext.assignedTask,userRequest:e.agentExecutionContext.userRequest,priorSteps:e.agentExecutionContext.priorSteps},l=await j({promptText:r,modelTier:"advanced",messages:e.dataExplorationMessages,inputVariables:n,tools:Je}),i=l.content.toString();return await ve(l,t),{...e,dataExplorationMessages:[...e.dataExplorationMessages,l],outputMessage:i,status:"partial",summary:i?U(i):"Query executed."}},va=async(e,t)=>{try{await h({text:"Requesting LLM for summary on query results"},t);let r=await q("summarize_query_response_prompt"),a={queryResponse:e.queryResponse,assignedTask:e.agentExecutionContext.assignedTask,userRequest:e.agentExecutionContext.userRequest,priorSteps:e.agentExecutionContext.priorSteps},o=await Ce({promptText:r,modelTier:"fast",messages:e.dataExplorationMessages,inputVariables:a}),n=typeof o=="string"?o:o.content,l=new ce(n);await h({text:`Received response from LLM: ${n}`},t);let i=n;return{...e,outputMessage:i,status:"success",summary:i?U(i):"Summary generated.",dataExplorationMessages:[...e.dataExplorationMessages,l]}}catch(r){throw await h({text:"Error during filter LLM request"},t),new Error(`Error during filter LLM request: ${r instanceof Error?r.message:String(r)}`)}};async function xa(e,t){let r=await new R(Ye).invoke({messages:e.dataExplorationMessages},t);return await h({text:`Finished executing layer filter tool: ${r.messages.map(a=>a.content).join(", ")}`},t),{...e}}var Sa=new R(Je);async function Ta(e,t){let{messages:r}=await Sa.invoke({messages:e.dataExplorationMessages},t),a=[],o=[];for(let n of r){let l=n.content,i;typeof l!="string"&&(i={tool:n.name??"unknown",layerName:"unknown",summary:"Query failed",details:{error:"Skipping non-string tool output:",raw:l}});try{typeof l=="string"?i=JSON.parse(l):i={tool:n.name??"unknown",layerName:"unknown",summary:"Query failed",details:{error:"Invalid tool output type",raw:l}}}catch{i={tool:n.name??"unknown",layerName:"unknown",summary:"Query failed",details:{error:l}}}a.push(i),i.details&&typeof i.details=="object"&&"error"in i.details?o.push(`- ${i.tool}: Error - ${String(i.details.error)}`):o.push(`- ${i.layerName}: ${i.summary}`)}return await h({text:`Finished executing layer query tool: ${o.join(", ")}`},t),{...e,dataExplorationMessages:[...e.dataExplorationMessages,...r],queryResponse:a,status:"partial",outputMessage:o.join(`
63
+ This is the DEFAULT tool for most queries. When in doubt, use this tool.`,schema:ga}),Je=[Xr,na,ua,ya],Ye=[Qr,zr,Rr],wa=async(e,t)=>{await h({text:"Requesting LLM for layer filter results"},t);let r=await q("data_explore_filter_prompt");if(!t?.configurable)throw new Error("config.configurable is required for layer filter tools");let{userTimezone:a,userTimezoneOffset:o}=Ze(),n={layerFieldInfo:e.layerFieldInfo,userTimezone:a,userTimezoneOffset:o,queryResponse:e.queryResponse,assignedTask:e.agentExecutionContext.assignedTask,userRequest:e.agentExecutionContext.userRequest,priorSteps:e.agentExecutionContext.priorSteps},l=await j({promptText:r,modelTier:"advanced",messages:e.dataExplorationMessages,inputVariables:n,tools:Ye}),i=[...e.dataExplorationMessages,l];if(!((l.tool_calls?.length??0)>0))return await h({text:"LLM determined no filter changes needed"},t),{...e,dataExplorationMessages:i};let c=[...i,l],d=l.content.toString();return await ve(l,t),{...e,dataExplorationMessages:c,outputMessage:d}},ba=async(e,t)=>{await h({text:"Requesting LLM for layer query results"},t);let r=await q("data_explore_query_prompt");if(!t?.configurable)throw new Error("config.configurable is required for layer query tools");let{userTimezone:a,userTimezoneOffset:o}=Ze(),n={layerFieldInfo:e.layerFieldInfo,userTimezone:a,userTimezoneOffset:o,assignedTask:e.agentExecutionContext.assignedTask,userRequest:e.agentExecutionContext.userRequest,priorSteps:e.agentExecutionContext.priorSteps},l=await j({promptText:r,modelTier:"advanced",messages:e.dataExplorationMessages,inputVariables:n,tools:Je}),i=l.content.toString();return await ve(l,t),{...e,dataExplorationMessages:[...e.dataExplorationMessages,l],outputMessage:i,status:"success",summary:i?U(i):"Query executed."}},va=async(e,t)=>{try{await h({text:"Requesting LLM for summary on query results"},t);let r=await q("summarize_query_response_prompt"),a={queryResponse:e.queryResponse,assignedTask:e.agentExecutionContext.assignedTask,userRequest:e.agentExecutionContext.userRequest,priorSteps:e.agentExecutionContext.priorSteps},o=await Ce({promptText:r,modelTier:"fast",messages:e.dataExplorationMessages,inputVariables:a}),n=typeof o=="string"?o:o.content,l=new ce(n);await h({text:`Received response from LLM: ${n}`},t);let i=n;return{...e,outputMessage:i,status:"success",summary:i?U(i):"Summary generated.",dataExplorationMessages:[...e.dataExplorationMessages,l]}}catch(r){throw await h({text:"Error during filter LLM request"},t),new Error(`Error during filter LLM request: ${r instanceof Error?r.message:String(r)}`)}};async function xa(e,t){let r=await new R(Ye).invoke({messages:e.dataExplorationMessages},t);return await h({text:`Finished executing layer filter tool: ${r.messages.map(a=>a.content).join(", ")}`},t),{...e}}var Sa=new R(Je);async function Ta(e,t){let{messages:r}=await Sa.invoke({messages:e.dataExplorationMessages},t),a=[],o=[];for(let n of r){let l=n.content,i;typeof l!="string"&&(i={tool:n.name??"unknown",layerName:"unknown",summary:"Query failed",details:{error:"Skipping non-string tool output:",raw:l}});try{typeof l=="string"?i=JSON.parse(l):i={tool:n.name??"unknown",layerName:"unknown",summary:"Query failed",details:{error:"Invalid tool output type",raw:l}}}catch{i={tool:n.name??"unknown",layerName:"unknown",summary:"Query failed",details:{error:l}}}a.push(i),i.details&&typeof i.details=="object"&&"error"in i.details?o.push(`- ${i.tool}: Error - ${String(i.details.error)}`):o.push(`- ${i.layerName}: ${i.summary}`)}return await h({text:`Finished executing layer query tool: ${o.join(", ")}`},t),{...e,dataExplorationMessages:[...e.dataExplorationMessages,...r],queryResponse:a,status:"success",outputMessage:o.join(`
64
64
  `),summary:o.length>0?U(o.join(`
65
65
  `)):"Query executed."}}var Ea=10,Ia=["string","small-integer","integer"],ka=async(e,t)=>{let r=null,a=null;try{if(t.type!=="geometry"&&t.type!=="oid"&&t.type!=="global-id"){r=await Qe({layer:e,field:t.name});let o=t.domain?.type==="coded-value"?t.domain:null;(Ia.includes(t.type)||o)&&(a=(await Ue({layer:e,field:t.name})).uniqueValueInfos.sort((n,l)=>l.count-n.count).slice(0,Ea),o&&(a=a.map(n=>({...n,value:o.getName(n.value)??n.value}))))}}catch(o){console.error(`Error fetching statistics for field ${t.name}:`,o)}return{summaryStatistics:r,uniqueValues:a}};async function $a(e,t,r){let a=[],o=[];for(let n of e){let l=function(p){let y=t.get(p)?.layerItem;return y?[y.name&&`Name: ${y.name}`,y.title&&`Title: ${y.title}`,y.description&&`Description: ${y.description}`].filter(Boolean).join(" | "):p},{layerId:i,results:c}=n,d=r.map?.allLayers.find(p=>p.id===i),m=t.get(i)?.fieldRegistry;if(!m)continue;let u=a.find(p=>p.layerId===i);u||(u={layerId:i,layerSummary:l(i),fieldInfos:[]},a.push(u));for(let p of c){let y=m.get(p.name);if(y){if(!y.statistics){let T=ka(d,y).then(f=>{m.set(y.name,{...y,statistics:f}),y.statistics=f});o.push(T)}u.fieldInfos.push(y)}}}return await Promise.all(o),a}var _a=async(e,t)=>{try{await h({text:"Getting statistics for vector search results"},t);let r=x(t,"layersAndFieldsRegistry"),{mapView:a}=L(t),o=await $a(e.vectorSearchFieldResults,r,a);return await h({text:"Statistics retrieved"},t),{...e,layerFieldInfo:o}}catch(r){throw await h({text:"Error during fetching statistics"},t),new Error(`Error during fetching statistics: ${r instanceof Error?r.message:String(r)}`)}},Oe=.7,Ca=10,Na=async(e,t)=>{try{await h({text:"Similarity search to find fields"},t);let r=x(t,"fieldSearch"),a=x(t,"layersAndFieldsRegistry"),o=x(t,"embeddingCache"),n=await r.searchFields({text:e.agentExecutionContext.assignedTask,layerIds:e.vectorSearchLayerIds,minScore:Oe,topResults:Ca,embeddingCache:o}),l=n.map(({layerId:c,results:d})=>{let m=d.map(u=>` - ${u.name} (${u.score.toFixed(2)})`).join(`
66
66
  `);return`${a.get(c)?.layerItem.name??c}:
package/dist/cdn/index.js CHANGED
@@ -1,2 +1,2 @@
1
1
  /* COPYRIGHT Esri - https://js.arcgis.com/5.1/LICENSE.txt */
2
- import{p as s,x as e}from"./AKEZZ3RP.js";import"./CFDTXKJ6.js";var a=s(e,{"arcgis-assistant":[()=>import("./7QVCJTXX.js"),"_messages:,awaitingResponse:,awaitingResponseStep:,copyEnabled,description,entryMessage,feedbackEnabled,heading,interrupt:,keepSuggestedPrompts,logEnabled,messages:,orchestrator:,readAloudEnabled,referenceElement,suggestedPrompts:,voiceInputEnabled;clearChatHistory,submitMessage;cancelInterrupt,register,submitInterrupt"],"arcgis-assistant-agent":[()=>import("./FZWNOKWO.js"),"agent:,context:;getContext"],"arcgis-assistant-data-exploration-agent":[()=>import("./43CR4HQU.js"),"referenceElement;;getContext"],"arcgis-assistant-help-agent":[()=>import("./QILCORIZ.js"),"referenceElement;;getContext"],"arcgis-assistant-layer-styling-agent":[()=>import("./ZHM6VL7C.js"),"referenceElement;;getContext"],"arcgis-assistant-navigation-agent":[()=>import("./VEF7NWH5.js"),"referenceElement;;getContext"],"arcgis-assistant-chat":[()=>import("./XUCS7JNA.js"),"loading,messages:"],"arcgis-assistant-chat-entry":[()=>import("./KJFC3ZEP.js"),"_messages:,awaitingResponse,entryPlaceholder,inputValue,keyboardShortcutsDisabled,messages:,status,voiceInputEnabled;submitMessage"],"arcgis-assistant-interrupt":[()=>import("./AAOF7JQT.js"),"_messages:,message,options:,type"],"arcgis-assistant-message":[()=>import("./OFWYCHDQ.js"),"copyEnabled,feedbackEnabled,footerDisabled,logEnabled,message:,readAloudEnabled"],"arcgis-assistant-message-block":[()=>import("./4MLHX7X5.js"),"block:"],"arcgis-assistant-message-content":[()=>import("./QTH2DYCO.js"),"message:"],"arcgis-assistant-message-feedback":[()=>import("./MDPF56RC.js"),"_messages:,feedbackEnabled,message:"],"arcgis-assistant-message-footer":[()=>import("./XMI2K6YV.js"),"_messages:,copyEnabled,feedbackEnabled,logEnabled,message:,readAloudEnabled"],"arcgis-assistant-message-loading":[()=>import("./FFQBDX6W.js"),"loading,loadingMessage"],"arcgis-assistant-message-log":[()=>import("./SNXQTZ5B.js"),"log:,logEnabled,showLog"],"arcgis-assistant-message-read-aloud":[()=>import("./3IWT4SEI.js"),"_messages:,message:,readAloudEnabled"],"arcgis-assistant-message-text":[()=>import("./6LFDWHQ4.js"),"content"],"arcgis-assistant-speech-input":[()=>import("./NY6TBJUU.js"),"awaitingResponse,inputValue,language,mode;;clearDraftSession"],"arcgis-assistant-suggested-prompts":[()=>import("./UWXD5PFQ.js"),"_messages:,label,prompts:"],"arcgis-assistant-user-message":[()=>import("./QUVGX4PA.js"),"content,message:,user"]});a({resourcesUrl:import.meta.url});var t=new CSSStyleSheet;t.replaceSync("@layer{:not([hydrated]):is(arcgis-assistant,arcgis-assistant-agent,arcgis-assistant-data-exploration-agent,arcgis-assistant-help-agent,arcgis-assistant-layer-styling-agent,arcgis-assistant-navigation-agent,arcgis-assistant-chat,arcgis-assistant-chat-entry,arcgis-assistant-interrupt,arcgis-assistant-message,arcgis-assistant-message-block,arcgis-assistant-message-content,arcgis-assistant-message-feedback,arcgis-assistant-message-footer,arcgis-assistant-message-loading,arcgis-assistant-message-log,arcgis-assistant-message-read-aloud,arcgis-assistant-message-text,arcgis-assistant-speech-input,arcgis-assistant-suggested-prompts,arcgis-assistant-user-message){visibility:hidden}}");document.adoptedStyleSheets=[...document.adoptedStyleSheets,t];window.$arcgis||Object.defineProperty(window,"$arcgis",{configurable:!1,enumerable:!0,writable:!1,value:{}}),((a,r)=>{a.t=(c,...x)=>Promise.all(x.map(x=>x.then?x:(!a?.forceESM&&a?.import||(x=>import(x+".js").then(m=>m.default??m)))("@arcgis/core/"+x))).then(c);r.p=a.t(([m])=>{r.t=m.trackAccess;r.o=m.createObservable;r.c=m.createTrackingTarget;r.r=m.runTracked},"applications/Components/reactiveUtils")})($arcgis,e)
2
+ import{p as s,x as e}from"./AKEZZ3RP.js";import"./CFDTXKJ6.js";var a=s(e,{"arcgis-assistant":[()=>import("./HLDIWEWD.js"),"_messages:,awaitingResponse:,awaitingResponseStep:,copyEnabled,description,entryMessage,feedbackEnabled,heading,interrupt:,keepSuggestedPrompts,logEnabled,messages:,orchestrator:,readAloudEnabled,referenceElement,suggestedPrompts:,voiceInputEnabled;clearChatHistory,submitMessage;cancelInterrupt,register,submitInterrupt"],"arcgis-assistant-agent":[()=>import("./FZWNOKWO.js"),"agent:,context:;getContext"],"arcgis-assistant-data-exploration-agent":[()=>import("./4TY43HO3.js"),"referenceElement;;getContext"],"arcgis-assistant-help-agent":[()=>import("./NCMEKPIM.js"),"referenceElement;;getContext"],"arcgis-assistant-layer-styling-agent":[()=>import("./2FQTU6HL.js"),"referenceElement;;getContext"],"arcgis-assistant-navigation-agent":[()=>import("./GJQVEIZF.js"),"referenceElement;;getContext"],"arcgis-assistant-chat":[()=>import("./XUCS7JNA.js"),"loading,messages:"],"arcgis-assistant-chat-entry":[()=>import("./KJFC3ZEP.js"),"_messages:,awaitingResponse,entryPlaceholder,inputValue,keyboardShortcutsDisabled,messages:,status,voiceInputEnabled;submitMessage"],"arcgis-assistant-interrupt":[()=>import("./AAOF7JQT.js"),"_messages:,message,options:,type"],"arcgis-assistant-message":[()=>import("./OFWYCHDQ.js"),"copyEnabled,feedbackEnabled,footerDisabled,logEnabled,message:,readAloudEnabled"],"arcgis-assistant-message-block":[()=>import("./4MLHX7X5.js"),"block:"],"arcgis-assistant-message-content":[()=>import("./QTH2DYCO.js"),"message:"],"arcgis-assistant-message-feedback":[()=>import("./MDPF56RC.js"),"_messages:,feedbackEnabled,message:"],"arcgis-assistant-message-footer":[()=>import("./XMI2K6YV.js"),"_messages:,copyEnabled,feedbackEnabled,logEnabled,message:,readAloudEnabled"],"arcgis-assistant-message-loading":[()=>import("./FFQBDX6W.js"),"loading,loadingMessage"],"arcgis-assistant-message-log":[()=>import("./SNXQTZ5B.js"),"log:,logEnabled,showLog"],"arcgis-assistant-message-read-aloud":[()=>import("./3IWT4SEI.js"),"_messages:,message:,readAloudEnabled"],"arcgis-assistant-message-text":[()=>import("./6LFDWHQ4.js"),"content"],"arcgis-assistant-speech-input":[()=>import("./NY6TBJUU.js"),"awaitingResponse,inputValue,language,mode;;clearDraftSession"],"arcgis-assistant-suggested-prompts":[()=>import("./UWXD5PFQ.js"),"_messages:,label,prompts:"],"arcgis-assistant-user-message":[()=>import("./QUVGX4PA.js"),"content,message:,user"]});a({resourcesUrl:import.meta.url});var t=new CSSStyleSheet;t.replaceSync("@layer{:not([hydrated]):is(arcgis-assistant,arcgis-assistant-agent,arcgis-assistant-data-exploration-agent,arcgis-assistant-help-agent,arcgis-assistant-layer-styling-agent,arcgis-assistant-navigation-agent,arcgis-assistant-chat,arcgis-assistant-chat-entry,arcgis-assistant-interrupt,arcgis-assistant-message,arcgis-assistant-message-block,arcgis-assistant-message-content,arcgis-assistant-message-feedback,arcgis-assistant-message-footer,arcgis-assistant-message-loading,arcgis-assistant-message-log,arcgis-assistant-message-read-aloud,arcgis-assistant-message-text,arcgis-assistant-speech-input,arcgis-assistant-suggested-prompts,arcgis-assistant-user-message){visibility:hidden}}");document.adoptedStyleSheets=[...document.adoptedStyleSheets,t];window.$arcgis||Object.defineProperty(window,"$arcgis",{configurable:!1,enumerable:!0,writable:!1,value:{}}),((a,r)=>{a.t=(c,...x)=>Promise.all(x.map(x=>x.then?x:(!a?.forceESM&&a?.import||(x=>import(x+".js").then(m=>m.default??m)))("@arcgis/core/"+x))).then(c);r.p=a.t(([m])=>{r.t=m.trackAccess;r.o=m.createObservable;r.c=m.createTrackingTarget;r.r=m.runTracked},"applications/Components/reactiveUtils")})($arcgis,e)