@arcgis/ai-components 5.1.0-next.102 → 5.1.0-next.103
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/dist/cdn/{L6A7BGIF.js → 7O3BAVC3.js} +1 -1
- package/dist/cdn/{25OJ5FXG.js → IYWZ7KR5.js} +1 -1
- package/dist/cdn/{7M7EPP5U.js → MXVYKCXV.js} +1 -1
- package/dist/cdn/{RUG4CKQX.js → P6VE72RL.js} +1 -1
- package/dist/cdn/{TSIUD5CY.js → PE3TLAMZ.js} +1 -1
- package/dist/cdn/{2GGXJKQD.js → WJLYLYKX.js} +1 -1
- package/dist/cdn/{VHOF6SUZ.js → Z7GVYVWK.js} +2 -1
- package/dist/cdn/{LOXY54T6.js → ZKQG2EZQ.js} +22 -22
- package/dist/cdn/index.js +1 -1
- package/dist/docs/api.json +1 -1
- package/dist/docs/docs.json +1 -1
- package/dist/docs/web-types.json +1 -1
- package/package.json +6 -6
|
@@ -1,5 +1,5 @@
|
|
|
1
1
|
/* COPYRIGHT Esri - https://js.arcgis.com/5.1/LICENSE.txt */
|
|
2
|
-
import a from"./
|
|
2
|
+
import a from"./ZKQG2EZQ.js";import{Bb as P,Fb as C,L as V,M as le,Q as ce,R as G,Za as F,_a as y,a as q,b as E,g as _e,j as X,k as ee,kb as v,q as Ne,qb as Me,u as Fe}from"./XHPF5TWW.js";export default $arcgis.t(([It,kt,{addressToLocations:$t},j,pe,_t,Ue,Nt,We,He,{formatDateOnly:Ft,convertDateFormatToIntlOptions:te,formatTimeOnly:Mt,formatDate:Le},Ze,Je,qt,Ct,{createRenderer:At},{getSchemesByTag:Rt,getSchemes:Lt},{getBackgroundColorTheme:ze},{createAgeRenderer:zt,createContinuousRenderer:jt},{getSchemesByTag:xe},{createContinuousRenderer:Dt},{createRenderer:Ot},{getSchemesByTag:Vt},{createRenderer:Gt},{getSchemesByTag:Pt},{createRenderer:Qt},{getSchemesByTag:Bt},{createRenderer:Kt},{getSchemesByTag:Ut},{createAgeRenderer:Wt,createContinuousRenderer:Ht},{createRenderer:Zt},{getSchemesByTag:Jt},,{fetchKnowledgeGraph:je,executeQueryStreaming:Yt,executeSearchStreaming:Xt},er,Ye,De,Oe,tr,{a:l,b:Q,c:qe,d:g,e:I,g:Ce,h:de,i:D}])=>{var Re=e=>Array.isArray(e)&&e.every(V),St=e=>typeof e=="object"&&e!=null&&"messages"in e&&Re(e.messages),xt=e=>typeof e=="object"&&e!=null&&"lg_tool_call"in e,A=class extends Me{tools;handleToolErrors=!0;trace=!1;constructor(e,t){let{name:r,tags:a,handleToolErrors:o}=t??{};super({name:r,tags:a,func:(n,i)=>this.run(n,i)}),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 V(a)&&a.getType()==="tool"||ee(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||Fe(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(xt(e))r=[await this.runTool(e.lg_tool_call,t)];else{let n;if(Re(e))n=e;else if(St(e))n=e.messages;else throw new Error("ToolNode only accepts BaseMessage[] or { messages: BaseMessage[] } as input.");let i=new Set(n.filter(d=>d.getType()==="tool").map(d=>d.tool_call_id)),s;for(let d=n.length-1;d>=0;d-=1){let c=n[d];if(G(c)){s=c;break}}if(s==null||!G(s))throw new Error("ToolNode only accepts AIMessages as input.");r=await Promise.all(s.tool_calls?.filter(d=>d.id==null||!i.has(d.id)).map(d=>this.runTool(d,t))??[])}if(!r.some(ee))return Array.isArray(e)?r:{messages:r};let a=[],o=null;for(let n of r)ee(n)?n.graph===X.PARENT&&Array.isArray(n.goto)&&n.goto.every(i=>_e(i))?o?o.goto.push(...n.goto):o=new X({graph:X.PARENT,goto:n.goto}):a.push(n):a.push(Array.isArray(e)?[n]:{messages:[n]});return o&&a.push(o),a}};var ps=v.Root({llmInputMessages:v({reducer:(e,t)=>P([],t),default:()=>[]})});var B=(e,t)=>t??e,Xe=v.Root({...qe(),intent:v({reducer:B}),vectorSearchLayerResults:v({reducer:B,default:()=>[]}),vectorSearchFieldResults:v({reducer:B}),navigationInternalState:v({reducer:B,default:()=>({toolCallMessage:void 0})})});async function rr(e,t){let r=j.getDefault().helperServices,a=r.geocode.find(p=>p.name==="ArcGIS World Geocoding Service")??r.geocode[0];if(!a)throw new Error("No geocoding service found in helperServices.");let o=a.url,n=`${pe.assetsPath?.endsWith("/")?pe.assetsPath:`${pe.assetsPath}/`}esri/images/search/search-symbol-32.png`,i=(await $t(o,{address:{SingleLine:e},outFields:["Match_addr"]}))?.[0];if(!i?.extent||!i.location)throw new Error(`Could not find location for: ${e}`);let s=new kt({url:n,width:24,height:24}),d=new It({geometry:i.location,symbol:s});t.graphics.removeAll(),t.graphics.add(d),await t.goTo(i.extent);let c={lastResolvedLocation:{value:{address:i.address??"",location:i.location?i.location.toJSON():null,extent:i.extent?i.extent.toJSON():null}}};return{text:`Successfully zoomed to ${e}.`,sharedStatePatch:c}}var ar=["mapView"];function k(e){let t=e?.configurable?.context;if(!t||typeof t!="object")throw new Error("NavigationAgent context missing");let r=ar.filter(a=>!(a in t));if(r.length)throw new Error(`NavigationAgent context missing: ${r.join(", ")}`);return t}async function or({address:e},t){let{mapView:r}=k(t);return await rr(e,r)}var nr=l.object({address:l.string().describe("The full address or place name to locate.")}),ir=y(or,{name:"goToAddress",description:"Geocodes an address using Esri's World Geocoding Service and zooms the map to that location.",schema:nr});async function sr(e,t){let r=t.map.bookmarks;if(!r||r.length===0)throw new Error("No bookmarks found in the map.");let a=r.find(n=>n.name===e);if(!a)throw new Error(`Bookmark with name "${e}" not found.`);let o=a.viewpoint;if(!o)throw new Error(`Bookmark with name "${e}" does not have a valid viewpoint.`);return await t.goTo(o),{text:`Navigated to bookmark: ${e}`}}async function lr({bookmarkName:e},t){let{mapView:r}=k(t);return await Promise.resolve(sr(e,r))}var cr=F.object({bookmarkName:F.string().describe("The name of the bookmark to navigate to.")}),dr=y(lr,{name:"goToBookmark",description:"Go to the extent of the bookmark with the given name.",schema:cr});async function ur(e,t,r){let a=r.map?.allLayers.find(n=>n.id===e);if(!a)return{text:`Error: Layer with id ${e} not found`};let o=a.createQuery();o.where=t??"1=1";try{let{extent:n,count:i}=await a.queryExtent(o);if(i===0)return{text:`No features found in ${a.title} matching: ${t}`};if(n)await r.goTo(n);else return{text:`Error: Unable to determine extent for ${a.title}`};return{text:`Successfully zoomed to ${i} feature(s) in ${a.title}`}}catch(n){return console.error("Error in goToFeatures:",n),{text:`Error: ${n instanceof Error?n.message:"Unknown error"}`}}}async function pr({layerId:e,where:t},r){let{mapView:a}=k(r);return await ur(e,t,a)}var hr=F.object({layerId:F.string().describe("The layerId of the layer to zoom to."),where:F.string().describe("The sql-92 where clause used to query features to zoom to")}),mr=y(pr,{name:"goToFeatures",description:"Go to the features that match the given filter related to the given layerId.",schema:hr});async function gr(e){let t=new _t({xmin:-180,ymin:-90,xmax:180,ymax:90,spatialReference:{wkid:4326}}).expand(.7);return await e.goTo(t),{text:"Successfully zoomed to world extent"}}async function fr(e,t){let{mapView:r}=k(t);return await gr(r)}var yr=F.object({}),wr=y(fr,{name:"goToFullExtent",description:"Zooms the map to the full world extent using Esri's Geocoding Service.",schema:yr});async function br(e){let t=e.map.initialViewProperties?.viewpoint?.targetGeometry;if(t)await e.goTo(t);else throw new Error("Initial extent is undefined");return{text:"Successfully zoomed to home extent"}}async function vr(e,t){let{mapView:r}=k(t);return await br(r)}var Sr=l.object({}),xr=y(vr,{name:"goToHomeExtent",description:"Go to the initial web map view extent",schema:Sr});async function Tr(e,t){await t.when();let r=t.map?.allLayers.find(o=>o.id===e);if(!r)return console.warn(`[goToLayer] No matching FeatureLayer found for: ${e}`),{text:`Could not find layer for: ${e}`};let a;return(r.type==="link-chart"||r.type==="knowledge-graph-sublayer")&&t.map?.activeLinkChartLayer?a=t.map.diagramNodesExtent:a=r.fullExtent,a?(await t.goTo(a),r.visible=!0,{text:`Successfully zoomed to: ${r.title??""}`}):{text:"Layer has no defined extent. Cannot zoom to layer."}}async function Er({layerId:e},t){let{mapView:r}=k(t);return await Tr(e,r)}var Ir=F.object({layerId:F.string().describe("The id of the layer to navigate to")}),kr=y(Er,{name:"goToLayer",description:"Zooms the map view to the full extent of the top matching layer.",schema:Ir});async function $r(e,t){return await t.goTo({scale:e}),{text:`Successfully zoomed to: ${e}`}}async function _r({scale:e},t){let{mapView:r}=k(t);return await $r(e,r)}var Nr=l.object({scale:l.number().describe("The map scale of the view to go to.")}),Fr=y(_r,{name:"goToScale",description:"Go to the specified view scale.",schema:Nr});async function Mr(e,t,r){let a={target:new Ue({longitude:e.longitude,latitude:e.latitude,spatialReference:{wkid:4326}})};return r?.zoom!==void 0&&(a.zoom=r.zoom),r?.scale!==void 0&&(a.scale=r.scale),await t.goTo(a),{text:`Successfully navigated to: ${[`(${e.latitude}\xB0, ${e.longitude}\xB0)`,r?.zoom!==void 0?`zoom ${r.zoom}`:"",r?.scale!==void 0?`scale 1:${r.scale}`:""].filter(Boolean).join(", ")}`}}async function qr({center:e,zoom:t,scale:r},a){let{mapView:o}=k(a);return await Mr(e,o,{zoom:t,scale:r})}var Cr=l.object({center:l.object({longitude:l.number().describe("The longitude (x-coordinate) of the point to navigate to."),latitude:l.number().describe("The latitude (y-coordinate) of the point to navigate to.")}),zoom:l.number().optional().describe("The zoom level. Higher values = more zoomed in."),scale:l.number().optional().describe("The map scale. Alternative to zoom. Smaller numbers = more zoomed in.")}),Ar=y(qr,{name:"goToViewpoint",description:"Go to the specified viewpoint. This can contain a combination of scale, center, zoom, etc.",schema:Cr});async function Rr(e,t){return await t.goTo({zoom:e}),{text:`Successfully zoomed to: ${e}`}}async function Lr({zoom:e},t){let{mapView:r}=k(t);return await Rr(e,r)}var zr=l.object({zoom:l.number().min(1).max(20).describe("The zoom level of the view to go to.")}),jr=y(Lr,{name:"goToZoom",description:'Go to the specified zoom level. If input is generic (e.g. "zoom in", then only zoom to the next appropriate level - increase level for zooming in and decrease for zooming out.).',schema:zr}),Te=[ir,dr,mr,wr,xr,kr,Fr,Ar,jr],Ve=Object.assign({"../agents/arcgisKnowledge/prompts/arcgis_knowledge_current_lc_context.md":()=>import("./LSGRWCAO.js").then(e=>e.default),"../agents/arcgisKnowledge/prompts/arcgis_knowledge_current_map_context.md":()=>import("./5X5GJH2L.js").then(e=>e.default),"../agents/arcgisKnowledge/prompts/arcgis_knowledge_lucene_generation_prompt.md":()=>import("./YVTKUITE.js").then(e=>e.default),"../agents/arcgisKnowledge/prompts/arcgis_knowledge_summarize_result_prompt.md":()=>import("./K6LVZHWM.js").then(e=>e.default),"../agents/arcgisKnowledge/prompts/arcgis_knowledge_tool_prompt.md":()=>import("./4QVKWA2Z.js").then(e=>e.default),"../agents/dataExploration/prompts/data_explore_filter_prompt.md":()=>import("./MZJGADGH.js").then(e=>e.default),"../agents/dataExploration/prompts/data_explore_query_prompt.md":()=>import("./5PT7ZFXF.js").then(e=>e.default),"../agents/dataExploration/prompts/summarize_query_response_prompt.md":()=>import("./7EXACS27.js").then(e=>e.default),"../agents/help/prompts/help_prompt.md":()=>import("./ESTSYVJP.js").then(e=>e.default),"../agents/layerStyling/prompts/layer_styling_prompt.md":()=>import("./CFT5BBC6.js").then(e=>e.default),"../agents/navigation/prompts/navigation_intent_prompt.md":()=>import("./SFREIREB.js").then(e=>e.default),"../agents/navigation/prompts/navigation_tool_prompt.md":()=>import("./DMLSCJAM.js").then(e=>e.default)});async function N(e){let t=Object.entries(Ve).find(([r])=>r.endsWith(`/${e}.md`));if(!t)throw new Error(`Prompt not found: ${e}
|
|
4
4
|
Available prompts:
|
|
5
5
|
${Object.keys(Ve).join(`
|
|
@@ -1,2 +1,2 @@
|
|
|
1
1
|
/* COPYRIGHT Esri - https://js.arcgis.com/5.1/LICENSE.txt */
|
|
2
|
-
import c from"./
|
|
2
|
+
import c from"./7O3BAVC3.js";import b from"./ZKQG2EZQ.js";import"./XHPF5TWW.js";import{a as e,c as a}from"./B4DEC7PH.js";import"./KVH3PDVW.js";import"./YGW7TUNX.js";import{v as s,y as r}from"./DSEMD4M2.js";import"./CFDTXKJ6.js";export default $arcgis.t(([,{c: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-layer-styling-agent requires a mapView");return{mapView:this.#t}}load(){this.#t=e(this,"arcgis-assistant-layer-styling-agent"),a(this)}};r("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"./
|
|
2
|
+
import c from"./7O3BAVC3.js";import b from"./ZKQG2EZQ.js";import"./XHPF5TWW.js";import{a as r,c as e}from"./B4DEC7PH.js";import"./KVH3PDVW.js";import"./YGW7TUNX.js";import{v as a,y as s}from"./DSEMD4M2.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}}load(){this.#t=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{a as _,b as f}from"./EUNEQNYC.js";import{a as C}from"./O62HTIOD.js";import"./3QC3BRZP.js";import b from"./LOXY54T6.js";import"./XHPF5TWW.js";import{a as P}from"./KVH3PDVW.js";import"./YGW7TUNX.js";import{g as E,h as a,l as $,n,t as y,u as v,v as k,w as m,y as S}from"./DSEMD4M2.js";import"./CFDTXKJ6.js";export default $arcgis.t(([R,{whenOnce:O,watch:M,when:A},V,q,{property:d,subclass:z},{f:I}])=>{var j=E`: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}.error-notice{padding:var(--calcite-spacing-sm)}`,H=Object.defineProperty,N=Object.getOwnPropertyDescriptor,h=(g,t,e,i)=>{for(var s=i>1?void 0:i?N(t,e):t,r=g.length-1,o;r>=0;r--)(o=g[r])&&(s=(i?o(t,e,s):o(s))||s);return i&&s&&H(t,e,s),s},l=class extends q{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 O(()=>!this.view.updating),this._set("orchestrator",await I.init({agents:[...this.agents],view:this.view??void 0})),this.addHandles([M(()=>[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 o=r.runId;if(t?.aborted){yield{type:"cancelled",runId:o};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,b=!!i?.length;if(!p&&!b){yield{type:"completed",error:"Could not process the request.",log:e,runId:o};return}let u=c.content;this._set("processingStep",""),yield{type:"completed",response:u,blocks:i,log:e,runId:o};return}case"ux-suggestion":{let c=r.suggestion;i=i?[...i,c]:[c];break}case"interrupt":{let{kind:c,message:p,metadata:b}=r.interrupt,u=Array.isArray(b)?b.filter(L=>typeof L=="string"):[],x=(()=>{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:x,runId:o};break}case"cancelled":{yield{type:"cancelled",runId:o};return}case"error":{yield{type:"completed",error:r.error.message,log:e,runId:o};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([z("OrchestratorController")],l);var D="Embeddings resource 'embeddings-v01.json' not found in the webmap portal item.",B="Embeddings not found for this web map.",F="https://developers.arcgis.com/javascript/latest/agentic-apps/ai-webmap-setup/#embeddings",w=class extends k{constructor(){super(...arguments),this._messages=C({blocking:!0}),this.#t=y(),this.#n=y(),this.#e=y(),this.#s=null,this.#o=new Map,this.#r=V.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.#p=t=>{this.arcgisSlottableRequest.emit(t.detail)},this._orchestratorController=null,this._interrupt=null,this._error=null,this._inputValue="",this.messages=new R([]),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=n(),this.arcgisError=n(),this.arcgisFeedback=n(),this.arcgisInterrupt=n(),this.arcgisInterruptCancel=n(),this.arcgisInterruptSubmit=n(),this.arcgisPromptSelect=n(),this.arcgisReady=n(),this.arcgisSubmit=n(),this.arcgisSlottableRequest=n({bubbles:!1,composed:!1})}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=j}#t;#n;#e;#s;#o;#r;#i;#a;#l;#c;#h;#g;#p;async#d(){try{let t=P(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.",$(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=A(()=>!!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.#d().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} ${v(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===D?a`<div slot=message>${B}</div><calcite-link slot=link .href=${F} 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} ${v(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} @arcgisSlottableRequest=${this.#p}><slot name=${_(t.id)??m} slot=${_(t.id)??m}>${t?.error?a`<calcite-notice class="error-notice" open icon kind=warning width=full><div slot=message>${t.error}</div></calcite-notice>`:a`<arcgis-assistant-message-text .content=${t?.content}></arcgis-assistant-message-text>`}</slot>${t.blocks?.map((e,i)=>a`<slot name=${f(t.id,i)??m} slot=${f(t.id,i)??m}><arcgis-assistant-message-block .block=${e}></arcgis-assistant-message-block></slot>`)}</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} ${v(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>`}};S("arcgis-assistant",w);return w},"core/Collection","core/reactiveUtils","portal/Portal","core/Accessor","core/accessorSupport/decorators",b)
|
|
2
|
+
import{a as _,b as f}from"./EUNEQNYC.js";import{a as C}from"./O62HTIOD.js";import"./3QC3BRZP.js";import b from"./ZKQG2EZQ.js";import"./XHPF5TWW.js";import{a as P}from"./KVH3PDVW.js";import"./YGW7TUNX.js";import{g as E,h as a,l as $,n,t as y,u as v,v as k,w as m,y as S}from"./DSEMD4M2.js";import"./CFDTXKJ6.js";export default $arcgis.t(([R,{whenOnce:O,watch:M,when:A},V,q,{property:d,subclass:z},{f:I}])=>{var j=E`: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}.error-notice{padding:var(--calcite-spacing-sm)}`,H=Object.defineProperty,N=Object.getOwnPropertyDescriptor,h=(g,t,e,i)=>{for(var s=i>1?void 0:i?N(t,e):t,r=g.length-1,o;r>=0;r--)(o=g[r])&&(s=(i?o(t,e,s):o(s))||s);return i&&s&&H(t,e,s),s},l=class extends q{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 O(()=>!this.view.updating),this._set("orchestrator",await I.init({agents:[...this.agents],view:this.view??void 0})),this.addHandles([M(()=>[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 o=r.runId;if(t?.aborted){yield{type:"cancelled",runId:o};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,b=!!i?.length;if(!p&&!b){yield{type:"completed",error:"Could not process the request.",log:e,runId:o};return}let u=c.content;this._set("processingStep",""),yield{type:"completed",response:u,blocks:i,log:e,runId:o};return}case"ux-suggestion":{let c=r.suggestion;i=i?[...i,c]:[c];break}case"interrupt":{let{kind:c,message:p,metadata:b}=r.interrupt,u=Array.isArray(b)?b.filter(L=>typeof L=="string"):[],x=(()=>{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:x,runId:o};break}case"cancelled":{yield{type:"cancelled",runId:o};return}case"error":{yield{type:"completed",error:r.error.message,log:e,runId:o};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([z("OrchestratorController")],l);var D="Embeddings resource 'embeddings-v01.json' not found in the webmap portal item.",B="Embeddings not found for this web map.",F="https://developers.arcgis.com/javascript/latest/agentic-apps/ai-webmap-setup/#embeddings",w=class extends k{constructor(){super(...arguments),this._messages=C({blocking:!0}),this.#t=y(),this.#n=y(),this.#e=y(),this.#s=null,this.#o=new Map,this.#r=V.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.#p=t=>{this.arcgisSlottableRequest.emit(t.detail)},this._orchestratorController=null,this._interrupt=null,this._error=null,this._inputValue="",this.messages=new R([]),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=n(),this.arcgisError=n(),this.arcgisFeedback=n(),this.arcgisInterrupt=n(),this.arcgisInterruptCancel=n(),this.arcgisInterruptSubmit=n(),this.arcgisPromptSelect=n(),this.arcgisReady=n(),this.arcgisSubmit=n(),this.arcgisSlottableRequest=n({bubbles:!1,composed:!1})}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=j}#t;#n;#e;#s;#o;#r;#i;#a;#l;#c;#h;#g;#p;async#d(){try{let t=P(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.",$(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=A(()=>!!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.#d().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} ${v(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===D?a`<div slot=message>${B}</div><calcite-link slot=link .href=${F} 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} ${v(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} @arcgisSlottableRequest=${this.#p}><slot name=${_(t.id)??m} slot=${_(t.id)??m}>${t?.error?a`<calcite-notice class="error-notice" open icon kind=warning width=full><div slot=message>${t.error}</div></calcite-notice>`:a`<arcgis-assistant-message-text .content=${t?.content}></arcgis-assistant-message-text>`}</slot>${t.blocks?.map((e,i)=>a`<slot name=${f(t.id,i)??m} slot=${f(t.id,i)??m}><arcgis-assistant-message-block .block=${e}></arcgis-assistant-message-block></slot>`)}</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} ${v(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>`}};S("arcgis-assistant",w);return w},"core/Collection","core/reactiveUtils","portal/Portal","core/Accessor","core/accessorSupport/decorators",b)
|
|
@@ -1,2 +1,2 @@
|
|
|
1
1
|
/* COPYRIGHT Esri - https://js.arcgis.com/5.1/LICENSE.txt */
|
|
2
|
-
import c from"./
|
|
2
|
+
import c from"./7O3BAVC3.js";import b from"./ZKQG2EZQ.js";import"./XHPF5TWW.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"./DSEMD4M2.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,2 +1,2 @@
|
|
|
1
1
|
/* COPYRIGHT Esri - https://js.arcgis.com/5.1/LICENSE.txt */
|
|
2
|
-
import c from"./
|
|
2
|
+
import c from"./7O3BAVC3.js";import b from"./ZKQG2EZQ.js";import"./XHPF5TWW.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"./DSEMD4M2.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)
|
|
@@ -79,7 +79,7 @@ Use prior steps to:
|
|
|
79
79
|
- Only break the request into multiple steps when necessary.
|
|
80
80
|
- When multiple agents could help, choose the best fit instead of returning \`null\`.
|
|
81
81
|
- Base the choice on the registered agent descriptions, not on whether the user used exact matching keywords.
|
|
82
|
-
- If no agent can fully complete the request, but one agent can take the next useful step, choose that agent
|
|
82
|
+
- If no agent can fully complete the request, but one agent can take the next useful step, choose that agent.
|
|
83
83
|
- Do NOT reuse constraints from prior steps unless the current user request explicitly requires them.
|
|
84
84
|
- Each step must reflect the current user request exactly.
|
|
85
85
|
|
|
@@ -117,4 +117,5 @@ Do not reinterpret the request into a different form.
|
|
|
117
117
|
- \`requiresFollowUp\` should indicate a likely next agent step, not uncertainty about the current request
|
|
118
118
|
- Set \`requiresFollowUp\` to \`true\` only when another orchestration step will likely be needed after this agent succeeds
|
|
119
119
|
- Set \`requiresFollowUp\` to \`false\` when a successful result from this agent would likely complete the user-visible task
|
|
120
|
+
- Default to \`false\`
|
|
120
121
|
`;export{e as default};
|