@arcgis/ai-components 5.0.0-next.133
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/LICENSE.md +17 -0
- package/README.md +11 -0
- package/dist/cdn/2KGO3SIH.js +4 -0
- package/dist/cdn/2OKOKVH3.js +4 -0
- package/dist/cdn/46CNQJRX.js +4 -0
- package/dist/cdn/7QPPUNQ3.js +4 -0
- package/dist/cdn/A3UHOE4Q.js +30 -0
- package/dist/cdn/A7BGJLHS.js +204 -0
- package/dist/cdn/AB32PU6M.js +4 -0
- package/dist/cdn/AD7WB3RO.js +4 -0
- package/dist/cdn/ASKBAWPQ.js +27 -0
- package/dist/cdn/BCCDWQP4.js +4 -0
- package/dist/cdn/CF42OIDB.js +4 -0
- package/dist/cdn/CGGGHCIN.js +4 -0
- package/dist/cdn/EJW7PCMD.js +4 -0
- package/dist/cdn/FORRN75L.js +4 -0
- package/dist/cdn/FYKWTA6C.js +58 -0
- package/dist/cdn/G7XEFTIR.js +4 -0
- package/dist/cdn/GRXZ64LO.js +20 -0
- package/dist/cdn/GZUY3255.js +61 -0
- package/dist/cdn/HPGCDT6I.js +4 -0
- package/dist/cdn/ID5STKZH.js +90 -0
- package/dist/cdn/J62NTCLN.js +4 -0
- package/dist/cdn/KMV7W5OL.js +4 -0
- package/dist/cdn/LILVLE37.js +87 -0
- package/dist/cdn/MXHQFIP3.js +19 -0
- package/dist/cdn/N4CYINOF.js +6 -0
- package/dist/cdn/NR6PK4OK.js +4 -0
- package/dist/cdn/PA2KCYKL.js +71 -0
- package/dist/cdn/PEFKT7JJ.js +4 -0
- package/dist/cdn/Q34AELDL.js +4 -0
- package/dist/cdn/Q3MKHRXI.js +4 -0
- package/dist/cdn/QIU4T2DV.js +4 -0
- package/dist/cdn/TCNLHL43.js +79 -0
- package/dist/cdn/UC4HPCM3.js +19 -0
- package/dist/cdn/UIUJKONY.js +4 -0
- package/dist/cdn/USJ5YVZN.js +16 -0
- package/dist/cdn/W4LEGPD2.js +111 -0
- package/dist/cdn/WOP5ENGJ.js +134 -0
- package/dist/cdn/YXLN5DSL.js +6 -0
- package/dist/cdn/ZQEX3TGK.js +17 -0
- package/dist/cdn/assets/assistant/t9n/messages.en.json +1 -0
- package/dist/cdn/assets/assistant-chat-card/t9n/messages.en.json +1 -0
- package/dist/cdn/assets/assistant-chat-entry/t9n/messages.en.json +1 -0
- package/dist/cdn/assets/assistant-interrupt/t9n/messages.en.json +1 -0
- package/dist/cdn/assets/assistant-shell/t9n/messages.en.json +1 -0
- package/dist/cdn/index.js +4 -0
- package/dist/cdn/main.css +1 -0
- package/dist/chunks/runtime.js +17 -0
- package/dist/chunks/useT9n.js +9 -0
- package/dist/chunks/utils.js +35 -0
- package/dist/chunks/utils2.js +9 -0
- package/dist/components/arcgis-assistant/customElement.d.ts +14 -0
- package/dist/components/arcgis-assistant/customElement.js +250 -0
- package/dist/components/arcgis-assistant/index.d.ts +5 -0
- package/dist/components/arcgis-assistant/index.js +5 -0
- package/dist/components/arcgis-assistant/support/OrchestratorController.d.ts +33 -0
- package/dist/components/arcgis-assistant/support/utils.d.ts +1 -0
- package/dist/components/arcgis-assistant-agent/customElement.d.ts +10 -0
- package/dist/components/arcgis-assistant-agent/customElement.js +21 -0
- package/dist/components/arcgis-assistant-agent/index.d.ts +1 -0
- package/dist/components/arcgis-assistant-agent/index.js +1 -0
- package/dist/components/arcgis-assistant-chat/customElement.d.ts +17 -0
- package/dist/components/arcgis-assistant-chat/customElement.js +47 -0
- package/dist/components/arcgis-assistant-chat/index.d.ts +2 -0
- package/dist/components/arcgis-assistant-chat/index.js +2 -0
- package/dist/components/arcgis-assistant-chat-card/customElement.d.ts +18 -0
- package/dist/components/arcgis-assistant-chat-card/customElement.js +55 -0
- package/dist/components/arcgis-assistant-chat-card/index.d.ts +6 -0
- package/dist/components/arcgis-assistant-chat-card/index.js +6 -0
- package/dist/components/arcgis-assistant-chat-card-content/customElement.d.ts +11 -0
- package/dist/components/arcgis-assistant-chat-card-content/customElement.js +42 -0
- package/dist/components/arcgis-assistant-chat-card-content/index.d.ts +2 -0
- package/dist/components/arcgis-assistant-chat-card-content/index.js +2 -0
- package/dist/components/arcgis-assistant-chat-entry/customElement.d.ts +19 -0
- package/dist/components/arcgis-assistant-chat-entry/customElement.js +46 -0
- package/dist/components/arcgis-assistant-chat-entry/index.d.ts +4 -0
- package/dist/components/arcgis-assistant-chat-entry/index.js +4 -0
- package/dist/components/arcgis-assistant-data-exploration-agent/customElement.d.ts +7 -0
- package/dist/components/arcgis-assistant-data-exploration-agent/customElement.js +28 -0
- package/dist/components/arcgis-assistant-data-exploration-agent/index.d.ts +1 -0
- package/dist/components/arcgis-assistant-data-exploration-agent/index.js +1 -0
- package/dist/components/arcgis-assistant-interrupt/customElement.d.ts +14 -0
- package/dist/components/arcgis-assistant-interrupt/customElement.js +39 -0
- package/dist/components/arcgis-assistant-interrupt/index.d.ts +6 -0
- package/dist/components/arcgis-assistant-interrupt/index.js +6 -0
- package/dist/components/arcgis-assistant-layer-filter-agent/customElement.d.ts +7 -0
- package/dist/components/arcgis-assistant-layer-filter-agent/customElement.js +28 -0
- package/dist/components/arcgis-assistant-layer-filter-agent/index.d.ts +1 -0
- package/dist/components/arcgis-assistant-layer-filter-agent/index.js +1 -0
- package/dist/components/arcgis-assistant-layer-query-agent/customElement.d.ts +7 -0
- package/dist/components/arcgis-assistant-layer-query-agent/customElement.js +28 -0
- package/dist/components/arcgis-assistant-layer-query-agent/index.d.ts +1 -0
- package/dist/components/arcgis-assistant-layer-query-agent/index.js +1 -0
- package/dist/components/arcgis-assistant-layer-styling-agent/customElement.d.ts +7 -0
- package/dist/components/arcgis-assistant-layer-styling-agent/customElement.js +28 -0
- package/dist/components/arcgis-assistant-layer-styling-agent/index.d.ts +1 -0
- package/dist/components/arcgis-assistant-layer-styling-agent/index.js +1 -0
- package/dist/components/arcgis-assistant-navigation-agent/customElement.d.ts +7 -0
- package/dist/components/arcgis-assistant-navigation-agent/customElement.js +28 -0
- package/dist/components/arcgis-assistant-navigation-agent/index.d.ts +1 -0
- package/dist/components/arcgis-assistant-navigation-agent/index.js +1 -0
- package/dist/components/arcgis-assistant-shell/customElement.d.ts +25 -0
- package/dist/components/arcgis-assistant-shell/customElement.js +29 -0
- package/dist/components/arcgis-assistant-shell/index.d.ts +6 -0
- package/dist/components/arcgis-assistant-shell/index.js +6 -0
- package/dist/components/assistant/assistant-agents/support/utils.d.ts +14 -0
- package/dist/controllers/useT9n.d.ts +1 -0
- package/dist/customAgents/AddAgent/AddAgent.d.ts +2 -0
- package/dist/docs/api.json +2239 -0
- package/dist/docs/docs.json +2011 -0
- package/dist/docs/vscode.css-custom-data.json +6 -0
- package/dist/docs/vscode.html-custom-data.json +306 -0
- package/dist/docs/web-types.json +693 -0
- package/dist/index.d.ts +99 -0
- package/dist/index.js +8 -0
- package/dist/loader.d.ts +2 -0
- package/dist/loader.js +23 -0
- package/dist/oauth-callback.html +31 -0
- package/dist/runtime.d.ts +6 -0
- package/dist/types/components.d.ts +2 -0
- package/dist/types/lumina.d.ts +80 -0
- package/dist/types/preact.d.ts +98 -0
- package/dist/types/react.d.ts +119 -0
- package/dist/types/stencil.d.ts +87 -0
- package/package.json +47 -0
package/LICENSE.md
ADDED
|
@@ -0,0 +1,17 @@
|
|
|
1
|
+
# Licensing
|
|
2
|
+
|
|
3
|
+
COPYRIGHT © Esri
|
|
4
|
+
|
|
5
|
+
All rights reserved under the copyright laws of the United States and applicable international laws, treaties, and conventions.
|
|
6
|
+
|
|
7
|
+
This material is licensed for use under the [Esri Master License Agreement (MLA)](https://www.esri.com/content/dam/esrisites/en-us/media/legal/ma-full/ma-full.pdf), and is bound by the terms of that agreement.
|
|
8
|
+
You may redistribute and use this code without modification, provided you adhere to the terms of the MLA and include this copyright notice.
|
|
9
|
+
|
|
10
|
+
For additional information, contact:
|
|
11
|
+
Environmental Systems Research Institute, Inc.
|
|
12
|
+
Attn: Contracts and Legal Services Department
|
|
13
|
+
380 New York Street
|
|
14
|
+
Redlands, California, USA 92373
|
|
15
|
+
USA
|
|
16
|
+
|
|
17
|
+
email: legal@esri.com
|
package/README.md
ADDED
|
@@ -0,0 +1,11 @@
|
|
|
1
|
+
# ArcGIS Maps SDK for JavaScript - AI Components package (beta)
|
|
2
|
+
|
|
3
|
+
**No Esri Technical Support included.**
|
|
4
|
+
|
|
5
|
+
The ArcGIS Maps SDK for JavaScript provides a suite of ready-to-use UI components that simplify the process of creating GIS web applications. This package contains **AI components** with functionality made possible through the SDK's core API which is also accessible through the components.
|
|
6
|
+
|
|
7
|
+
## License
|
|
8
|
+
|
|
9
|
+
COPYRIGHT © Esri
|
|
10
|
+
|
|
11
|
+
This package is licensed under the terms described in the `LICENSE.md` file, located in the root of the package.
|
|
@@ -0,0 +1,4 @@
|
|
|
1
|
+
/*! All material copyright Esri, All Rights Reserved, unless otherwise specified.
|
|
2
|
+
See https://js.arcgis.com/5.0/esri/copyright.txt for details.
|
|
3
|
+
v5.0.0-next.133 */
|
|
4
|
+
import{a as $,c as k}from"./UIUJKONY.js";import{a as C,b as L,c as m,d as f,e as P,f as O,i as g,j as v,l as w,u as N}from"./YXLN5DSL.js";var _=t=>(...s)=>{let o=f(),e=new t(...s),r=e.exports;m(o.at(-1));let n=e.component.manager;n.W(e,r),e.watchExports(n.W.bind(n,e)),P(e);let a=[e.component,...o].reverse();return v(a,i=>i===void 0?void 0:j(e,i,r),r)},j=(t,{host:s,key:o,isReactive:e},r)=>{let n=s,a=n[o]!==t.exports,i=n[o]!==r,c=r!==t.exports;if(a&&!i&&c&&(n[o]=t.exports),s===t.component){if(e){let l=t.component.manager;i&&l.W(t,n[o]),t.onUpdate(u=>{if(u.has(o)){let x=n[o];x!==t.exports&&l.W(t,x)}})}t.O=e?void 0:o}let d=t.component.constructor.elementProperties.get(o)?.readOnly;t.watchExports(()=>{n[o]!==t.exports&&(d?O(()=>{n[o]=t.exports}):n[o]=t.exports)})};var z="ar,bg,bs,ca,cs,da,de,el,en,es,et,fi,fr,he,hr,hu,id,it,ja,ko,lt,lv,nl,nb,no,pl,pt-BR,pt-PT,ro,ru,sk,sl,sr,sv,th,tr,uk,vi,zh-CN,zh-HK,zh-TW".split(","),M=new Set(z),h="en",U={pt:"pt-PT",nb:"no",nn:"no",zh:"zh-CN"},F=async(t,s,o="")=>{let e=`${s}/${o}`,r=`${e}${t}.json`;return b[r]??(b[r]=A(t,e)),await b[r]},b={},A=async(t,s)=>{let o=`${s}${t}.json`;try{let e=await fetch(o);if(e.ok)return await e.json()}catch(e){return g("error","intl",`An unknown error occurred while fetching localization strings at ${o}`,{detail:{error:e}}),{}}return t===h?{}:await A(h,s)},y=t=>{let s=k(t,"lang",globalThis.navigator?.language||h);return{lang:s,t9nLocale:T(s)}},T=t=>{let[s,o]=t.split("-"),e=s.toLowerCase(),r=e;return o&&(r=`${e}-${o.toUpperCase()}`),r=U[r]??r,M.has(r)?r:o?T(e):h},D=(t,s,o,e)=>{let r,n=()=>K(t,s(),e).then(a=>{(r?.lang!==a.lang||r.t9nLocale!==a.t9nLocale||r.t9nStrings!==a.t9nStrings)&&o(a),r=a}).catch(a=>{g("error","intl","Error updating component locale state",{detail:{error:a}})});return queueMicrotask(n),$(t,["lang"],n)},K=async(t,s,o=t.localName.split("-").slice(1).join("-"))=>{let{lang:e,t9nLocale:r}=y(t),n=`${s}/${o}/t9n`,i=o===null?{}:await F(r,n,"messages.");return{lang:e,t9nLocale:r,t9nStrings:i}};var W=t=>I(void 0,t);var E=class extends w{constructor(s,o){super(s);let e=this.exports;try{L(this.component);let r=o(this.component,this),n=this.exports!==e;if(C(r)){n||this.setProvisionalExports(r);let a=r.then(i=>{this.exports=i,super.catchUpLifecycle()}).catch(i=>{this.P.reject(i)});this.onLoad(async()=>await a)}else(!n||r!==void 0)&&(this.exports=r),queueMicrotask(()=>super.catchUpLifecycle())}catch(r){this.P.reject(r)}}catchUpLifecycle(){}},I=_(E);var S=t=>(s={})=>W((o,e)=>{let r=y(o.el),n={_lang:r.lang,_t9nLocale:r.t9nLocale,_loading:!0},a=o;e.onLifecycle(()=>D(o.el,()=>t("./assets"),({t9nLocale:c,t9nStrings:p,lang:d})=>{let l={...p,_lang:d,_t9nLocale:c,_loading:!1};e.exports=l;let u=p.componentLabel;typeof u=="string"&&"label"in o&&o.label==null&&(o.label??=u),i(a.messageOverrides)},s.name));let i=c=>{let p=e.exports,d=p._original??p,l=V(d,c);c&&(l._original=d),e.exports=l};return"messageOverrides"in a&&e.onUpdate(c=>{c.has("messageOverrides")&&i(a.messageOverrides)}),s.blocking?(e.setProvisionalExports(n,!1),e.ready):n}),V=(t,s)=>{if(!s)return t;let o={...t};return Object.entries(s).forEach(([e,r])=>{t[e]!==void 0&&(typeof r=="object"?o[e]=V(t[e],r):o[e]=r??t[e])}),o};var ct=S(N);export{ct as a};
|
|
@@ -0,0 +1,4 @@
|
|
|
1
|
+
/*! All material copyright Esri, All Rights Reserved, unless otherwise specified.
|
|
2
|
+
See https://js.arcgis.com/5.0/esri/copyright.txt for details.
|
|
3
|
+
v5.0.0-next.133 */
|
|
4
|
+
import{a as n}from"./2KGO3SIH.js";import"./UIUJKONY.js";import{g as a,h as e,k as s,p as l,t as c}from"./YXLN5DSL.js";import"./46CNQJRX.js";var o=a``,i=class extends l{constructor(){super(...arguments),this.#t=[],this._messages=n({blocking:!0}),this.arcgisCancel=s(),this.arcgisSubmit=s()}static{this.properties={type:1,message:1,options:0}}static{this.styles=o}#t;_renderInterruptOptions(){switch(this.type){case"single-select":return e`<calcite-list selection-mode=single-persist .label=${this._messages.optionsLabel} @calciteListChange=${t=>this.#t=t.target.selectedItems[0]?.value}>${this.options?.map(t=>e`<calcite-list-item .label=${t} .value=${t}></calcite-list-item>`)}</calcite-list>`;case"multi-select":return e`<calcite-list selection-mode=multiple .label=${this._messages.optionsLabel} @calciteListChange=${t=>this.#t=t.target.selectedItems.map(r=>r.value)}>${this.options?.map(t=>e`<calcite-list-item .label=${t} .value=${t}></calcite-list-item>`)}</calcite-list>`;case"boolean-choice":return e`<calcite-list selection-mode=single-persist .label=${this._messages.optionsLabel} @calciteListChange=${t=>this.#t=t.target.selectedItems[0]?.value}>${this.options?.map(t=>e`<calcite-list-item .label=${t} .value=${t}></calcite-list-item>`)}</calcite-list>`;case"text-input":return e`<calcite-input .label=${this._messages.enterTextLabel} @calciteInputInput=${t=>this.#t=t.target.value}></calcite-input>`}}render(){return e`<calcite-panel .description=${this.message}>${this._renderInterruptOptions()}<calcite-button slot=footer-end appearance=outline @click=${()=>this.arcgisCancel.emit()}>${this._messages.cancelButtonLabel}</calcite-button><calcite-button slot=footer-end appearance=solid @click=${()=>this.arcgisSubmit.emit(this.#t)}>${this._messages.submitButtonLabel}</calcite-button></calcite-panel>`}};c("arcgis-assistant-interrupt",i);export{i as ArcgisAssistantInterrupt};
|
|
@@ -0,0 +1,4 @@
|
|
|
1
|
+
/*! All material copyright Esri, All Rights Reserved, unless otherwise specified.
|
|
2
|
+
See https://js.arcgis.com/5.0/esri/copyright.txt for details.
|
|
3
|
+
v5.0.0-next.133 */
|
|
4
|
+
var g=Object.create;var e=Object.defineProperty;var h=Object.getOwnPropertyDescriptor;var i=Object.getOwnPropertyNames;var j=Object.getPrototypeOf,k=Object.prototype.hasOwnProperty;var m=(b,a)=>()=>(a||b((a={exports:{}}).exports,a),a.exports),n=(b,a)=>{for(var c in a)e(b,c,{get:a[c],enumerable:!0})},l=(b,a,c,f)=>{if(a&&typeof a=="object"||typeof a=="function")for(let d of i(a))!k.call(b,d)&&d!==c&&e(b,d,{get:()=>a[d],enumerable:!(f=h(a,d))||f.enumerable});return b};var o=(b,a,c)=>(c=b!=null?g(j(b)):{},l(a||!b||!b.__esModule?e(c,"default",{value:b,enumerable:!0}):c,b));export{m as a,n as b,o as c};
|
|
@@ -0,0 +1,4 @@
|
|
|
1
|
+
/*! All material copyright Esri, All Rights Reserved, unless otherwise specified.
|
|
2
|
+
See https://js.arcgis.com/5.0/esri/copyright.txt for details.
|
|
3
|
+
v5.0.0-next.133 */
|
|
4
|
+
import d from"./A7BGJLHS.js";import{a as e,b as i}from"./FORRN75L.js";import c from"./WOP5ENGJ.js";import"./PEFKT7JJ.js";import"./UIUJKONY.js";import{p as s,t as a}from"./YXLN5DSL.js";import b from"./ZQEX3TGK.js";import"./LILVLE37.js";import"./46CNQJRX.js";export default $arcgis.t(([,,{e:r}])=>{var t=class extends s{constructor(){super(...arguments),this.agent=r}static{this.properties={referenceElement:1}}#t;getContext(){if(!this.#t)throw new Error("arcgis-assistant-layer-styling-agent requires a mapView");return{mapView:this.#t}}async load(){this.#t=await e(this,"arcgis-assistant-layer-styling-agent"),i(this)}};a("arcgis-assistant-layer-styling-agent",t);return t},b,c,d)
|
|
@@ -0,0 +1,30 @@
|
|
|
1
|
+
/*! All material copyright Esri, All Rights Reserved, unless otherwise specified.
|
|
2
|
+
See https://js.arcgis.com/5.0/esri/copyright.txt for details.
|
|
3
|
+
v5.0.0-next.133 */
|
|
4
|
+
import"./46CNQJRX.js";var e=`## Task: Summarize Geographic Features
|
|
5
|
+
|
|
6
|
+
You are given features from ArcGIS Feature layer for multiple layers:
|
|
7
|
+
{queryResponse}
|
|
8
|
+
|
|
9
|
+
Also consider any **relevant context from the chat history**, such as user questions or instructions.
|
|
10
|
+
|
|
11
|
+
### Your goal:
|
|
12
|
+
|
|
13
|
+
1. If the user question is about a **specific calculation** (e.g., average, total, count, min, max), return only the **direct numeric answer** \u2014 short and clear.
|
|
14
|
+
- Example: \u201CThe average price is $4.00.\u201D
|
|
15
|
+
|
|
16
|
+
2. If the question is more general or there are **multiple features with varying attributes**, write a **brief summary** (2\u20133 sentences max) that highlights key patterns or insights.
|
|
17
|
+
|
|
18
|
+
3. The response can be per layer, or summarize based on the question.
|
|
19
|
+
|
|
20
|
+
4. When the user asks "where" a feature is located: Simply confirm whether the feature was found and in which layer. DO NOT attempt to provide coordinates, addresses, or geographic descriptions.
|
|
21
|
+
|
|
22
|
+
5. DO NOT ramble.
|
|
23
|
+
|
|
24
|
+
In all cases:
|
|
25
|
+
|
|
26
|
+
- Focus on **notable attribute values**, **commonalities or differences**, and **interesting trends**.
|
|
27
|
+
- If the feature list is empty or not meaningful, state that clearly.
|
|
28
|
+
|
|
29
|
+
**Keep your response concise and relevant to the user\u2019s question.**
|
|
30
|
+
`;export{e as default};
|
|
@@ -0,0 +1,204 @@
|
|
|
1
|
+
/*! All material copyright Esri, All Rights Reserved, unless otherwise specified.
|
|
2
|
+
See https://js.arcgis.com/5.0/esri/copyright.txt for details.
|
|
3
|
+
v5.0.0-next.133 */
|
|
4
|
+
import a from"./WOP5ENGJ.js";import{Ba as _,F as O,I as H,M as j,Wa as n,Y as K}from"./LILVLE37.js";export default $arcgis.t(([tt,oe,Ne,rt,{addressToLocations:at},Re,V,U,ie,ne,Ae,qe,se,ke,{createRenderer:ot},{getSchemesByTag:it,getSchemes:nt},{getBackgroundColorTheme:Te},{createAgeRenderer:st,createContinuousRenderer:lt},{getSchemesByTag:le},{createContinuousRenderer:ct},{createRenderer:dt},{getSchemesByTag:ut},{createRenderer:mt},{getSchemesByTag:ht},{createRenderer:ft},{getSchemesByTag:gt},{createRenderer:yt},{getSchemesByTag:pt},{createAgeRenderer:wt,createContinuousRenderer:bt},{createRenderer:St},{getSchemesByTag:vt},{a:ge,b:ye,c:p,d:g,e:N,f:x,g:pe,h:G,i:W,j:we,k:R,l:A,m:m,n:E,o:Y,p:be,q:C}])=>{var ve=e=>Array.isArray(e)&&e.every(O),He=e=>typeof e=="object"&&e!=null&&"messages"in e&&ve(e.messages),Ke=e=>typeof e=="object"&&e!=null&&"lg_tool_call"in e,L=class extends we{constructor(r,t){let{name:a,tags:o,handleToolErrors:i}=t??{};super({name:a,tags:o,func:(s,l)=>this.run(s,l)}),Object.defineProperty(this,"tools",{enumerable:!0,configurable:!0,writable:!0,value:void 0}),Object.defineProperty(this,"handleToolErrors",{enumerable:!0,configurable:!0,writable:!0,value:!0}),Object.defineProperty(this,"trace",{enumerable:!0,configurable:!0,writable:!0,value:!1}),this.tools=r,this.handleToolErrors=i??this.handleToolErrors}async runTool(r,t){let a=this.tools.find(o=>o.name===r.name);try{if(a===void 0)throw new Error(`Tool "${r.name}" not found.`);let o=await a.invoke({...r,type:"tool_call"},t);return O(o)&&o.getType()==="tool"||W(o)?o:new H({status:"success",name:a.name,content:typeof o=="string"?o:JSON.stringify(o),tool_call_id:r.id})}catch(o){if(!this.handleToolErrors||ye(o))throw o;return new H({status:"error",content:`Error: ${o.message}
|
|
5
|
+
Please fix your mistakes.`,name:r.name,tool_call_id:r.id??""})}}async run(r,t){let a;if(Ke(r))a=[await this.runTool(r.lg_tool_call,t)];else{let s;if(ve(r))s=r;else if(He(r))s=r.messages;else throw new Error("ToolNode only accepts BaseMessage[] or { messages: BaseMessage[] } as input.");let l=new Set(s.filter(c=>c.getType()==="tool").map(c=>c.tool_call_id)),d;for(let c=s.length-1;c>=0;c-=1){let u=s[c];if(u.getType()==="ai"){d=u;break}}if(d?.getType()!=="ai")throw new Error("ToolNode only accepts AIMessages as input.");a=await Promise.all(d.tool_calls?.filter(c=>c.id==null||!l.has(c.id)).map(c=>this.runTool(c,t))??[])}if(!a.some(W))return Array.isArray(r)?a:{messages:a};let o=[],i=null;for(let s of a)W(s)?s.graph===G.PARENT&&Array.isArray(s.goto)&&s.goto.every(l=>pe(l))?i?i.goto.push(...s.goto):i=new G({graph:G.PARENT,goto:s.goto}):o.push(s):o.push(Array.isArray(r)?[s]:{messages:[s]});return i&&o.push(i),o}};var Rn=g.Root({llmInputMessages:g({reducer:(e,r)=>A([],r),default:()=>[]})});var ze=g.Root({messages:g({reducer:A,default:()=>[]}),outputMessage:g({reducer:(e="",r)=>{let t=typeof r=="string"?r.trim():"";if(!t)return e;let a=e.trim();if(!a)return t;if(a===t)return e;let o=a.split(`
|
|
6
|
+
|
|
7
|
+
`);return o[o.length-1]?.trim()===t?e:`${e}
|
|
8
|
+
|
|
9
|
+
${t}`},default:()=>""}),intent:g({reducer:(e,r)=>r}),vectorSearchLayerResults:g({reducer:(e,r)=>r,default:()=>[]}),vectorSearchFieldResults:g({reducer:(e,r)=>r})});async function Tt(e,r){let t="https://geocode.arcgis.com/arcgis/rest/services/World/GeocodeServer";console.log(`[goToAddress] Geocoding: ${e}`);let a=(await at(t,{address:{SingleLine:e},outFields:["Match_addr"]}))?.[0];if(!a?.extent)throw new Error(`Could not find location for: ${e}`);let{xmin:o,ymin:i,xmax:s,ymax:l,spatialReference:d}=a.extent,c=new Ne({xmin:o,ymin:i,xmax:s,ymax:l,spatialReference:d}),u=(o+s)/2,h=(i+l)/2,y=new oe({x:u,y:h,spatialReference:d}),f=new rt({style:"circle",color:"red",size:12}),w=new tt({geometry:y,symbol:f});return r.graphics.removeAll(),r.graphics.add(w),await r.goTo(c),`Successfully zoomed to: ${a.address}. Location coordinates: x=${u}, y=${h}, wkid=${d.wkid}`}var xt=["mapView"];function $(e){let r=e?.configurable?.context;if(!r||typeof r!="object")throw new Error("NavigationAgent context missing");let t=xt.filter(a=>!(a in r));if(t.length)throw new Error(`NavigationAgent context missing: ${t.join(", ")}`);return r}async function Et({address:e},r){let{mapView:t}=$(r);return await Tt(e,t)}var Lt=n.object({address:n.string().describe("The full address or place name to locate.")}),It=p(Et,{name:"goToAddress",description:"Geocodes an address using Esri's World Geocoding Service and zooms the map to that location.",schema:Lt});async function $t(e,r){let t=r.map.bookmarks;if(!t||t.length===0)throw new Error("No bookmarks found in the map.");let a=t.find(i=>i.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 r.goTo(o),`Navigated to bookmark: ${e}`}async function Ft({bookmarkName:e},r){let{mapView:t}=$(r);return await Promise.resolve($t(e,t))}var _t=_.object({bookmarkName:_.string().describe("The name of the bookmark to navigate to.")}),Nt=p(Ft,{name:"goToBookmark",description:"Go to the extent of the bookmark with the given name.",schema:_t});async function Rt(e,r,t){let a=t.map?.allLayers.find(i=>i.id===e);if(!a)return`Error: Layer with id ${e} not found`;let o=a.createQuery();o.where=r??"1=1";try{let{extent:i,count:s}=await a.queryExtent(o);if(s===0)return`No features found in ${a.title} matching: ${r}`;if(i)await t.goTo(i);else return`Error: Unable to determine extent for ${a.title}`;return`Successfully zoomed to ${s} feature(s) in ${a.title}`}catch(i){return console.error("Error in goToFeatures:",i),`Error: ${i instanceof Error?i.message:"Unknown error"}`}}async function At({layerId:e,where:r},t){let{mapView:a}=$(t);return await Rt(e,r,a)}var qt=_.object({layerId:_.string().describe("The layerId of the layer to zoom to."),where:_.string().describe("The sql-92 where clause used to query features to zoom to")}),kt=p(At,{name:"goToFeatures",description:"Go to the features that match the given filter related to the given layerId.",schema:qt});async function zt(e){let r=new Ne({xmin:-180,ymin:-90,xmax:180,ymax:90,spatialReference:{wkid:4326}}).expand(.7);return await e.goTo(r),"Successfully zoomed to world extent"}async function Mt(e,r){let{mapView:t}=$(r);return await zt(t)}var Ct=_.object({}),jt=p(Mt,{name:"goToFullExtent",description:"Zooms the map to the full world extent using Esri's Geocoding Service.",schema:Ct});async function Vt(e){let r=e.map.initialViewProperties?.viewpoint?.targetGeometry;if(r)await e.goTo(r);else throw new Error("Initial extent is undefined");return"Successfully zoomed to home extent"}async function Ot(e,r){let{mapView:t}=$(r);return await Vt(t)}var Dt=n.object({}),Bt=p(Ot,{name:"goToHomeExtent",description:"Go to the initial web map view extent",schema:Dt});async function Qt(e,r){await r.when();let t=r.map?.allLayers.find(o=>o.id===e);if(!t)return console.warn(`[goToLayer] No matching FeatureLayer found for: ${e}`),`Could not find layer for: ${e}`;console.log(`[goToLayer] Zooming to layer: ${t.title}`);let a=t.fullExtent;return a?(await r.goTo(a),t.visible=!0,`Successfully zoomed to: ${t.title??""}`):"Layer has no defined extent. Cannot zoom to layer."}async function Pt({layerId:e},r){let{mapView:t}=$(r);return await Qt(e,t)}var Gt=_.object({layerId:_.string().describe("The id of the layer to navigate to")}),Wt=p(Pt,{name:"goToLayer",description:"Zooms the map view to the full extent of the top matching layer.",schema:Gt});async function Ut(e,r){return await r.goTo({scale:e}),`Successfully zoomed to: ${e}`}async function Jt({scale:e},r){let{mapView:t}=$(r);return await Ut(e,t)}var Zt=n.object({scale:n.number().describe("The map scale of the view to go to.")}),Ht=p(Jt,{name:"goToScale",description:"Go to the specified view scale.",schema:Zt});async function Kt(e,r,t){let a={target:new oe({longitude:e.longitude,latitude:e.latitude,spatialReference:{wkid:4326}})};return t?.zoom!==void 0&&(a.zoom=t.zoom),t?.scale!==void 0&&(a.scale=t.scale),await r.goTo(a),`Successfully navigated to: ${[`(${e.latitude}\xB0, ${e.longitude}\xB0)`,t?.zoom!==void 0?`zoom ${t.zoom}`:"",t?.scale!==void 0?`scale 1:${t.scale}`:""].filter(Boolean).join(", ")}`}async function Yt({center:e,zoom:r,scale:t},a){let{mapView:o}=$(a);return await Kt(e,o,{zoom:r,scale:t})}var Xt=n.object({center:n.object({longitude:n.number().describe("The longitude (x-coordinate) of the point to navigate to."),latitude:n.number().describe("The latitude (y-coordinate) of the point to navigate to.")}),zoom:n.number().optional().describe("The zoom level. Higher values = more zoomed in."),scale:n.number().optional().describe("The map scale. Alternative to zoom. Smaller numbers = more zoomed in.")}),er=p(Yt,{name:"goToViewpoint",description:"Go to the specified viewpoint. This can contain a combination of scale, center, zoom, etc.",schema:Xt});async function tr(e,r){return await r.goTo({zoom:e}),`Successfully zoomed to: ${e}`}async function rr({zoom:e},r){let{mapView:t}=$(r);return await tr(e,t)}var ar=n.object({zoom:n.number().min(1).max(20).describe("The zoom level of the view to go to.")}),or=p(rr,{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:ar}),ce=[It,Nt,kt,jt,Bt,Wt,Ht,er,or],xe=Object.assign({"../agents/dataExploration/prompts/data_explore_filter_prompt.md":()=>import("./TCNLHL43.js").then(e=>e.default),"../agents/dataExploration/prompts/data_explore_query_prompt.md":()=>import("./ID5STKZH.js").then(e=>e.default),"../agents/layerFilter/prompts/layer_filter_prompt.md":()=>import("./Q3MKHRXI.js").then(e=>e.default),"../agents/layerQuery/prompts/data_query_prompt.md":()=>import("./GZUY3255.js").then(e=>e.default),"../agents/layerQuery/prompts/summarize_query_response_prompt.md":()=>import("./A3UHOE4Q.js").then(e=>e.default),"../agents/layerStyling/prompts/layer_styling_prompt.md":()=>import("./PA2KCYKL.js").then(e=>e.default),"../agents/linkChart/prompts/link_chart_intent_prompt.md":()=>import("./MXHQFIP3.js").then(e=>e.default),"../agents/linkChart/prompts/link_chart_tool_prompt.md":()=>import("./USJ5YVZN.js").then(e=>e.default),"../agents/navigation/prompts/navigation_intent_prompt.md":()=>import("./UC4HPCM3.js").then(e=>e.default),"../agents/navigation/prompts/navigation_tool_prompt.md":()=>import("./ASKBAWPQ.js").then(e=>e.default)});async function q(e){let r=Object.entries(xe).find(([t])=>t.endsWith(`/${e}.md`));if(console.log(`entry for prompt "${e}":`,r),!r)throw new Error(`Prompt not found: ${e}
|
|
10
|
+
Available prompts:
|
|
11
|
+
${Object.keys(xe).join(`
|
|
12
|
+
`)}`);return await r[1]()}var ir=(e,r=3)=>e.filter(t=>t instanceof K).slice(-r),S=(e,r=3)=>{let t=e.map((o,i)=>o instanceof K?i:-1).filter(o=>o!==-1);if(t.length===0)return[];let a=t.length>r?t[t.length-r]:t[0];return e.slice(a)},F=(e,r=" ")=>ir(e).map(t=>t.content).join(r).trim();async function nr(e,r){let t=await q("navigation_tool_prompt"),{mapView:a}=$(r),o=a.map,i=e.vectorSearchLayerResults?.length>0?e.vectorSearchLayerResults.map((w,v)=>`${v+1}. layerId=${w.id} | title=${w.title??""} | name=${w.name??""} | score=${w.score.toFixed(2)}`).join(`
|
|
13
|
+
`):"",s=e.vectorSearchFieldResults?.length>0?JSON.stringify(e.vectorSearchFieldResults,null,2):"",l=e.intent==="goToBookmark"&&o.bookmarks?.length?`Available bookmarks:
|
|
14
|
+
${JSON.stringify(o.bookmarks,null,2)}`:"",d=(e.intent==="goToLayer"||e.intent==="goToFeatures")&&e.vectorSearchLayerResults?.length?`Candidate layers:
|
|
15
|
+
${i}`:"",c=e.intent==="goToFeatures"&&e.vectorSearchFieldResults?.length?`Candidate fields:
|
|
16
|
+
${s}`:"",u={intent:e.intent,bookmarksSection:l,layersSection:d,fieldsSection:c,currentZoom:a.zoom},h=await C({promptText:t,messages:S(e.messages),inputVariables:u,tools:ce}),y=[...e.messages,h],f=(h.tool_calls?.length??0)>0?[...y]:[...y,h];return{...e,messages:f}}async function sr(e,r){let t=await new L(ce).invoke({messages:S(e.messages)},r),a=t.messages.map(s=>s.text).join(`
|
|
17
|
+
`);await m({text:`Finished executing navigation tool: ${a}`},r);let o=[...e.messages,...t.messages],i=t.messages.map(s=>s.text).join(`
|
|
18
|
+
`);return{...e,messages:o,outputMessage:i}}async function lr(e){let r=await q("navigation_intent_prompt"),t={tools:ce.map(s=>({name:s.name,description:s.description,schema:s.schema})).map(({name:s,description:l,schema:d})=>`${s}: ${l}, ${JSON.stringify(d)}`).join(`
|
|
19
|
+
`)},a=n.object({intent:n.string()}),o=await be({promptText:r,modelTier:"fast",messages:S(e.messages),inputVariables:t,schema:a}),i=typeof o.intent=="string"?o.intent.trim().replace(/^"|"$/gu,""):"";return{...e,intent:i||""}}var b=(e,r)=>{let t=e?.configurable?.services?.[r];if(t==null)throw new Error(`${r} missing in config.configurable.services`);return t},cr=.7,dr=async(e,r)=>{try{let t=F(e.messages);await m({text:`Similarity search to find layers: ${t}`},r);let a=b(r,"layerSearch"),o=b(r,"layersAndFieldsRegistry"),i=(await a.searchLayers({text:t,minScore:cr})).map(({id:l,score:d})=>{let c=o.get(l)?.layerItem;return{id:l,title:c?.title,name:c?.name??void 0,score:d}}),s;return i.length>0?s=`Vector search completed. Matching layers:
|
|
20
|
+
${i.map(l=>`- layerId=${l.id} | title=${l.title??""} | name=${l.name??""} | score=${l.score.toFixed(2)}`).join(`
|
|
21
|
+
`)}`:s="Vector search completed. No matching layers found.",await m({text:s},r),{...e,vectorSearchLayerResults:i}}catch(t){throw await m({text:`Error during vector search layers: ${t instanceof Error?t.message:String(t)}`},r),t}},Ee=.7,ur=10,mr=async(e,r)=>{try{let t=F(e.messages);await m({text:"Similarity search to find fields"},r);let a=b(r,"fieldSearch"),o=b(r,"layersAndFieldsRegistry"),i=e.vectorSearchLayerResults?.map(d=>d.id)??[];if(i.length===0)return await m({text:"No candidate layers for field search"},r),e;let s=(await a.searchFields({text:t,layerIds:i,minScore:Ee,topResults:ur})).map(({layerId:d,results:c})=>{let u=o.get(d)?.fieldRegistry;return{layerId:d,layerName:o.get(d)?.layerItem.name,results:c.map(h=>{let y=u?.get(h.name);return{name:h.name,score:h.score,type:y?.type,alias:y?.alias,description:y?.description,statistics:y?.statistics}})}}),l;return s.length>0?l=`Vector search completed. Matching layers and fields:
|
|
22
|
+
${s.map(d=>`${d.layerName??d.layerId}:
|
|
23
|
+
${d.results.map(c=>` - ${c.name} (${c.score.toFixed(2)})`).join(`
|
|
24
|
+
`)}`).join(`
|
|
25
|
+
`)}`:l=`No vector search field results found for score over ${Ee}.`,await m({text:l},r),{...e,vectorSearchFieldResults:s}}catch(t){throw await m({text:`Error during vector search fields: ${t instanceof Error?t.message:String(t)}`},r),t}},D=(e,r)=>(t,a)=>{let o=a?.configurable?.services;for(let i of e)if(!o?.[i])throw new Error(`${r} requires services.${i} to be available.`);return t},hr=(e,r)=>D(["layerSearch","layersAndFieldsRegistry"],"Navigation Agent")(e,r),fr=()=>new R(ze).addNode("requireNavigationServices",hr).addNode("intentLLM",lr).addNode("vectorSearchLayers",dr).addNode("vectorSearchFields",mr).addNode("agent",nr).addNode("tools",sr).addEdge(N,"requireNavigationServices").addEdge("requireNavigationServices","intentLLM").addConditionalEdges("intentLLM",e=>e.intent==="goToLayer"||e.intent==="goToFeatures"?"vectorSearchLayers":"agent",{vectorSearchLayers:"vectorSearchLayers",agent:"agent"}).addConditionalEdges("vectorSearchLayers",e=>e.intent==="goToFeatures"?"vectorSearchFields":"agent",{vectorSearchFields:"vectorSearchFields",agent:"agent"}).addEdge("vectorSearchFields","agent").addEdge("agent","tools").addEdge("tools",x),gr=String.raw`- **navigation** — Enables users to interact with the map by navigating to specific locations, layers, features, or extents.
|
|
26
|
+
This includes zooming, panning, centering, or geocoding based on user input. The agent is designed to handle explicit map movement requests. NOTE: DO NOT call this agent if the user asks "where is... " or "show me...", that is meant to be handled by another agent.
|
|
27
|
+
|
|
28
|
+
Supported actions:
|
|
29
|
+
- **Zooming**: Adjust the map's zoom level (e.g., "Zoom to level 10", "Zoom in").
|
|
30
|
+
- **Viewpoints**: Navigate to a specific center point with optional zoom or scale (e.g., "Center the map on San Francisco at zoom level 16").
|
|
31
|
+
- **Scales**: Set the map to a specific scale (e.g., "Set the map scale to 1:50,000").
|
|
32
|
+
- **Layers**: Zoom to the full extent of a specific layer (e.g., "Go to the water mains layer").
|
|
33
|
+
- **Features**: Zoom to features in a layer that match a filter (e.g., "Zoom to all schools in the city").
|
|
34
|
+
- **Bookmarks**: Navigate to a predefined bookmark extent (e.g., "Go to the Downtown bookmark").
|
|
35
|
+
- **Extents**: Reset to the initial web map extent or zoom to the full world extent (e.g., "Reset the map", "Zoom to the full world extent").
|
|
36
|
+
- **Addresses**: Zoom to an address or place name (e.g., "Zoom to 1600 Pennsylvania Ave").
|
|
37
|
+
|
|
38
|
+
_Example: “Zoom to Texas”_
|
|
39
|
+
_Example: “Go to the water mains layer”_
|
|
40
|
+
_Example: “Center the map on San Francisco at scale 50000”_
|
|
41
|
+
_Example: “Zoom to the features in the schools layer where city = 'Austin'”_
|
|
42
|
+
_Example: “Go to the Downtown bookmark”_
|
|
43
|
+
_Example: “Zoom to 1600 Pennsylvania Ave”_`,Fs={id:"navigation",name:"Navigation Agent",description:gr,createGraph:fr,workspace:ze},Me=g.Root({messages:g({reducer:A,default:()=>[]}),outputMessage:g({reducer:(e="",r)=>{let t=typeof r=="string"?r.trim():"";if(!t)return e;let a=e.trim();if(!a)return t;if(a===t)return e;let o=a.split(`
|
|
44
|
+
|
|
45
|
+
`);return o[o.length-1]?.trim()===t?e:`${e}
|
|
46
|
+
|
|
47
|
+
${t}`},default:()=>""}),vectorSearchLayerIds:g(),vectorSearchFieldResults:g(),layerFieldInfo:g(),queryResponse:g()}),yr=async(e,r)=>(await m({text:"Exiting Data Exploration agent"},r),e),B=async(e,r)=>{let t=e.tool_calls??[];if(t.length===0){await m({text:`LLM did not request any tool calls: ${String(e?.content)}`},r);return}await Promise.all(t.map(async a=>await m({text:`LLM requested tool call with arguments: ${JSON.stringify(a.args,null,2)}`},r))),console.log("LLM response:",JSON.stringify(e.tool_calls,null,2))},de=async(e,r,t)=>{let a=e.map?.allLayers.find(i=>i.id===r),o=a.createQuery();o.where=t??"1=1";try{let{extent:i,count:s}=await a.queryExtent(o);return!i||s===0?{success:!1,error:`No features found for where clause: ${t}`}:(await e.goTo(i),{success:!0})}catch(i){return{success:!1,error:i instanceof Error?i.message:String(i)}}},pr=async(e,r,t)=>{let a=t.map?.allLayers.find(s=>s.id===e);if(!a)return`Could not find layer with ID: ${e}`;a.definitionExpression=r,a.visible=!0;let o=await de(t,e,r),i=a.title??a.layerId;return o.success?`Applied definition expression to layer "${a.title??e}": ${r}`:`Applied filter to "${i}" but no features matched. ${o.error}`},wr=["mapView"];function k(e){let r=e?.configurable?.context;if(!r||typeof r!="object")throw new Error("DataExplorationAgent context missing");let t=wr.filter(a=>!(a in r));if(t.length)throw new Error(`DataExplorationAgent context missing: ${t.join(", ")}`);return r}var br=async({layerId:e,definitionExpression:r},t)=>{let{mapView:a}=k(t);return await pr(e,r,a)},Sr=n.object({layerId:n.string().describe("The layerId of the layer on which to set a definitionExpression."),definitionExpression:n.string().describe("The SQL-92 where clause used to set a definition expression on the layer.")}),vr=p(br,{name:"setDefinitionExpression",description:"Set a SQL-92 where clause to the definition expression of a layer (i.e. a server-side filter). This filters features at the server level, affecting all views of the layer. Do not prioritize this tool unless specifically asked for or implied for server level, affecting all views of the layer.",schema:Sr});function te(e){return"point"in e&&e.point!==void 0}function re(e){return"layerId"in e&&e.layerId!==void 0}var Q=async(e,r)=>{if(te(e)){let{point:t}=e;return{geometry:new oe({x:t.x,y:t.y,spatialReference:t.spatialReference?{wkid:t.spatialReference.wkid}:r.spatialReference})}}if(re(e)){let t=r.map?.allLayers.find(a=>a.id===e.layerId);if(!t)return{error:`Could not find geometry layer with ID: ${e.layerId}`};try{let a=await t.queryFeatures({where:e.where,returnGeometry:!0,outSpatialReference:r.spatialReference});if(!a.features.length)return{error:`No features found in geometry layer with the specified where clause: ${e.where}`};let o;if(a.features.length===1){let i=a.features[0].geometry;if(!i)return{error:"The geometry of the first feature is undefined or null."};o=i}else{let i=a.features.map(l=>l.geometry),s=U.executeMany(i);if(!s)return{error:"Failed to create a combined geometry."};o=s}return o.spatialReference||(o.spatialReference=r.spatialReference),{geometry:o}}catch(a){return{error:`Failed to query geometry: ${String(a)}`}}}return{error:"Invalid geometry configuration provided"}},Tr=async(e,r,t,a,o)=>{let i=r.map?.allLayers.find(c=>c.id===e.layerId);if(!i)return`Could not find target layer with ID: ${e.layerId}`;let s;if(o){let c=await Q(o,r);if("error"in c)return c.error;s=c.geometry}i.featureEffect=null,i.featureEffect=new Re({filter:new V({where:e.where,geometry:s,spatialRelationship:"intersects",distance:o?.distance,units:o?.units}),includedEffect:t,excludedEffect:a}),i.visible=!0;let l=await de(r,o?o.layerId:e.layerId,o?o.where:e.where),d=i.title??e.layerId;return l.success?`Applied feature effects to target layer "${i.title??e.layerId}"${o?` using geometry from layer "${o.layerId}"`:""}.`:`Applied filter to "${d}" but no features matched. ${l.error}`},xr=["feet","kilometers","meters","miles","nautical-miles","us-nautical-miles"],z=n.enum(xr),Er=async({targetLayer:e,geometryLayer:r,includedEffect:t="drop-shadow(2px, 2px, 2px, gray)",excludedEffect:a="grayscale(100%) opacity(60%) blur(2px)"},o)=>{let{mapView:i}=k(o);return await Tr(e,i,t,a,r)},Lr=n.object({targetLayer:n.object({layerId:n.string().describe("The layerId of the layer on which to set a feature effect."),where:n.string().describe("The SQL-92 where clause representing the features to emphasize.")}),geometryLayer:n.object({layerId:n.string().describe("The layerId of the layer containing the geometry by which to filter."),where:n.string().describe("The SQL-92 where clause representing the features from which to filter features from the targetLayer by geometry."),distance:n.number().describe("The distance by which to filter the input geometry."),units:z.describe("The units used to filter by geometry and distance.")}).optional().describe("Optional geometry-based filtering parameters for spatial queries."),includedEffect:n.string().optional().default("drop-shadow(2px, 2px, 2px, gray)").describe("The effect applied to features that meet the filter requirements. Valid effects include: bloom, blur, brightness, contrast, drop-shadow, grayscale, hue-rotate, invert, opacity, saturate, and sepia. Prefer default unless specified."),excludedEffect:n.string().optional().default("grayscale(100%) opacity(60%) blur(2px)").describe("The effect applied to features that do not meet the filter requirements. Valid effects include: bloom, blur, brightness, contrast, drop-shadow, grayscale, hue-rotate, invert, opacity, saturate, and sepia. Prefer default unless specified.")}),Ir=p(Er,{name:"setFeatureEffect",description:"Sets a feature effect on a given layer with given filter parameters and feature effects to emphasize certain features that meet a filter requirement. If no feature effect information is provided, then use the default effect provided.",schema:Lr}),$r=async(e,r,t)=>{let a=r.map?.allLayers.find(d=>d.id===e.layerId);if(!a)return`Could not find target layer with ID: ${e.layerId}`;let o;if(t){let d=await Q(t,r);if("error"in d)return d.error;o=d.geometry}let i=await r.whenLayerView(a);i.filter=null,i.filter=new V({where:e.where,geometry:o,spatialRelationship:"intersects",distance:t?.distance,units:t?.units}),a.visible=!0;let s=await de(r,t?t.layerId:e.layerId,t?t.where:e.where),l=a.title??e.layerId;return s.success?`Applied feature filter to layer "${a.title??e.layerId}"${t?` using geometry from layer "${t.layerId}"`:""}.`:`Applied filter to "${l}" but no features matched. ${s.error}`},Fr=async({targetLayer:e,geometryLayer:r},t)=>{let{mapView:a}=k(t);return await $r(e,a,r)},_r=n.object({targetLayer:n.object({layerId:n.string().describe("The layerId of the layer on which to set a filter."),where:n.string().describe("The SQL-92 where clause representing the features to display.")}),geometryLayer:n.object({layerId:n.string().describe("The layerId of the layer containing the geometry by which to filter."),where:n.string().describe("The SQL-92 where clause representing the features from which to filter features from the targetLayer by geometry."),distance:n.number().describe("The distance by which to filter the input geometry."),units:z.describe("The units used to filter by geometry and distance.")}).optional().describe("Optional geometry-based filtering parameters for spatial queries.")}),Nr=p(Fr,{name:"setFeatureFilter",description:"Sets a client-side filter using a where clause, geometry filter, or both on a target layer. This filters features at the client level in the view.",schema:_r}),ae=(e,r,t)=>{if(e&&typeof e!="function"){let a="getField"in t&&t.getField?.(e),o=a&&"getFieldDomain"in t&&t.getFieldDomain?t.getFieldDomain(a.name):null;if(o?.type==="coded-value"){let i=o.codedValues.find(s=>s.code===r);return i?i.name:null}}return null},Rr=(e,r,t)=>{let a=e.createQuery();return a.outFields=[r],a.where=t||"1=1",a.num=1,a},Ar=async(e,r,t,a)=>{let o=a.map?.allLayers.find(c=>c.id===e),i=Rr(o,r,t.where),s=(await o.queryFeatures(i)).features[0],l=s?s.attributes[r]:null,d=ae(r,l,o)||l;return{tool:"getAttribute",layerName:o.title??e,summary:`${r} = ${d}`,details:{fieldName:r,value:d,where:t.where}}};async function qr({layerId:e,fieldName:r,query:t},a){let{mapView:o}=k(a),i=await Ar(e,r,t,o);return JSON.stringify(i,null,2)}var kr=n.object({layerId:n.string().describe("The layerId of the layer containing the field from which to get a value."),fieldName:n.string().describe("The name of the field/attribute from which to get a field value."),query:n.object({where:n.string().describe("The SQL-92 where clause representing the feature from which to get an attribute value.")})}),zr=p(qr,{name:"getAttribute",description:"Returns an attribute value for a given feature.",schema:kr}),ue=(e,r)=>r?e.hasAllFeaturesInView:e.hasAllFeatures,Mr=async e=>{let{targetLayer:r,fieldName:t,statisticType:a,mapView:o,layersAndFieldsRegistry:i,geometryLayer:s}=e,l=o.map?.allLayers.find(T=>T.id===r.layerId);if(!l)throw new Error(`Layer '${r.layerId}' not found.`);let d=await o.whenLayerView(l),c=i.get(r.layerId)?.fieldRegistry.get(t);if(!c)throw new Error(`Field '${t}' not found.`);let u,h;if(s){let T=await Q(s,o);if("error"in T)throw new Error(T.error);if(!T.geometry)throw new Error(`No features found matching: ${s.where}`);u={geometryLayerId:s.layerId,geometryWhere:s.where,distance:s.distance,units:s.units,applied:!0},h=new V({geometry:T.geometry,distance:s.distance,units:s.units,spatialRelationship:"intersects"})}let y=ue(d,!1),f=null,w=null,v=10;if(c.type!=="geometry"&&c.type!=="oid"&&c.type!=="global-id")try{f=await ie({layer:l,useFeaturesInView:y,view:y?o:void 0,field:t,sqlWhere:r.where,...h&&{filter:h},outStatisticTypes:{include:[a]}}),["string","small-integer","integer"].includes(c.type)&&(w=(await ne({layer:l,useFeaturesInView:y,view:y?o:void 0,field:t,sqlWhere:r.where,...h&&{filter:h}})).uniqueValueInfos.sort((T,M)=>M.count-T.count).slice(0,v))}catch(T){console.error("Statistics error:",T)}return{tool:"getStatistics",layerName:l.title??r.layerId,summary:`${a} = ${typeof f?.[a]=="number"?f[a]:"N/A"}`,details:{fieldName:t,statisticType:a,statistic:f?.[a]??null,summaryStatistics:f,uniqueValues:w,where:r.where,spatialFilterInfo:u}}};async function Cr({targetLayer:e,fieldName:r,statisticType:t,geometryLayer:a},o){let i=b(o,"layersAndFieldsRegistry"),{mapView:s}=k(o),l=await Mr({targetLayer:e,fieldName:r,statisticType:t,mapView:s,layersAndFieldsRegistry:i,geometryLayer:a});return JSON.stringify(l,null,2)}var jr=n.object({targetLayer:n.object({layerId:n.string().describe("The layerId of the layer containing the field from which to get a value."),where:n.string().describe("The SQL-92 where clause representing the feature from which to get an attribute value.")}),geometryLayer:n.union([n.object({layerId:n.string().describe("The layerId of the layer containing the geometry by which to filter."),where:n.string().describe("The SQL-92 where clause representing the features from which to filter features from the targetLayer by geometry."),distance:n.number().optional().describe("The distance by which to query from the input geometry."),units:z.optional().describe("The units used to query by geometry and distance.")}),n.object({}).strict()]).optional().describe("Optional geometry-based filtering parameters for spatial queries."),fieldName:n.string().describe("The name of the field for which to get statistics. STRICTLY DO NOT use OBJECTID. Use any other field"),statisticType:n.enum(["avg","max","median","min","stddev","sum","variance","nullcount","count"]).describe("The statistic type to calculate.")}),Vr=p(Cr,{name:"getStatistics",description:'Returns one or more summary statistics for the given field. Statistic types include: count, maximum, minimum, average, median, standard deviation, variance, mode, sum, nullcount (number of features without a value for a given field), unique values. For "most common/frequent" questions: Use statisticType "count" on a categorical field. The response includes uniqueValues sorted by frequency (most common first). Statistics can be returned for number, date, and string fields. Also returns frequency analysis for string fields - unique values sorted by occurrence count (most frequent first). Use this for "most common", "most frequent", or "how many of each" questions. Only call this tool when the question requires filtering (e.g. a WHERE clause or spatial constraint) that cannot be satisfied by precomputed stats.',schema:jr}),Or=async(e,r,t,a)=>{let o=t.map?.allLayers.find(u=>u.id===e.layerId),i=await t.whenLayerView(o),s=o.title??e.layerId,l;if(a){let u=await Q(a,t);if("error"in u)return{tool:"getTopFeatures",layerName:s,summary:"Geometry lookup failed",details:{error:u.error}};if(!u.geometry)return{tool:"getTopFeatures",layerName:s,summary:"No features found for geometry filter",details:{error:`No features found matching: ${a.where}`}};l=u.geometry}let d=e.outFields.length>2?e.outFields:["*"],c=r.groupByFields&&r.groupByFields.length>0;try{let u;if(c){let y=new Ae({where:e.where||"1=1",outFields:d,orderByFields:e.orderByFields,geometry:l,spatialRelationship:l?"intersects":void 0,distance:a?.distance,units:a?.units,topFilter:new qe({topCount:r.topCount,groupByFields:r.groupByFields,orderByFields:r.orderByFields})});u=await o.queryTopFeatures(y)}else{let y=new se({where:e.where||"1=1",outFields:d,orderByFields:r.orderByFields,num:r.topCount,geometry:l,spatialRelationship:l?"intersects":void 0,distance:a?.distance,units:a?.units,outSpatialReference:t.spatialReference}),f=ue(i,!1);try{u=f?await i.queryFeatures(y):await o.queryFeatures(y)}catch(w){console.warn("Client-side query failed, falling back to server:",w),u=await o.queryFeatures(y)}}let h=u.features.map(y=>y.attributes);return{tool:"getTopFeatures",layerName:s,summary:`Top ${r.topCount} features extracted`,details:{topCount:r.topCount,attributes:h,where:e.where,orderByFields:r.orderByFields,...c&&{groupByFields:r.groupByFields}}}}catch(u){return{tool:"getTopFeatures",layerName:s,summary:"Query failed",details:{error:u instanceof Error?u.message:String(u)}}}},Dr=async({targetLayer:e,topFilter:r,geometryLayer:t},a)=>{let{mapView:o}=k(a),i=await Or(e,r,o,t);return JSON.stringify(i,null,2)},Br=n.object({targetLayer:n.object({layerId:n.string().describe("The layerId of the layer containing the field from which to get a value."),where:n.string().describe("The SQL-92 where clause representing the feature from which to get an attribute value."),orderByFields:n.array(n.string().describe("The field(s) and order for which to sort the resulting features.")),outFields:n.array(n.string().describe('The fields to include in the output that will be presented to the user. This should include identifying information about the resulting features, like a name or id, along with the values desired in the output. If unsure, choose all fields ("*").').default("*"))}),geometryLayer:n.object({layerId:n.string().describe("The layerId of the layer containing the geometry by which to filter."),where:n.string().describe("The SQL-92 where clause representing the features from which to filter features from the targetLayer by geometry."),distance:n.number().optional().describe("The distance by which to query from the input geometry."),units:z.describe("The units used to query by geometry and distance.").optional()}).optional().describe("Optional geometry-based filtering parameters for spatial queries."),topFilter:n.object({topCount:n.number().describe("Number of top features to return per group."),orderByFields:n.array(n.string().describe("Field(s) to rank by with ASC/DESC. Must be existing field names, not aggregate functions.")),groupByFields:n.array(n.string().describe("Field(s) to group results by. Returns top N per group."))})}),Qr=p(Dr,{name:"getTopFeatures",description:'Returns top N features ranked by an existing field value. Use for "highest", "lowest", "top N" questions where ranking is based on a field that already exists in the data (e.g., population, value, date, depth). orderByFields must be actual field names with ASC/DESC. Do NOT use aggregate functions like COUNT(), SUM(), AVG() - those require getStatistics.',schema:Br}),ee=25,Pr=async(e,r,t,a)=>{let o=r.map?.allLayers.find(f=>f.id===e.layerId),i=await r.whenLayerView(o),s=o.title??e.layerId,l;if(t){let f=await Q(t,r);if("error"in f){let w={error:f.error};return re(t)?(w.geometryLayerId=t.layerId,w.geometryWhere=t.where):te(t)&&(w.point=t.point),{tool:"queryFeatures",layerName:s,summary:"Geometry lookup failed",details:w}}if(!f.geometry){let w={};return re(t)?(w.error=`No features found matching: ${t.where}`,w.geometryLayerId=t.layerId,w.geometryWhere=t.where):te(t)&&(w.error="Failed to create point geometry",w.point=t.point),{tool:"queryFeatures",layerName:s,summary:"No features found for geometry filter",details:w}}l=f.geometry}else a&&(l=r.extent.clone());let d=ue(i,a??!1),c=new se({where:e.where||"1=1",outFields:e.outFields.length?e.outFields:["*"],orderByFields:e.orderByFields,...l&&{geometry:l,spatialRelationship:"intersects"},...t?.distance&&{distance:t.distance},...t?.units&&{units:t.units},outSpatialReference:r.spatialReference}),u,h;try{u=d?await i.queryFeatureCount(c):await o.queryFeatureCount(c),u>0&&u<=ee&&(h=d?await i.queryFeatures(c):await o.queryFeatures(c),h&&h.features.forEach(f=>{let w=f.attributes;o.fields.forEach(v=>{let T=w[v.name],M=ae(v.name,T,o);M&&(w[v.name]=M)})}))}catch(f){console.warn("Client-side query failed, falling back to server:",f),u=await o.queryFeatureCount(c),u>0&&u<=ee&&(h=await o.queryFeatures(c),h&&h.features.forEach(w=>{o.fields.forEach(v=>{let T=w.attributes[v.name],M=ae(v.name,T,o);M&&(w.attributes[v.name]=M)})}))}let y=h?.features.map(f=>f.attributes);return{tool:"queryFeatures",layerName:s,summary:`${u} features found`,details:{totalCount:u,where:e.where,...y&&{attributes:y},...u>ee&&{note:`${u} features found. Too many to list. Use filters to narrow results.`}}}};async function Gr({targetLayer:e,geometryFilter:r,useCurrentExtent:t},a){let{mapView:o}=k(a),i=await Pr(e,o,r,t);return JSON.stringify(i,null,2)}var Wr=n.object({layerId:n.string().describe("The layerId of the layer containing the geometry by which to filter."),where:n.string().describe("The SQL-92 where clause representing the features from which to filter."),distance:n.number().optional().describe("The buffer distance around the geometry."),units:z.optional().describe("The units for the distance buffer.")}),Ur=n.object({point:n.object({x:n.number().describe("X coordinate (longitude) from navigation result"),y:n.number().describe("Y coordinate (latitude) from navigation result"),spatialReference:n.object({wkid:n.number().describe("Spatial reference WKID (e.g., 4326 for WGS84)")}).optional().describe("Spatial reference. Defaults to map's spatial reference if not provided.")}).describe("Point coordinates from a previous navigation/geocoding result"),distance:n.number().optional().describe("Optional buffer distance around the point."),units:z.optional().describe("The units for the distance buffer.")}),Jr=n.object({targetLayer:n.object({layerId:n.string().describe("The layerId of the layer containing the field from which to get a value."),where:n.string().describe("SQL-92 where clause. IMPORTANT: When using geometryFilter.point for point-in-polygon queries, set this to '1=1' to return all features that intersect the point. Only add attribute filters if the user specifically requests them in addition to the spatial query."),orderByFields:n.array(n.string().describe("The field(s) and order for which to sort the resulting features.")),outFields:n.array(n.string().describe('The fields to include in the output that will be presented to the user. This should include identifying information about the resulting features, like a name or id, along with the values desired in the output. If unsure, choose all fields ("*").').default("*"))}),geometryFilter:n.union([Wr,Ur]).optional().describe("Geometry filter for spatial queries. Use 'point' option with x/y coordinates from navigation results to find features at that location (point-in-polygon). Use 'layerId/where' option to filter by features from another layer."),useCurrentExtent:n.boolean().optional().describe("Set to true ONLY when user explicitly asks about features 'in my view', 'on my map', 'I am looking at'. Default is false (queries entire layer).")}),Zr=p(Gr,{name:"queryFeatures",description:"Queries features from a layer. Returns count and attributes (if \u226425 features). Use for listing features, finding features matching conditions, or spatial queries.",schema:Jr}),Ce=[zr,Vr,Qr,Zr],je=[vr,Ir,Nr],J=()=>{let e=new Date().getTimezoneOffset(),r=e<=0?"+":"-",t=Math.floor(Math.abs(e)/60).toString().padStart(2,"0"),a=(Math.abs(e)%60).toString().padStart(2,"0"),o=`${r}${t}:${a}`;return{userTimezone:Intl.DateTimeFormat().resolvedOptions().timeZone,userTimezoneOffset:o}},Hr=async(e,r)=>{await m({text:"Requesting LLM for layer filter results"},r);let t=await q("data_explore_filter_prompt");if(!r?.configurable)throw new Error("config.configurable is required for layer filter tools");let{userTimezone:a,userTimezoneOffset:o}=J(),i={layerFieldInfo:e.layerFieldInfo,userTimezone:a,userTimezoneOffset:o},s=await C({promptText:t,messages:S(e.messages),inputVariables:i,tools:je}),l=[...e.messages,s],d=(s.tool_calls?.length??0)>0?l:[...l,s],c=s.content.toString();return await B(s,r),{...e,messages:d,outputMessage:c}},Kr=async(e,r)=>{await m({text:"Requesting LLM for layer query results"},r);let t=await q("data_explore_query_prompt");if(!r?.configurable)throw new Error("config.configurable is required for layer query tools");let{userTimezone:a,userTimezoneOffset:o}=J(),i={layerFieldInfo:e.layerFieldInfo,userTimezone:a,userTimezoneOffset:o},s=await C({promptText:t,messages:S(e.messages),inputVariables:i,tools:Ce}),l=[...e.messages,s],d=s.content.toString();return await B(s,r),{...e,messages:l,outputMessage:d}},Yr=async(e,r)=>{try{await m({text:"Requesting LLM for summary on query results"},r);let t=await q("summarize_query_response_prompt"),a={queryResponse:e.queryResponse},o=await Y({promptText:t,messages:S(e.messages),inputVariables:a}),i=typeof o=="string"?o:o.content,s=new j(i);return await m({text:`Received response from LLM: ${i}`},r),{...e,outputMessage:i,messages:[...e.messages,s]}}catch(t){throw await m({text:"Error during filter LLM request"},r),new Error(`Error during filter LLM request: ${t instanceof Error?t.message:String(t)}`)}};async function Xr(e,r){let t=await new L(je).invoke({messages:S(e.messages)},r),a=[...e.messages,...t.messages],o=t.messages.map(l=>new j({content:l.content,additional_kwargs:l.additional_kwargs}));await m({text:`Finished executing layer filter tool: ${t.messages.map(l=>l.content).join(", ")}`},r);let i=[...a,...o],s=o.map(l=>l.content).join(`
|
|
48
|
+
|
|
49
|
+
`);return{...e,messages:i,outputMessage:s}}var ea=new L(Ce);async function ta(e,r){let{messages:t}=await ea.invoke({messages:S(e.messages)},r),a=[],o=[];for(let s of t){let l=s.content,d;if(typeof l!="string"){d={tool:s.name??"unknown",layerName:"unknown",summary:"Query failed",details:{error:"Skipping non-string tool output:",raw:l}};continue}try{d=JSON.parse(l)}catch{d={tool:s.name??"unknown",layerName:"unknown",summary:"Query failed",details:{error:l}}}a.push(d),d.details&&typeof d.details=="object"&&"error"in d.details?o.push(`- ${d.tool}: Error - ${String(d.details.error)}`):o.push(`- ${d.layerName}: ${d.summary}`)}let i=[...e.messages,...t];return await m({text:`Finished executing layer query tool: ${o.join(", ")}`},r),{...e,messages:i,queryResponse:a}}var ra=10,aa=async(e,r)=>{let t=null,a=null;try{r.type!=="geometry"&&r.type!=="oid"&&r.type!=="global-id"&&(t=await ie({layer:e,field:r.name}),r.type==="string"&&(a=(await ne({layer:e,field:r.name})).uniqueValueInfos.sort((o,i)=>i.count-o.count).slice(0,ra)))}catch(o){console.error(`Error fetching statistics for field ${r.name}:`,o)}return{summaryStatistics:t,uniqueValues:a}};async function me(e,r,t){let a=[],o=[];for(let i of e){let s=function(y){let f=r.get(y)?.layerItem;return f?[f.name&&`Name: ${f.name}`,f.title&&`Title: ${f.title}`,f.description&&`Description: ${f.description}`].filter(Boolean).join(" | "):y},{layerId:l,results:d}=i,c=t.map?.allLayers.find(y=>y.id===l),u=r.get(l)?.fieldRegistry;if(!u)continue;let h=a.find(y=>y.layerId===l);h||(h={layerId:l,layerSummary:s(l),fieldInfos:[]},a.push(h));for(let y of d){let f=u.get(y.name);if(f){if(!f.statistics){let w=aa(c,f).then(v=>{u.set(f.name,{...f,statistics:v}),f.statistics=v});o.push(w)}h.fieldInfos.push(f)}}}return await Promise.all(o),a}var oa=async(e,r)=>{try{await m({text:"Getting statistics for vector search results"},r);let t=b(r,"layersAndFieldsRegistry"),{mapView:a}=k(r),o=await me(e.vectorSearchFieldResults,t,a);return console.log("Field statistics retrieved:",o),await m({text:"Statistics retrieved"},r),{...e,layerFieldInfo:o}}catch(t){throw await m({text:"Error during fetching statistics"},r),new Error(`Error during fetching statistics: ${t instanceof Error?t.message:String(t)}`)}},Le=.7,ia=10,na=async(e,r)=>{try{let t=F(e.messages);await m({text:"Similarity search to find fields"},r);let a=b(r,"fieldSearch"),o=b(r,"layersAndFieldsRegistry"),i=await a.searchFields({text:t,layerIds:e.vectorSearchLayerIds,minScore:Le,topResults:ia}),s=i.map(({layerId:d,results:c})=>{let u=c.map(h=>` - ${h.name} (${h.score.toFixed(2)})`).join(`
|
|
50
|
+
`);return`${o.get(d)?.layerItem.name??d}:
|
|
51
|
+
${u}`}).join(`
|
|
52
|
+
`),l;return i.length>0?l=`Vector search completed. Matching layers and fields with scores:
|
|
53
|
+
${s}`:l=`No vector search results found for score over ${Le}.`,await m({text:l},r),{...e,vectorSearchFieldResults:i}}catch(t){throw await m({text:`Error during vector search: ${t instanceof Error?t.message:String(t)}`},r),new Error(`Vector search failed: ${t instanceof Error?t.message:String(t)}`)}},sa=.7,la=async(e,r)=>{try{let t=F(e.messages);await m({text:`Similarity search to find layers: ${t}`},r);let a=b(r,"layerSearch"),o=b(r,"layersAndFieldsRegistry"),i=await a.searchLayers({text:t,minScore:sa}),s=i.map(c=>c.id),l=i.map(({id:c,score:u})=>`${o.get(c)?.layerItem.name??c} (${u.toFixed(2)})`).join(`
|
|
54
|
+
`),d;return s.length>0?d=`Vector search completed. Matching layers with scores:
|
|
55
|
+
${l}`:d="Vector search completed. No matching layers found.",await m({text:d},r),{...e,vectorSearchLayerIds:s}}catch(t){throw await m({text:`Error during vector search: ${t instanceof Error?t.message:String(t)}`},r),new Error(`Vector search failed: ${t instanceof Error?t.message:String(t)}`)}},ca=(e,r)=>D(["layerSearch","fieldSearch","layersAndFieldsRegistry"],"Data Exploration Agent")(e,r),da=()=>new R(Me).addNode("requireDataExplorationServices",ca).addNode("vectorSearchLayers",la).addNode("vectorSearchFields",na).addNode("fieldStatistics",oa).addNode("queryAgent",Kr).addNode("queryTools",ta).addNode("summarizeQueryResponseLLM",Yr).addNode("filterAgent",Hr).addNode("filterTools",Xr).addNode("earlyExit",yr).addEdge(N,"requireDataExplorationServices").addEdge("requireDataExplorationServices","vectorSearchLayers").addConditionalEdges("vectorSearchLayers",e=>e.vectorSearchLayerIds.length?"vectorSearchFields":"earlyExit").addConditionalEdges("vectorSearchFields",e=>e.vectorSearchFieldResults.length?"fieldStatistics":"earlyExit").addEdge("fieldStatistics","queryAgent").addConditionalEdges("queryAgent",e=>(e.messages[e.messages.length-1]?.tool_calls?.length??0)>0?"queryTools":"filterAgent").addConditionalEdges("queryTools",e=>e.queryResponse.length?"summarizeQueryResponseLLM":"filterAgent").addEdge("summarizeQueryResponseLLM","filterAgent").addEdge("filterAgent","filterTools").addEdge("filterTools",x).addEdge("summarizeQueryResponseLLM",x).addEdge("earlyExit",x),ua=String.raw`- **data exploration** — User is asking about the feature layer’s data (e.g. counts, summaries, statistics, field values), either for all features, a subset based on a condition, or for a subset based on the current view. And/Or user wants to include or exclude features based on field values, or visually style features differently (e.g., highlight or deemphasize them).
|
|
56
|
+
The Data Exploration Agent will automatically zoom to the affected features for action taken by this agent. In this case, no need to call navigation tool separately.
|
|
57
|
+
_Example: “Only show stations where Brand is Shell”_
|
|
58
|
+
_Example: “Make Shell stations stand out on the map”_
|
|
59
|
+
_Example: “Gray out all stations that aren’t Shell”_
|
|
60
|
+
This also includes questions that ask which feature meets a given condition or where a particular feature in the data is located (e.g., “Where is the spring with the highest elevation?”).
|
|
61
|
+
_Example: “How many features are there?”_
|
|
62
|
+
_Example: “What’s the average population?”_
|
|
63
|
+
_Example: “Which values are in the status field?”_`,_s={id:"dataExploration",name:"Data Exploration Agent",description:ua,createGraph:da,workspace:Me},Ie=.7,ma=10,ha=async(e,r)=>{try{let t=F(e.messages);await m({text:"Similarity search to find fields"},r);let a=b(r,"fieldSearch"),o=b(r,"layersAndFieldsRegistry"),i=await a.searchFields({text:t,layerIds:e.vectorSearchLayerIds,minScore:Ie,topResults:ma}),s=i.map(({layerId:d,results:c})=>{let u=c.map(h=>` - ${h.name} (${h.score.toFixed(2)})`).join(`
|
|
64
|
+
`);return`${o.get(d)?.layerItem.name??d}:
|
|
65
|
+
${u}`}).join(`
|
|
66
|
+
`),l;return i.length>0?l=`Vector search completed. Matching layers and fields with scores:
|
|
67
|
+
${s}`:l=`No vector search results found for score over ${Ie}.`,await m({text:l},r),{...e,vectorSearchFieldResults:i}}catch(t){throw await m({text:`Error during vector search: ${t instanceof Error?t.message:String(t)}`},r),new Error(`Vector search failed: ${t instanceof Error?t.message:String(t)}`)}},fa=.7,ga=async(e,r)=>{try{let t=F(e.messages);await m({text:`Similarity search to find layers: ${t}`},r);let a=b(r,"layerSearch"),o=b(r,"layersAndFieldsRegistry"),i=await a.searchLayers({text:t,minScore:fa}),s=i.map(c=>c.id),l=i.map(({id:c,score:u})=>`${o.get(c)?.layerItem.name??c} (${u.toFixed(2)})`).join(`
|
|
68
|
+
`),d;return s.length>0?d=`Vector search completed. Matching layers with scores:
|
|
69
|
+
${l}`:d="Vector search completed. No matching layers found.",await m({text:d},r),{...e,vectorSearchLayerIds:s}}catch(t){throw await m({text:`Error during vector search: ${t instanceof Error?t.message:String(t)}`},r),new Error(`Vector search failed: ${t instanceof Error?t.message:String(t)}`)}},Ve=["mapView"];function Z(e){let r=e?.configurable?.context;if(!r||typeof r!="object")throw new Error("LayerFilterAgent context missing");let t=Ve.filter(a=>!(a in r));if(t.length)throw new Error(`LayerFilterAgent context missing: ${t.join(", ")}`);return r}var ya=async(e,r)=>{try{await m({text:"Getting statistics for vector search results"},r);let t=b(r,"layersAndFieldsRegistry"),{mapView:a}=Z(r),o=await me(e.vectorSearchFieldResults,t,a);return console.log("Field statistics retrieved:",o),await m({text:"Statistics retrieved"},r),{...e,layerFieldInfo:o}}catch(t){throw await m({text:"Error during fetching statistics"},r),new Error(`Error during fetching statistics: ${t instanceof Error?t.message:String(t)}`)}},he=async(e,r,t)=>{let a=e.map?.allLayers.find(s=>s.id===r),o=a.createQuery();o.where=t??"1=1";let{features:i}=await a.queryFeatures(o);e.goTo(i)},pa=(e,r,t)=>{let a=t.map?.allLayers.find(o=>o.id===e);return a?(a.definitionExpression=r,a.visible=!0,he(t,e,r),`Applied definition expression to layer "${a.title??e}": ${r}`):`Could not find layer with ID: ${e}`},wa=({layerId:e,definitionExpression:r},t)=>{let{mapView:a}=Z(t);return pa(e,r,a)},ba=n.object({layerId:n.string().describe("The layerId of the layer on which to set a definitionExpression."),definitionExpression:n.string().describe("The SQL-92 where clause used to set a definition expression on the layer.")}),Sa=p(wa,{name:"setDefinitionExpression",description:"Set a SQL-92 where clause to the definition expression of a layer (i.e. a server-side filter). This filters features at the server level, affecting all views of the layer. Do not prioritize this tool unless specifically asked for or implied for server level, affecting all views of the layer.",schema:ba}),Oe=async(e,r)=>{let t=r.map?.allLayers.find(i=>i.id===e.layerId);if(!t)return{error:`Could not find geometry layer with ID: ${e.layerId}`};let a=await t.queryFeatures({where:e.where,returnGeometry:!0});if(!a.features.length)return{error:`No features found in geometry layer with the specified where clause: ${e.where}`};let o;if(a.features.length===1){let i=a.features[0].geometry;if(!i)return{error:"The geometry of the first feature is undefined or null."};o=i}else{let i=a.features.map(l=>l.geometry),s=U.executeMany(i);if(!s)return{error:"Failed to create a combined geometry."};o=s}return{geometry:o}},va=async(e,r,t,a,o)=>{let i=r.map?.allLayers.find(l=>l.id===e.layerId);if(!i)return`Could not find target layer with ID: ${e.layerId}`;console.log("Layer type:",i.type),console.log("Layer geometryType:",i.geometryType),console.log("Layer renderer:",i.renderer?.type);let s;if(o){let l=await Oe(o,r);if("error"in l)return l.error;s=l.geometry}return i.featureEffect=new Re({filter:new V({where:e.where,geometry:s,spatialRelationship:"intersects",distance:o?.distance,units:o?.units}),includedEffect:t,excludedEffect:a}),i.visible=!0,he(r,o?o.layerId:e.layerId,o?o.where:e.where),`Applied feature effects to target layer "${i.title??e.layerId}"${o?` using geometry from layer "${o.layerId}"`:""}.`},Ta=["feet","kilometers","meters","miles","nautical-miles","us-nautical-miles"],De=n.enum(Ta),xa=async({targetLayer:e,geometryLayer:r,includedEffect:t="drop-shadow(2px, 2px, 2px, gray)",excludedEffect:a="grayscale(100%) opacity(60%) blur(2px)"},o)=>{let{mapView:i}=Z(o);return await va(e,i,t,a,r)},Ea=n.object({targetLayer:n.object({layerId:n.string().describe("The layerId of the layer on which to set a feature effect."),where:n.string().describe("The SQL-92 where clause representing the features to emphasize.")}),geometryLayer:n.object({layerId:n.string().describe("The layerId of the layer containing the geometry by which to filter."),where:n.string().describe("The SQL-92 where clause representing the features from which to filter features from the targetLayer by geometry."),distance:n.number().describe("The distance by which to filter the input geometry."),units:De.describe("The units used to filter by geometry and distance.")}).optional().describe("Optional geometry-based filtering parameters for spatial queries."),includedEffect:n.string().optional().default("drop-shadow(2px, 2px, 2px, gray)").describe("The effect applied to features that meet the filter requirements. Valid effects include: bloom, blur, brightness, contrast, drop-shadow, grayscale, hue-rotate, invert, opacity, saturate, and sepia. Prefer default unless specified."),excludedEffect:n.string().optional().default("grayscale(100%) opacity(60%) blur(2px)").describe("The effect applied to features that do not meet the filter requirements. Valid effects include: bloom, blur, brightness, contrast, drop-shadow, grayscale, hue-rotate, invert, opacity, saturate, and sepia. Prefer default unless specified.")}),La=p(xa,{name:"setFeatureEffect",description:"Sets a feature effect on a given layer with given filter parameters and feature effects to emphasize certain features that meet a filter requirement. If no feature effect information is provided, then use the default effect provided.",schema:Ea}),Ia=async(e,r,t)=>{let a=r.map?.allLayers.find(s=>s.id===e.layerId);if(!a)return`Could not find target layer with ID: ${e.layerId}`;let o;if(t){let s=await Oe(t,r);if("error"in s)return s.error;o=s.geometry}let i=await r.whenLayerView(a);return i.filter=new V({where:e.where,geometry:o,spatialRelationship:"intersects",distance:t?.distance,units:t?.units}),a.visible=!0,he(r,t?t.layerId:e.layerId,t?t.where:e.where),`Applied feature filter to layer "${a.title??e.layerId}"${t?` using geometry from layer "${t.layerId}"`:""}.`},$a=async({targetLayer:e,geometryLayer:r},t)=>{let{mapView:a}=Z(t);return await Ia(e,a,r)},Fa=n.object({targetLayer:n.object({layerId:n.string().describe("The layerId of the layer on which to set a filter."),where:n.string().describe("The SQL-92 where clause representing the features to display.")}),geometryLayer:n.object({layerId:n.string().describe("The layerId of the layer containing the geometry by which to filter."),where:n.string().describe("The SQL-92 where clause representing the features from which to filter features from the targetLayer by geometry."),distance:n.number().describe("The distance by which to filter the input geometry."),units:De.describe("The units used to filter by geometry and distance.")}).optional().describe("Optional geometry-based filtering parameters for spatial queries.")}),_a=p($a,{name:"setFeatureFilter",description:"Sets a client-side filter using a where clause, geometry filter, or both on a target layer. This filters features at the client level in the view.",schema:Fa}),Be=[Sa,La,_a],Na=async(e,r)=>{await m({text:"Requesting LLM for layer filter results"},r);let t=await q("layer_filter_prompt");if(!r?.configurable)throw new Error("config.configurable is required for layer filter tools");let{userTimezone:a,userTimezoneOffset:o}=J(),i={layerFieldInfo:e.layerFieldInfo,userTimezone:a,userTimezoneOffset:o},s=await C({promptText:t,messages:S(e.messages),inputVariables:i,tools:Be}),l=s.content.toString();return await B(s,r),{...e,messages:[...e.messages,s],outputMessage:l}};async function Ra(e,r){let t=await new L(Be).invoke({messages:S(e.messages)},r),a=t.messages.map(s=>s.text).join(`
|
|
70
|
+
`);await m({text:`Finished executing layer filter tool: ${a}`},r);let o=[...e.messages,...t.messages],i=t.messages.map(s=>s.text).join(`
|
|
71
|
+
`);return{...e,outputMessage:i,messages:o}}var Qe=g.Root({messages:g({reducer:A,default:()=>[]}),outputMessage:g({reducer:(e="",r)=>{let t=typeof r=="string"?r.trim():"";if(!t)return e;let a=e.trim();if(!a)return t;if(a===t)return e;let o=a.split(`
|
|
72
|
+
|
|
73
|
+
`);return o[o.length-1]?.trim()===t?e:`${e}
|
|
74
|
+
|
|
75
|
+
${t}`},default:()=>""}),vectorSearchLayerIds:g(),vectorSearchFieldResults:g(),layerFieldInfo:g()}),Aa=async(e,r)=>(await m({text:"Exiting Layer Filter agent"},r),e),qa=(e,r)=>D(["layerSearch","fieldSearch","layersAndFieldsRegistry"],"Layer Filter Agent")(e,r),ka=()=>new R(Qe).addNode("requireLayerFilterServices",qa).addNode("vectorSearchLayers",ga).addNode("vectorSearchFields",ha).addNode("fieldStatistics",ya).addNode("agent",Na).addNode("tools",Ra).addNode("earlyExit",Aa).addEdge(N,"requireLayerFilterServices").addEdge("requireLayerFilterServices","vectorSearchLayers").addConditionalEdges("vectorSearchLayers",e=>e.vectorSearchLayerIds.length?"vectorSearchFields":"earlyExit").addConditionalEdges("vectorSearchFields",e=>e.vectorSearchFieldResults.length?"fieldStatistics":"earlyExit").addEdge("fieldStatistics","agent").addConditionalEdges("agent",e=>(e.messages[e.messages.length-1]?.tool_calls?.length??0)>0?"tools":"earlyExit").addEdge("tools","earlyExit").addEdge("earlyExit",x),za=String.raw`- **layer filter** — User wants to include or exclude features based on field values, or visually style features differently (e.g., highlight or deemphasize them).
|
|
76
|
+
The Layer Filter Agent will automatically zoom to the affected features for action taken by this agent. In this case, no need to call navigation tool separately.
|
|
77
|
+
_Example: “Only show stations where Brand is Shell”_
|
|
78
|
+
_Example: “Make Shell stations stand out on the map”_
|
|
79
|
+
_Example: “Gray out all stations that aren’t Shell”_`,Ns={id:"layerFilter",name:"Layer Filter Agent",description:za,createGraph:ka,workspace:Qe},Pe=g.Root({messages:g({reducer:A,default:()=>[]}),outputMessage:g({reducer:(e="",r)=>{let t=typeof r=="string"?r.trim():"";if(!t)return e;let a=e.trim();if(!a)return t;if(a===t)return e;let o=a.split(`
|
|
80
|
+
|
|
81
|
+
`);return o[o.length-1]?.trim()===t?e:`${e}
|
|
82
|
+
|
|
83
|
+
${t}`},default:()=>""}),vectorSearchLayerIds:g(),vectorSearchFieldResults:g(),layerFieldInfo:g(),queryResponses:g()}),Ma=async(e,r)=>(await m({text:"Exiting Layer Query agent"},r),e);function P(e){let r=e?.configurable?.context;if(!r||typeof r!="object")throw new Error("LayerQueryAgent context missing");let t=Ve.filter(a=>!(a in r));if(t.length)throw new Error(`LayerQueryAgent context missing: ${t.join(", ")}`);return r}var Ca=async(e,r)=>{try{await m({text:"Getting statistics for vector search results"},r);let t=b(r,"layersAndFieldsRegistry"),{mapView:a}=P(r),o=await me(e.vectorSearchFieldResults,t,a);return console.log("Field statistics retrieved:",o),await m({text:"Statistics retrieved"},r),{...e,layerFieldInfo:o}}catch(t){throw await m({text:"Error during fetching statistics"},r),new Error(`Error during fetching statistics: ${t instanceof Error?t.message:String(t)}`)}},$e=.7,ja=10,Va=async(e,r)=>{try{let t=F(e.messages);await m({text:"Similarity search to find fields"},r);let a=b(r,"fieldSearch"),o=b(r,"layersAndFieldsRegistry"),i=await a.searchFields({text:t,layerIds:e.vectorSearchLayerIds,minScore:$e,topResults:ja}),s=i.map(({layerId:d,results:c})=>{let u=c.map(h=>` - ${h.name} (${h.score.toFixed(2)})`).join(`
|
|
84
|
+
`);return`${o.get(d)?.layerItem.name??d}:
|
|
85
|
+
${u}`}).join(`
|
|
86
|
+
`),l;return i.length>0?l=`Vector search completed. Matching layers and fields with scores:
|
|
87
|
+
${s}`:l=`No vector search results found for score over ${$e}.`,await m({text:l},r),{...e,vectorSearchFieldResults:i}}catch(t){throw await m({text:`Error during vector search: ${t instanceof Error?t.message:String(t)}`},r),new Error(`Vector search failed: ${t instanceof Error?t.message:String(t)}`)}},Oa=.7,Da=async(e,r)=>{try{let t=F(e.messages);await m({text:`Similarity search to find layers: ${t}`},r);let a=b(r,"layerSearch"),o=b(r,"layersAndFieldsRegistry"),i=await a.searchLayers({text:t,minScore:Oa}),s=i.map(c=>c.id),l=i.map(({id:c,score:u})=>`${o.get(c)?.layerItem.name??c} (${u.toFixed(2)})`).join(`
|
|
88
|
+
`),d;return s.length>0?d=`Vector search completed. Matching layers with scores:
|
|
89
|
+
${l}`:d="Vector search completed. No matching layers found.",await m({text:d},r),{...e,vectorSearchLayerIds:s}}catch(t){throw await m({text:`Error during vector search: ${t instanceof Error?t.message:String(t)}`},r),new Error(`Vector search failed: ${t instanceof Error?t.message:String(t)}`)}},Ba=(e,r,t)=>{let a=e.createQuery();return a.outFields=[r],a.where=t||"1=1",a.num=1,a},Qa=async(e,r,t,a)=>{let o=a.map?.allLayers.find(d=>d.id===e),i=Ba(o,r,t.where),s=(await o.queryFeatures(i)).features[0],l=s?s.attributes[r]:null;return{tool:"getAttribute",layerName:o.title??e,summary:`${r} = ${l}`,details:{fieldName:r,value:l,where:t.where}}};async function Pa({layerId:e,fieldName:r,query:t},a){let{mapView:o}=P(a),i=await Qa(e,r,t,o);return JSON.stringify(i,null,2)}var Ga=n.object({layerId:n.string().describe("The layerId of the layer containing the field from which to get a value."),fieldName:n.string().describe("The name of the field/attribute from which to get a field value."),query:n.object({where:n.string().describe("The SQL-92 where clause representing the feature from which to get an attribute value.")})}),Wa=p(Pa,{name:"getAttribute",description:"Returns an attribute value for a given feature.",schema:Ga}),fe=async(e,r)=>{let t=r.map?.allLayers.find(i=>i.id===e.layerId);if(!t)return{error:`Could not find geometry layer with ID: ${e.layerId}`};let a=await t.queryFeatures({where:e.where,returnGeometry:!0});if(!a.features.length)return{error:`No features found in geometry layer with the specified where clause: ${e.where}`};let o;if(a.features.length===1){let i=a.features[0].geometry;if(!i)return{error:"The geometry of the first feature is undefined or null."};o=i}else{let i=a.features.map(l=>l.geometry),s=U.executeMany(i);if(!s)return{error:"Failed to create a combined geometry."};o=s}return{geometry:o}},Ua=async e=>{let{targetLayer:r,fieldName:t,statisticType:a,mapView:o,layersAndFieldsRegistry:i,geometryLayer:s}=e,l=o.map?.allLayers.find(f=>f.id===r.layerId);if(!l)throw new Error(`Layer '${r.layerId}' not found.`);let d=i.get(r.layerId)?.fieldRegistry.get(t);if(!d)throw new Error(`Field '${t}' not found.`);let c;if(s){let f=await fe(s,o);if("error"in f)throw new Error(f.error);if(c=f.geometry,s.distance&&s.units){let w=ke.execute(c,s.distance,{unit:s.units==="us-nautical-miles"?"nautical-miles":s.units});w&&(c=w)}}else c=o.extent.clone();let u=new V({geometry:c,spatialRelationship:"intersects"}),h=null,y=null;try{h=await ie({layer:l,field:t,sqlWhere:r.where,filter:u,outStatisticTypes:{include:[a]}}),d.type==="string"&&(y=(await ne({layer:l,field:t,sqlWhere:r.where,filter:u})).uniqueValueInfos)}catch(f){console.error("Statistics error:",f)}return{tool:"getStatistics",layerName:l.title??r.layerId,summary:`${a} = ${typeof h?.[a]=="number"?h[a]:"N/A"}`,details:{fieldName:t,statisticType:a,statistic:h?.[a]??null,summaryStatistics:h,uniqueValues:y,where:r.where}}},Ja=["feet","kilometers","meters","miles","nautical-miles","us-nautical-miles"],Za=n.enum(Ja);async function Ha({targetLayer:e,fieldName:r,statisticType:t,geometryLayer:a},o){let i=b(o,"layersAndFieldsRegistry"),{mapView:s}=P(o),l=await Ua({targetLayer:e,fieldName:r,statisticType:t,mapView:s,layersAndFieldsRegistry:i,geometryLayer:a});return console.log(l),JSON.stringify(l,null,2)}var Ka=n.object({targetLayer:n.object({layerId:n.string().describe("The layerId of the layer containing the field from which to get a value."),where:n.string().describe("The SQL-92 where clause representing the feature from which to get an attribute value.")}),geometryLayer:n.union([n.object({layerId:n.string().describe("The layerId of the layer containing the geometry by which to filter."),where:n.string().describe("The SQL-92 where clause representing the features from which to filter features from the targetLayer by geometry."),distance:n.number().optional().describe("The distance by which to query from the input geometry."),units:Za.optional().describe("The units used to query by geometry and distance.")}),n.object({}).strict()]).optional().describe("Optional geometry-based filtering parameters for spatial queries."),fieldName:n.string().describe("The name of the field for which to get statistics."),statisticType:n.enum(["avg","max","median","min","stddev","sum","variance","nullcount","count"]).describe("The statistic type to calculate.")}),Ya=p(Ha,{name:"getStatistics",description:"Returns one or more summary statistics for the given field. Statistic types include: count, maximum, minimum, average, median, standard deviation, variance, mode, sum, nullcount (number of features without a value for a given field), unique values. Statistics can be returned for number, date, and string fields. Only call this tool when the question requires filtering (e.g. a WHERE clause or spatial constraint) that cannot be satisfied by precomputed stats.",schema:Ka}),Xa=async(e,r,t,a)=>{let o=t.map?.allLayers.find(c=>c.id===e.layerId),i=a?await fe(a,t):{geometry:void 0},s="geometry"in i?i.geometry:void 0,l=new Ae({where:e.where||"1=1",outFields:e.outFields.length?e.outFields:["*"],orderByFields:e.orderByFields,geometry:s,spatialRelationship:s?"intersects":void 0,distance:a?.distance,units:a?.units,topFilter:new qe({topCount:r.topCount,groupByFields:r.groupByFields,orderByFields:r.orderByFields})}),d=await o.queryTopFeatures(l);return{tool:"getTopFeatures",layerName:o.title??e.layerId,summary:`Top ${r.topCount} features extracted`,details:{topCount:r.topCount,features:d.features,where:e.where}}},eo=async({targetLayer:e,topFilter:r,geometryLayer:t},a)=>{let{mapView:o}=P(a),i=await Xa(e,r,o,t);return JSON.stringify(i,null,2)},to=n.object({targetLayer:n.object({layerId:n.string().describe("The layerId of the layer containing the field from which to get a value."),where:n.string().describe("The SQL-92 where clause representing the feature from which to get an attribute value."),orderByFields:n.array(n.string().describe("The field(s) and order for which to sort the resulting features.")),outFields:n.array(n.string().describe("The fields to include in the output that will be presented to the user. This should include identifying information about the resulting features, like a name or id, along with the values desired in the output."))}),geometryLayer:n.object({layerId:n.string().describe("The layerId of the layer containing the geometry by which to filter."),where:n.string().describe("The SQL-92 where clause representing the features from which to filter features from the targetLayer by geometry."),distance:n.number().describe("The distance by which to query from the input geometry."),units:z.describe("The units used to query by geometry and distance.")}).optional().describe("Optional geometry-based filtering parameters for spatial queries."),topFilter:n.object({topCount:n.number().describe("The SQL-92 where clause representing the feature from which to get an attribute value."),orderByFields:n.array(n.string().describe("The field(s) and order for which to sort the resulting features.")),groupByFields:n.array(n.string().describe("The field(s) for which to group by the top features."))})}),ro=p(eo,{name:"getTopFeatures",description:"Returns the top n features from a layer",schema:to}),ao=async(e,r,t)=>{let a=r.map?.allLayers.find(d=>d.id===e.layerId),o=t?await fe(t,r):{geometry:void 0},i="geometry"in o?o.geometry:void 0,s=new se({where:e.where||"1=1",outFields:e.outFields.length?e.outFields:["*"],orderByFields:e.orderByFields,geometry:i,spatialRelationship:i?"intersects":void 0,distance:t?.distance,units:t?.units}),l=await a.queryFeatures(s);return{tool:"queryFeatures",layerName:a.title??e.layerId,summary:`${l.features.length} features found`,details:{totalCount:l.features.length,features:l.features.slice(0,10),where:e.where}}};async function oo({targetLayer:e,geometryLayer:r},t){let{mapView:a}=P(t),o=await ao(e,a,r);return JSON.stringify(o,null,2)}var io=n.object({targetLayer:n.object({layerId:n.string().describe("The layerId of the layer containing the field from which to get a value."),where:n.string().describe("The SQL-92 where clause representing the feature from which to get an attribute value."),orderByFields:n.array(n.string().describe("The field(s) and order for which to sort the resulting features.")),outFields:n.array(n.string().describe("The fields to include in the output that will be presented to the user. This should include identifying information about the resulting features, like a name or id, along with the values desired in the output."))}),geometryLayer:n.object({layerId:n.string().describe("The layerId of the layer containing the geometry by which to filter."),where:n.string().describe("The SQL-92 where clause representing the features from which to filter features from the targetLayer by geometry."),distance:n.number().describe("The distance by which to query from the input geometry."),units:z.describe("The units used to query by geometry and distance.")}).optional().describe("Optional geometry-based filtering parameters for spatial queries.")}),no=p(oo,{name:"queryFeatures",description:"Queries for one or more features from a given layer.",schema:io}),Ge=[no,Ya,Wa,ro],so=async(e,r)=>{await m({text:"Requesting LLM for layer query results"},r);let t=await q("data_query_prompt");if(!r?.configurable)throw new Error("config.configurable is required for layer query tools");let{userTimezone:a,userTimezoneOffset:o}=J(),i={layerFieldInfo:e.layerFieldInfo,userTimezone:a,userTimezoneOffset:o},s=await C({promptText:t,messages:S(e.messages),inputVariables:i,tools:Ge});if(!(s.tool_calls&&Array.isArray(s.tool_calls)&&s.tool_calls.length>0))return{...e,messages:[...e.messages,s]};let l=s.content.toString()||"LLM requested tool calls.";return await B(s,r),{...e,outputMessage:l,messages:[...e.messages,s]}},lo=new L(Ge);async function co(e,r){let{messages:t}=await lo.invoke({messages:S(e.messages)},r),a=[],o=[];for(let l of t){let d=l.content;if(typeof d!="string"){console.warn("Skipping non-string tool output:",d);continue}let c;try{c=JSON.parse(d)}catch{console.warn("Skipping invalid JSON from tool:",d);continue}a.push(c),o.push(`- ${c.layerName}: ${c.summary}`)}if(o.length===0)return{...e,queryResponses:a};let i=new j({content:`Query results:
|
|
90
|
+
${o.join(`
|
|
91
|
+
`)}`}),s=`Query results:
|
|
92
|
+
${o.join(`
|
|
93
|
+
`)}`;return{...e,outputMessage:s,messages:[...e.messages,...t,i],queryResponses:a}}var uo=async(e,r)=>{try{await m({text:"Requesting LLM for summary on query results"},r);let t=await q("summarize_query_response_prompt"),a={queryResponse:e.queryResponses},o=await Y({promptText:t,messages:S(e.messages),inputVariables:a}),i=typeof o=="string"?o:o.content;return e.messages=[...e.messages,new j(i)],e.outputMessage=i,await m({text:`Received response from LLM: ${i}`},r),e}catch(t){throw await m({text:"Error during filter LLM request"},r),new Error(`Error during filter LLM request: ${t instanceof Error?t.message:String(t)}`)}},mo=(e,r)=>D(["layerSearch","fieldSearch","layersAndFieldsRegistry"],"Layer Query Agent")(e,r),ho=()=>new R(Pe).addNode("requireLayerQueryServices",mo).addNode("vectorSearchLayers",Da).addNode("vectorSearchFields",Va).addNode("fieldStatistics",Ca).addNode("agent",so).addNode("tools",co).addNode("summarizeQueryResponseLLM",uo).addNode("earlyExit",Ma).addEdge(N,"requireLayerQueryServices").addEdge("requireLayerQueryServices","vectorSearchLayers").addConditionalEdges("vectorSearchLayers",e=>e.vectorSearchLayerIds.length?"vectorSearchFields":"earlyExit").addConditionalEdges("vectorSearchFields",e=>e.vectorSearchFieldResults.length?"fieldStatistics":"earlyExit").addEdge("fieldStatistics","agent").addEdge("agent","tools").addConditionalEdges("tools",e=>e.queryResponses.length?"summarizeQueryResponseLLM":"earlyExit").addEdge("summarizeQueryResponseLLM",x).addEdge("earlyExit",x),fo=String.raw`- **layerQuery** — User is asking about the feature layer’s data (e.g. counts, summaries, statistics, field values), either for all features, a subset based on a condition, or for a subset based on the current view. CRITICAL: Always call the Layer Filter Agent after this agent.
|
|
94
|
+
This also includes questions that ask which feature meets a given condition or where a particular feature in the data is located (e.g., “Where is the spring with the highest elevation?”).
|
|
95
|
+
_Example: “How many features are there?”_
|
|
96
|
+
_Example: “What’s the average population?”_
|
|
97
|
+
_Example: “Which values are in the status field?”_`,Rs={id:"layerQuery",name:"Layer Query Agent",description:fo,createGraph:ho,workspace:Pe},Fe=.7,go=10,yo=async(e,r)=>{try{let t=F(e.messages);await m({text:"Similarity search to find fields"},r);let a=b(r,"fieldSearch"),o=b(r,"layersAndFieldsRegistry"),i=await a.searchFields({text:t,layerIds:e.vectorSearchLayerIds,minScore:Fe,topResults:go}),s=i.map(({layerId:d,results:c})=>{let u=c.map(h=>` - ${h.name} (${h.score.toFixed(2)})`).join(`
|
|
98
|
+
`);return`${o.get(d)?.layerItem.name??d}:
|
|
99
|
+
${u}`}).join(`
|
|
100
|
+
`),l;return i.length>0?l=`Vector search completed. Matching layers and fields with scores:
|
|
101
|
+
${s}`:l=`No vector search results found for score over ${Fe}.`,await m({text:l},r),{...e,vectorSearchFieldResults:i}}catch(t){throw await m({text:`Error during vector search: ${t instanceof Error?t.message:String(t)}`},r),new Error(`Vector search failed: ${t instanceof Error?t.message:String(t)}`)}},po=.7,wo=async(e,r)=>{try{let t=F(e.messages);await m({text:`Similarity search to find layers: ${t}`},r);let a=b(r,"layerSearch"),o=b(r,"layersAndFieldsRegistry"),i=await a.searchLayers({text:t,minScore:po}),s=i.map(c=>c.id),l=i.map(({id:c,score:u})=>`${o.get(c)?.layerItem.name??c} (${u.toFixed(2)})`).join(`
|
|
102
|
+
`),d;return s.length>0?d=`Vector search completed. Matching layers with scores:
|
|
103
|
+
${l}`:d="Vector search completed. No matching layers found.",await m({text:d},r),{...e,vectorSearchLayerIds:s}}catch(t){throw await m({text:`Error during vector search: ${t instanceof Error?t.message:String(t)}`},r),new Error(`Vector search failed: ${t instanceof Error?t.message:String(t)}`)}};async function bo(e){let{fields:r,layer:t,view:a,styleName:o,colorSchemeTags:i}=e,s;return i?s=it({basemapTheme:await Te(a),geometryType:t.geometryType,includedTags:i,numColors:Math.min(r.length,8)})[0]:s=nt({basemapTheme:await Te(a),geometryType:t.geometryType,numColors:Math.min(r.length,8)}).primaryScheme,{layer:t,view:a,attributes:r.map(l=>({field:l,label:t.fields.find(d=>d.name===l)?.alias??""})).slice(0,8),outlineOptimizationEnabled:!0,sizeOptimizationEnabled:!0,includeSizeVariable:o.includes("Size"),pieChartScheme:s}}async function So(e){return await ot(e)}async function vo({arcgisMap:e,arcgisMapView:r,layerId:t,fields:a,colorSchemes:o,includeSize:i}){let s=r,l=e?.allLayers.find(c=>c.id===t);if(!l)return`Could not find layer for id: ${t}`;let d={styleName:i?"chart-size":"chart",fields:a,layer:l,view:s,colorSchemeTags:o};try{let c=await bo(d),u=await So(c);return l.renderer=u.renderer,l.visible=!0,`Chart renderer applied to layer: ${l.title??l.id} using fields ${a.join(", ")}`}catch(c){return`Error applying chart renderer: ${c instanceof Error?c.message:String(c)}`}}var To=["mapView"];function I(e){let r=e?.configurable?.context;if(!r||typeof r!="object")throw new Error("LayerStylingAgent context missing");let t=To.filter(a=>!(a in r));if(t.length)throw new Error(`LayerStylingAgent context missing: ${t.join(", ")}`);return r}async function xo({layerId:e,fields:r,colorSchemes:t,includeSize:a},o){let{mapView:i}=I(o);return await E({id:"show-legend",description:"Show Legend",payload:{layerIds:[e]}},o),await vo({arcgisMap:i.map,arcgisMapView:i,layerId:e,fields:r,colorSchemes:t,includeSize:a})}var Eo=n.object({layerId:n.string().describe("The id of the layer to apply the chart renderer to"),fields:n.array(n.string()).describe("The fields to use for the chart renderer (multiple numeric fields)"),colorSchemes:n.array(n.string()).optional().describe("Optional color scheme tags to use"),includeSize:n.boolean().optional().describe("Whether to vary the chart size (chart-size)")}),Lo=p(xo,{name:"chart",description:`Label: Charts
|
|
104
|
+
Description: Show the values of two or more categories as a proportion of the total using a pie chart.
|
|
105
|
+
Keywords: pie, chart, all categories, breakdown, proportion
|
|
106
|
+
Example: Show the total number of homes built in each decade using a pie chart for each feature.
|
|
107
|
+
Fields: This style requires 2-8 number fields.
|
|
108
|
+
|
|
109
|
+
Label: Charts and Size
|
|
110
|
+
Description: Show the values of two or more categories as a proportion of the total using a pie chart and use size to capture the total amount or magnitude.
|
|
111
|
+
Keywords: pie, chart, all categories, breakdown, proportion, total, amount, how much, sum, graduated size, proportional size
|
|
112
|
+
Example: Show the total number of homes built in each decade using a pie chart for each feature and vary the size of each chart based on the total of all categories.
|
|
113
|
+
Fields: This style requires 2-8 number fields.`,schema:Eo});function Io(e){let{fields:r,layer:t,view:a,theme:o,colorSchemeTags:i}=e,s=r[0],l;return i&&(l=le({geometryType:t.geometryType,includedTags:i,theme:o||"high-to-low"})[0]),{layer:t,view:a,startTime:s,endTime:new Date,theme:o,sizeOptimizationEnabled:!0,outlineOptimizationEnabled:!0,colorScheme:l}}async function $o(e){return await st(e)}async function Fo({arcgisMap:e,arcgisMapView:r,layerId:t,fields:a,colorSchemes:o,theme:i}){let s=r,l=e?.allLayers.find(c=>c.id===t);if(!l)return`Could not find layer for id: ${t}`;let d={styleName:"color-age",fields:a,layer:l,view:s,colorSchemeTags:o,theme:i};try{let c=Io(d),u=await $o(c);return l.renderer=u.renderer,l.visible=!0,`Color-age renderer applied to layer: ${l.title??l.id} using fields ${a.join(", ")}`}catch(c){return`Error applying color-age renderer: ${c instanceof Error?c.message:String(c)}`}}async function _o({layerId:e,fields:r,colorSchemes:t,theme:a},o){let{mapView:i}=I(o);return await E({id:"show-legend",description:"Show Legend",payload:{layerIds:[e]}},o),await Fo({arcgisMap:i.map,arcgisMapView:i,layerId:e,fields:r,colorSchemes:t,theme:a})}var No=n.object({layerId:n.string().describe("The id of the layer to apply the color-age renderer to"),fields:n.array(n.string()).describe("The field(s) to use for the color-age renderer (temporal/date data)"),colorSchemes:n.array(n.string()).optional().describe("Optional color scheme tags to use"),theme:n.enum(["above-and-below","above","below","centered-on","extremes","high-to-low"]).optional().describe("Optional theme for the color ramp")}),Ro=p(_o,{name:"color-age",description:`Label: Age (color)
|
|
114
|
+
Description: Use colors along a continuous color ramp to represent the age of features. Age reflects the length of time from a start date to an end date.
|
|
115
|
+
Keywords: since, age, how old, how long
|
|
116
|
+
Example: Show the age of each feature based on its reported date.
|
|
117
|
+
Fields: This style requires at least one field with a date type.`,schema:No});function Ao(e){let{fields:r,layer:t,view:a,colorSchemeTags:o}=e,{theme:i}=e,s=r[1],l=r[0],d;return o&&(d=le({geometryType:t.geometryType,includedTags:o,theme:i||"high-to-low"})[0]),{layer:t,view:a,field:l,normalizationField:s,theme:i,sizeOptimizationEnabled:!0,outlineOptimizationEnabled:!0,colorScheme:d}}async function qo(e){return await lt(e)}async function ko({arcgisMap:e,arcgisMapView:r,layerId:t,fields:a,colorSchemes:o,theme:i}){let s=r,l=e?.allLayers.find(c=>c.id===t);if(!l)return`Could not find layer for id: ${t}`;let d={styleName:"color",fields:a,layer:l,view:s,colorSchemeTags:o,theme:i};try{let c=Ao(d),u=await qo(c);return l.renderer=u.renderer,l.visible=!0,`Color renderer applied to layer: ${l.title??l.id} using fields ${a.join(", ")}`}catch(c){return`Error applying color renderer: ${c instanceof Error?c.message:String(c)}`}}async function zo({layerId:e,fields:r,colorSchemes:t,theme:a},o){let{mapView:i}=I(o);return await E({id:"show-legend",description:"Show Legend",payload:{layerIds:[e]}},o),await ko({arcgisMap:i.map,arcgisMapView:i,layerId:e,fields:r,colorSchemes:t,theme:a})}var Mo=n.object({layerId:n.string().describe("The id of the layer to apply the color renderer to"),fields:n.array(n.string()).describe("The field(s) to use for the color renderer"),colorSchemes:n.array(n.string()).optional().describe("Optional color scheme tags to use"),theme:n.enum(["above-and-below","above","below","centered-on","extremes","high-to-low"]).optional().describe("Optional theme for the color ramp")}),Co=p(zo,{name:"color",description:`Label: Counts and Amounts (color)
|
|
118
|
+
Description: Vary color along a continuous color ramp to represent numeric or ranked data.
|
|
119
|
+
Keywords: graduated color, choropleth, continuous color, hue, color, gradation, saturation, lightness, percent, rate, ratio, index, how much, increase, decrease
|
|
120
|
+
Example: Color each feature based on the population density.
|
|
121
|
+
Fields: This style requires a single field with a number type. A second number field may be specified for normalizing the value of the first field.`,schema:Mo});function jo(e){let{fields:r,layer:t,view:a,colorSchemeTags:o,theme:i}=e,s,l,d=r[0];return o&&(l=le({geometryType:t.geometryType,includedTags:o,theme:i||"high-to-low"})[0]),{layer:t,view:a,field:d,normalizationField:s,theme:i,colorOptions:{colorScheme:l}}}async function Vo(e){return await ct(e)}async function Oo({arcgisMap:e,arcgisMapView:r,layerId:t,fields:a,colorSchemes:o,theme:i}){let s=r,l=e?.allLayers.find(c=>c.id===t);if(!l)return`Could not find layer for id: ${t}`;let d={styleName:"color-size-univariate",fields:a,layer:l,view:s,colorSchemeTags:o,theme:i};try{let c=jo(d),u=await Vo(c);return l.renderer=u.renderer,l.visible=!0,`Color-size-univariate renderer applied to layer: ${l.title??l.id} using fields ${a.join(", ")}`}catch(c){return`Error applying color-size-univariate renderer: ${c instanceof Error?c.message:String(c)}`}}async function Do({layerId:e,fields:r,colorSchemes:t,theme:a},o){let{mapView:i}=I(o);return await E({id:"show-legend",description:"Show Legend",payload:{layerIds:[e]}},o),await Oo({arcgisMap:i.map,arcgisMapView:i,layerId:e,fields:r,colorSchemes:t,theme:a})}var Bo=n.object({layerId:n.string().describe("The id of the layer to apply the color-size univariate renderer to"),fields:n.array(n.string()).describe("The fields to use for the color-size univariate renderer"),colorSchemes:n.array(n.string()).optional().describe("Optional color scheme tags to use"),theme:n.enum(["above-and-below","above","below","centered-on","extremes","high-to-low"]).optional().describe("Optional theme for the color and size ramps")}),Qo=p(Do,{name:"color-size-univariate",description:`Label: Color and Size (univariate)
|
|
122
|
+
Description: Vary symbol size and color based on the values of two numeric attributes.
|
|
123
|
+
Keywords: continuous color, hue, color, size, gradation, saturation, lightness, percent, rate, ratio, index, how much, increase, decrease, amount
|
|
124
|
+
Example: Color each feature based on the percentage of the population that owns a home and vary the size of each point based on total population.
|
|
125
|
+
Fields: This style requires at least two fields: one determining the color of each feature, the other determining the size of each feature. Each field may be normalized by an additional normalization field.`,schema:Bo});function Po(e){let{fields:r,layer:t,view:a,colorSchemeTags:o}=e,i;return o&&(i=ut({includedTags:o,numColors:Math.min(r.length,8)})[0]),{layer:t,view:a,legendOptions:{unit:"units"},attributes:r.map(s=>({field:s,label:t.fields.find(l=>l.name===s)?.alias??""})).slice(0,8),outlineOptimizationEnabled:!0,dotDensityScheme:i}}async function Go(e){return await dt(e)}async function Wo({arcgisMap:e,arcgisMapView:r,layerId:t,fields:a,colorSchemes:o}){let i=r,s=e?.allLayers.find(d=>d.id===t);if(!s)return`Could not find layer for id: ${t}`;let l={styleName:"dot-density",fields:a,layer:s,view:i,colorSchemeTags:o};try{let d=Po(l),c=await Go(d);return s.renderer=c.renderer,s.visible=!0,`Dot Density renderer applied to layer: ${s.title??s.id} using fields ${a.join(", ")}`}catch(d){return`Error applying dot density renderer: ${d instanceof Error?d.message:String(d)}`}}async function Uo({layerId:e,fields:r,colorSchemes:t},a){let{mapView:o}=I(a);return await E({id:"show-legend",description:"Show Legend",payload:{layerIds:[e]}},a),await Wo({arcgisMap:o.map,arcgisMapView:o,layerId:e,fields:r,colorSchemes:t})}var Jo=n.object({layerId:n.string().describe("The id of the layer to apply the dot density renderer to"),fields:n.array(n.string()).describe("The field(s) to use for the dot density renderer (population or count data)"),colorSchemes:n.array(n.string()).optional().describe("Optional color scheme tags to use")}),Zo=p(Uo,{name:"dot-density",description:`Dot Density
|
|
126
|
+
Use dot density to visualize the distribution of one attribute or compare the density of multiple attributes. This is only valid for polygon layers.
|
|
127
|
+
**Use cases:**
|
|
128
|
+
- Population distribution visualization
|
|
129
|
+
- Comparing multiple categories within areas
|
|
130
|
+
- Showing spatial distribution patterns
|
|
131
|
+
**Examples:**
|
|
132
|
+
- Show the density of the population based on various race/ethnic groups
|
|
133
|
+
- Visualize distribution of different crops across regions
|
|
134
|
+
- Display demographic patterns within census tracts
|
|
135
|
+
**Fields:** Requires 2-8 number fields.
|
|
136
|
+
**Keywords:** density, how much, how many, total, number, amount`,schema:Jo});function Ho(e){let{fields:r,layer:t,view:a,colorSchemeTags:o}=e,i,s=r[0];return o&&(i=ht({includedTags:o,basemap:a.map?.basemap||"topo"})[0]),{layer:t,view:a,field:s,heatmapScheme:i}}async function Ko(e){return await mt(e)}async function Yo({arcgisMap:e,arcgisMapView:r,layerId:t,fields:a,colorSchemes:o}){let i=r,s=e?.allLayers.find(d=>d.id===t);if(!s)return`Could not find layer for id: ${t}`;let l={styleName:"heatmap",fields:a,layer:s,view:i,colorSchemeTags:o};try{let d=Ho(l),c=await Ko(d);return s.renderer=c.renderer,s.visible=!0,`Heatmap renderer applied to layer: ${s.title??s.id} using fields ${a.join(", ")}`}catch(d){return`Error applying heatmap renderer: ${d instanceof Error?d.message:String(d)}`}}async function Xo({layerId:e,fields:r,colorSchemes:t},a){let{mapView:o}=I(a);return await E({id:"show-legend",description:"Show Legend",payload:{layerIds:[e]}},a),await Yo({arcgisMap:o.map,arcgisMapView:o,layerId:e,fields:r,colorSchemes:t})}var ei=n.object({layerId:n.string().describe("The id of the layer to apply the heatmap renderer to"),fields:n.array(n.string()).describe("The field(s) to use for the heatmap renderer (typically point density)"),colorSchemes:n.array(n.string()).optional().describe("Optional color scheme tags to use")}),ti=p(Xo,{name:"heatmap",description:`Label: Heat Map
|
|
137
|
+
Description: Show areas of high density with colors that appear to glow hotter. This is only valid for point layers.
|
|
138
|
+
Keywords: density, heatmap, hot spots, pattern, cluster
|
|
139
|
+
Example: Create a heatmap
|
|
140
|
+
Fields: This typically requires zero or one field of type number.`,schema:ei});function ri(e){let{fields:r,layer:t,view:a,styleName:o,colorSchemeTags:i}=e,s;return i&&(s=gt({geometryType:t.geometryType,includedTags:i,numColors:Math.min(r.length,10)})[0]),{layer:t,view:a,fields:r.map(l=>({name:l})).slice(0,9),outlineOptimizationEnabled:!0,sizeOptimizationEnabled:!0,includeSizeVariable:o.includes("Size"),predominanceScheme:s}}async function ai(e){return await ft(e)}async function oi({arcgisMap:e,arcgisMapView:r,layerId:t,fields:a,colorSchemes:o,includeSize:i}){let s=r,l=e?.allLayers.find(c=>c.id===t);if(!l)return`Could not find layer for id: ${t}`;let d={styleName:i?"predominance-size":"predominance",fields:a,layer:l,view:s,colorSchemeTags:o};try{let c=ri(d),u=await ai(c);return l.renderer=u.renderer,l.visible=!0,`Predominance renderer applied to layer: ${l.title??l.id} using fields ${a.join(", ")}`}catch(c){return`Error applying predominance renderer: ${c instanceof Error?c.message:String(c)}`}}async function ii({layerId:e,fields:r,colorSchemes:t,includeSize:a},o){let{mapView:i}=I(o);return await E({id:"show-legend",description:"Show Legend",payload:{layerIds:[e]}},o),await oi({arcgisMap:i.map,arcgisMapView:i,layerId:e,fields:r,colorSchemes:t,includeSize:a})}var ni=n.object({layerId:n.string().describe("The id of the layer to apply the predominance renderer to"),fields:n.array(n.string()).describe("The fields to use for the predominance renderer (competing categories)"),colorSchemes:n.array(n.string()).optional().describe("Optional color scheme tags to use"),includeSize:n.boolean().optional().describe("Whether to include size visualization (predominance-size)")}),si=p(ii,{name:"predominance",description:`Label: Predominant category
|
|
141
|
+
Description: Compare attributes that share a common subject and unit of measurement to see which has the highest value.
|
|
142
|
+
Keywords: predominant, winner, won, competing, most, most common, most frequent, dominant, prevalent, top
|
|
143
|
+
Example: Using fields for Corn Acres, Wheat Acres, and Cotton Acres, show the predominant crop harvested in each area.
|
|
144
|
+
Fields: This style relies on 2-10 number fields.
|
|
145
|
+
|
|
146
|
+
Label: Predominant category and Size
|
|
147
|
+
Description: Compare attributes that share a common subject and unit of measurement to see which has the highest value. Also varies the size of each symbol based on the total of all categories.
|
|
148
|
+
Keywords: predominant, winner, won, competing, most, most common, most frequent, dominant, prevalent, top, amount, total, how much, proportional size, graduated size, sum
|
|
149
|
+
Example: Show the predominant crop in each area and vary the size of each symbol based on the total of all categories.
|
|
150
|
+
Fields: This style relies on 2-10 number fields.`,schema:ni});function li(e){let{fields:r,layer:t,view:a,colorSchemeTags:o}=e,i,s={field:r[0]},l={field:r[1]};return o&&(i=pt({geometryType:t.geometryType,includedTags:o})[0]),{layer:t,view:a,field1:s,field2:l,outlineOptimizationEnabled:!0,sizeOptimizationEnabled:!0,relationshipScheme:i}}async function ci(e){return await yt(e)}async function di({arcgisMap:e,arcgisMapView:r,layerId:t,fields:a,colorSchemes:o}){let i=r,s=e?.allLayers.find(d=>d.id===t);if(!s)return`Could not find layer for id: ${t}`;let l={styleName:"relationship",fields:a,layer:s,view:i,colorSchemeTags:o};try{let d=li(l),c=await ci(d);return s.renderer=c.renderer,s.visible=!0,`Relationship renderer applied to layer: ${s.title??s.id} using fields ${a.join(", ")}`}catch(d){return`Error applying relationship renderer: ${d instanceof Error?d.message:String(d)}`}}async function ui({layerId:e,fields:r,colorSchemes:t},a){let{mapView:o}=I(a);return await E({id:"show-legend",description:"Show Legend",payload:{layerIds:[e]}},a),await di({arcgisMap:o.map,arcgisMapView:o,layerId:e,fields:r,colorSchemes:t})}var mi=n.object({layerId:n.string().describe("The id of the layer to apply the relationship renderer to"),fields:n.array(n.string()).describe("The two fields to use for the relationship renderer (bivariate visualization)"),colorSchemes:n.array(n.string()).optional().describe("Optional color scheme tags to use")}),hi=p(ui,{name:"relationship",description:`Label: Relationship
|
|
151
|
+
Description: Overlays two color ramps to represent the relationship between two numeric attributes.
|
|
152
|
+
Keywords: relationship, correlation, compare, related, bivariate choropleth, bivariate color
|
|
153
|
+
Example: Show the relationship between tree height and carbon storage
|
|
154
|
+
Fields: This style requires two number fields.`,schema:mi});function fi(e){let{fields:r,layer:t,view:a,theme:o}=e,i=r[0];return{layer:t,view:a,startTime:i,endTime:new Date,theme:o,sizeOptimizationEnabled:!0,outlineOptimizationEnabled:!0}}async function gi(e){return await wt(e)}async function yi({arcgisMap:e,arcgisMapView:r,layerId:t,fields:a,colorSchemes:o,theme:i}){let s=r,l=e?.allLayers.find(c=>c.id===t);if(!l)return`Could not find layer for id: ${t}`;let d={styleName:"size-age",fields:a,layer:l,view:s,colorSchemeTags:o,theme:i};try{let c=fi(d),u=await gi(c);return l.renderer=u.renderer,l.visible=!0,`Size-age renderer applied to layer: ${l.title??l.id} using fields ${a.join(", ")}`}catch(c){return`Error applying size-age renderer: ${c instanceof Error?c.message:String(c)}`}}async function pi({layerId:e,fields:r,colorSchemes:t,theme:a},o){let{mapView:i}=I(o);return await E({id:"show-legend",description:"Show Legend",payload:{layerIds:[e]}},o),await yi({arcgisMap:i.map,arcgisMapView:i,layerId:e,fields:r,colorSchemes:t,theme:a})}var wi=n.object({layerId:n.string().describe("The id of the layer to apply the size-age renderer to"),fields:n.array(n.string()).describe("The field(s) to use for the size-age renderer (temporal data with size)"),colorSchemes:n.array(n.string()).optional().describe("Optional color scheme tags to use"),theme:n.enum(["above-and-below","above","below","centered-on","extremes","high-to-low"]).optional().describe("Optional theme for the size ramp")}),bi=p(pi,{name:"size-age",description:`Label: Age (size)
|
|
155
|
+
Description: Vary symbol sizes along a continuous ramp to represent the age of features. Age reflects the length of time from a start date to an end date.
|
|
156
|
+
Keywords: since, age, how old, how long
|
|
157
|
+
Example: Change the size of features so older features are larger than new features.
|
|
158
|
+
Fields: This style requires at least one field with a date type.`,schema:wi});function Si(e){let{fields:r,layer:t,view:a}=e,{theme:o}=e,i=r[1],s=r[0];return{layer:t,view:a,field:s,normalizationField:i,theme:o,sizeOptimizationEnabled:!0,outlineOptimizationEnabled:!0}}async function vi(e){return await bt(e)}async function Ti({arcgisMap:e,arcgisMapView:r,layerId:t,fields:a,colorSchemes:o,theme:i}){let s=r,l=e?.allLayers.find(c=>c.id===t);if(!l)return`Could not find layer for id: ${t}`;let d={styleName:"size",fields:a,layer:l,view:s,colorSchemeTags:o,theme:i};try{let c=Si(d),u=await vi(c);return l.renderer=u.renderer,l.visible=!0,`Size renderer applied to layer: ${l.title??l.id} using fields ${a.join(", ")}`}catch(c){return`Error applying size renderer: ${c instanceof Error?c.message:String(c)}`}}async function xi({layerId:e,fields:r,colorSchemes:t,theme:a},o){let{mapView:i}=I(o);return await E({id:"show-legend",description:"Show Legend",payload:{layerIds:[e]}},o),await Ti({arcgisMap:i.map,arcgisMapView:i,layerId:e,fields:r,colorSchemes:t,theme:a})}var Ei=n.object({layerId:n.string().describe("The id of the layer to apply the size renderer to"),fields:n.array(n.string()).describe("The field(s) to use for the size renderer (numeric data)"),colorSchemes:n.array(n.string()).optional().describe("Optional color scheme tags to use"),theme:n.enum(["above-and-below","above","below","centered-on","extremes","high-to-low"]).optional().describe("Optional theme for the size ramp")}),Li=p(xi,{name:"size",description:`Label: Counts and Amounts (size)
|
|
159
|
+
Description: Vary symbol sizes along a continuous ramp to represent numeric or ranked data.
|
|
160
|
+
Keywords: graduated size, proportional size, how much, total, number, amount, size
|
|
161
|
+
Example: Vary the size of each point based on the total population.
|
|
162
|
+
Fields: This style requires a single field with a number type. A second number field may be specified for normalizing the value of the first field.
|
|
163
|
+
|
|
164
|
+
Label: Continuous Timeline (size)
|
|
165
|
+
Description: Vary symbol sizes along a continuous ramp to represent dates.
|
|
166
|
+
Keywords: graduated size, proportional size, classed size, how much, total, number, when
|
|
167
|
+
Example: Vary the size of each feature based on the date a ticket was completed.
|
|
168
|
+
Fields: This style requires a single field with a date type.`,schema:Ei});function Ii(e){let{fields:r,layer:t,view:a,colorSchemeTags:o}=e;console.log("processTypeRendererParams",e);let i=r[0],s=r[1],l=r[2],d;return o&&(d=vt({geometryType:t.geometryType,includedTags:o})[0]),{layer:t,view:a,field:i,field2:s,field3:l,outlineOptimizationEnabled:!0,sizeOptimizationEnabled:!0,typeScheme:d}}async function $i(e){return await St(e)}async function Fi({arcgisMap:e,arcgisMapView:r,layerId:t,fields:a,colorSchemes:o,theme:i}){let s=r,l=e?.allLayers.find(c=>c.id===t);if(!l)return`Could not find layer for id: ${t}`;let d={styleName:"type",fields:a,layer:l,view:s,colorSchemeTags:o,theme:i};try{let c=Ii(d),u=await $i(c);return l.renderer=u.renderer,l.visible=!0,`Type renderer applied to layer: ${l.title??l.id} using fields ${a.join(", ")}`}catch(c){return`Error applying type renderer: ${c instanceof Error?c.message:String(c)}`}}async function _i({layerId:e,fields:r,colorSchemes:t,theme:a},o){let{mapView:i}=I(o);return await E({id:"show-legend",description:"Show Legend",payload:{layerIds:[e]}},o),await Fi({arcgisMap:i.map,arcgisMapView:i,layerId:e,fields:r,colorSchemes:t,theme:a})}var Ni=n.object({layerId:n.string().describe("The id of the layer to apply the type renderer to"),fields:n.array(n.string()).describe("The field(s) to use for the type renderer (categorical data)"),colorSchemes:n.array(n.string()).optional().describe("Optional color scheme tags to use"),theme:n.enum(["above-and-below","above","below","centered-on","extremes","high-to-low"]).optional().describe("Optional theme for the color scheme")}),Ri=p(_i,{name:"type",description:`Label: Types (unique symbols)
|
|
169
|
+
Description: Represent features as categories with different symbol colors or shapes. Examples include type of tree, road class, or province name.
|
|
170
|
+
Keywords: categorical, category, type, unique, discrete, point of interest, region, group
|
|
171
|
+
Example: Color each feature based on the region it belongs to
|
|
172
|
+
Fields: This style requires a single field which may be a string, number, or date type. It is usually a string.`,schema:Ni}),We=[Lo,Ro,Co,Qo,Zo,ti,si,hi,bi,Li,Ri],Ai=async(e,r)=>{await m({text:"Requesting LLM for layer query results"},r);let t=await q("navigation_intent_prompt");if(!r?.configurable)throw new Error("config.configurable is required for layer query tools");let a={layerFieldInfo:e.layerFieldInfo},o=await C({promptText:t,messages:S(e.messages),inputVariables:a,tools:We});return await B(o,r),{...e,messages:[...e.messages,o]}};async function qi(e,r){let t=await new L(We).invoke({messages:S(e.messages)},r),a=t.messages.map(i=>i.text).join(`
|
|
173
|
+
`);await m({text:`Finished executing layer filter tool: ${a}`},r);let o=t.messages.map(i=>i.text).join(`
|
|
174
|
+
`);return{...e,outputMessage:o}}var Ue=g.Root({messages:g({reducer:A,default:()=>[]}),outputMessage:g({reducer:(e="",r)=>{let t=typeof r=="string"?r.trim():"";if(!t)return e;let a=e.trim();if(!a)return t;if(a===t)return e;let o=a.split(`
|
|
175
|
+
|
|
176
|
+
`);return o[o.length-1]?.trim()===t?e:`${e}
|
|
177
|
+
|
|
178
|
+
${t}`},default:()=>""}),vectorSearchLayerIds:g(),vectorSearchFieldResults:g(),layerFieldInfo:g(),selectedLayerId:g()}),ki=async(e,r)=>(await m({text:"Exiting Layer Styling agent"},r),e),zi=async(e,r)=>{try{await m({text:"Populating layer and field info"},r);let t=[];for(let a of e.vectorSearchFieldResults){let o=function(u){let h=l.get(u)?.layerItem;return h?[h.name&&`Name: ${h.name}`,h.title&&`Title: ${h.title}`,h.description&&`Description: ${h.description}`].filter(Boolean).join(" | "):u},{layerId:i,results:s}=a,l=b(r,"layersAndFieldsRegistry"),d=l.get(i)?.fieldRegistry;if(!d)continue;let c=t.find(u=>u.layerId===i);c||(c={layerId:i,layerSummary:o(i),fieldInfos:[]},t.push(c));for(let u of s){let h=d.get(u.name);h&&c.fieldInfos.push(h)}}return console.log("Populated layerFieldInfo:",t),await m({text:"Populated layerFieldInfo"},r),{...e,layerFieldInfo:t}}catch(t){throw await m({text:"Error populating layerFieldInfo"},r),new Error(`Error populating layerFieldInfo: ${t instanceof Error?t.message:String(t)}`)}},Mi=(e,r)=>{let t=e.vectorSearchLayerIds??[];if(t.length<=1)return{...e,selectedLayerId:e.vectorSearchLayerIds[0]};let{hitlResponse:a}=r.configurable;if(console.log("hitlResponse:",a),!a||a.agentId!==_e.id||a.id!=="reviewLayerSelection"){let i={agentId:_e.id,id:"reviewLayerSelection",kind:"singleSelection",message:"Choose a layer to apply the styles.",metadata:[...t]};throw new ge(i)}let o=null;return Array.isArray(a.payload)&&a.payload.length>0&&(o=a.payload[0]),{...e,selectedLayerId:o??e.vectorSearchLayerIds[0]}},Ci=(e,r)=>D(["layerSearch","fieldSearch","layersAndFieldsRegistry"],"Layer Styling Agent")(e,r),ji=()=>new R(Ue).addNode("requireLayerStylingServices",Ci).addNode("vectorSearchLayers",wo).addNode("layerSelectionHITL",Mi).addNode("vectorSearchFields",yo).addNode("populateLayerFieldInfo",zi).addNode("agent",Ai).addNode("tools",qi).addNode("earlyExit",ki).addEdge(N,"requireLayerStylingServices").addEdge("requireLayerStylingServices","vectorSearchLayers").addConditionalEdges("layerSelectionHITL",e=>e.vectorSearchLayerIds.length?"vectorSearchFields":"earlyExit").addConditionalEdges("vectorSearchFields",e=>e.vectorSearchFieldResults.length?"populateLayerFieldInfo":"earlyExit").addEdge("populateLayerFieldInfo","agent").addEdge("agent","tools").addEdge("tools",x).addEdge("earlyExit",x),Vi=String.raw`- **layerStyling** — User wants to change how features are drawn or styled on the map based on their data, such as applying color, size, transparency, symbols, or charts according to field values.
|
|
179
|
+
_Example: “Color points by sales amount”_
|
|
180
|
+
_Example: “Show population density with a color gradient”_
|
|
181
|
+
_Example: “Create a relationship map between height and depth”_
|
|
182
|
+
_Example: “Vary circle sizes according to population”_`,_e={id:"layerStyling",name:"Layer Styling Agent",description:Vi,createGraph:ji,workspace:Ue},As=g.Root({messages:g({reducer:A,default:()=>[]}),outputMessage:g({reducer:(e="",r)=>{let t=typeof r=="string"?r.trim():"";if(!t)return e;let a=e.trim();if(!a)return t;if(a===t)return e;let o=a.split(`
|
|
183
|
+
|
|
184
|
+
`);return o[o.length-1]?.trim()===t?e:`${e}
|
|
185
|
+
|
|
186
|
+
${t}`},default:()=>""}),intent:g({reducer:(e,r)=>r})}),Oi=["linkChartView"];function Je(e){let r=e?.configurable?.context;if(!r||typeof r!="object")throw new Error("LinkChartAgent context missing");let t=Oi.filter(a=>!(a in r));if(t.length)throw new Error(`Link Chart context missing: ${t.join(", ")}`);return r}async function Di(e,r){return await r.map.applyLayout(e),`Successfully applied layout: ${e}.`}async function Bi({layout:e},r){let{linkChartView:t}=Je(r);return await Di(e,t)}var Qi=n.object({layout:n.enum(["organic-standard","organic-community","basic-grid","hierarchical-bottom-to-top","radial-root-centric","tree-left-to-right","geographic-organic-standard","chronological-mono-timeline","chronological-multi-timeline"]).describe("The layout mode to apply to the link chart. The value must be one of the following: organic-standard, organic-community, basic-grid, hierarchical-bottom-to-top, radial-root-centric, tree-left-to-right, geographic-organic-standard, chronological-mono-timeline, chronological-multi-timeline")}),qs=p(Bi,{name:"applyLayout",description:"Apply a diagram layout to the link chart",schema:Qi});function Pi(e,r){return r.map.changeNonspatialDataDisplay(e),`Successfully applied nonspatial visibility setting: ${e}.`}function Gi({setting:e},r){let{linkChartView:t}=Je(r);return Pi(e,t)}var Wi=n.object({setting:n.enum(["hidden","visible"]).describe("The setting of nonspatial visibility")}),ks=p(Gi,{name:"changeNonspatialVisibility",description:"Change whether or not nonspatial data is visible in the link chart. The value must be either 'hidden' or 'visible'.",schema:Wi});var zs=String.raw`Enables users to interact with a link chart by adding new entities (also called nodes) or relationships (also called edges), removing existing entities or relationships,
|
|
187
|
+
expanding the graph from particular entities, finding relationships between specified entities on the link chart and adding them to the link chart, finding all relationships
|
|
188
|
+
that exist out from specified entities and adding those to the link chart, changing whether or not nonspatial data is visible, or changing the layout of the link chart.
|
|
189
|
+
This agent is designed to handle requests that manipulate the specific link chart.
|
|
190
|
+
|
|
191
|
+
Supported actions:
|
|
192
|
+
- **Change or Apply Layout**: Changes the current layout visualization strategy of the link chart (e.g., "Change the layout to basic-grid", "Apply hierarchical layout"). Valid layout types include organic-standard, organic-community, basic-grid, hierarchical-bottom-to-top, radial-root-centric, tree-left-to-right, geographic-organic-standard, chronological-mono-timeline. A best effort should be made to transform the user's request into one of these layout types.
|
|
193
|
+
- **Change Nonspatial Data Visibility**: Changes whether or not nonspatial data is visible on the link chart (e.g., "Show nonspatial data", "Hide nonspatial data"). Valid settings are "hidden" and "visible". A best effort should be made to transform the user's request into one of these settings.
|
|
194
|
+
- **Add Records (entities or relationships)**: NYI
|
|
195
|
+
- **Remove Records (entities or relationships)**: NYI
|
|
196
|
+
- **Expand from Entities**: NYI
|
|
197
|
+
- **Find Relationships Between Entities**: NYI
|
|
198
|
+
- **Find all Relationships Out from Entities**: NYI
|
|
199
|
+
|
|
200
|
+
_example: "Change the layout to hierarchical-bottom-to-top"_
|
|
201
|
+
_example: "Apply radial-root-centric layout"_
|
|
202
|
+
_example: "Show nonspatial data"_
|
|
203
|
+
_example: "Hide nonspatial data"_
|
|
204
|
+
_example: "Turn off nonspatial visibility"_`;return{a:Fs,b:_s,c:Ns,d:Rs,e:_e}},"Graphic","geometry/Point","geometry/Extent","symbols/SimpleMarkerSymbol","rest/locator","layers/support/FeatureEffect","layers/support/FeatureFilter","geometry/operators/unionOperator","smartMapping/statistics/summaryStatistics","smartMapping/statistics/uniqueValues","rest/support/TopFeaturesQuery","rest/support/TopFilter","rest/support/Query","geometry/operators/bufferOperator","smartMapping/renderers/pieChart","smartMapping/symbology/pieChart","views/support/colorUtils","smartMapping/renderers/color","smartMapping/symbology/color","smartMapping/renderers/univariateColorSize","smartMapping/renderers/dotDensity","smartMapping/symbology/dotDensity","smartMapping/renderers/heatmap","smartMapping/symbology/heatmap","smartMapping/renderers/predominance","smartMapping/symbology/predominance","smartMapping/renderers/relationship","smartMapping/symbology/relationship","smartMapping/renderers/size","smartMapping/renderers/type","smartMapping/symbology/type",a)
|
|
@@ -0,0 +1,4 @@
|
|
|
1
|
+
/*! All material copyright Esri, All Rights Reserved, unless otherwise specified.
|
|
2
|
+
See https://js.arcgis.com/5.0/esri/copyright.txt for details.
|
|
3
|
+
v5.0.0-next.133 */
|
|
4
|
+
import{a as c}from"./2KGO3SIH.js";import"./UIUJKONY.js";import{g as e,h as t,p as s,t as i}from"./YXLN5DSL.js";import"./46CNQJRX.js";var r=e`.assistant-chat-card__prompt-container{display:flex;align-items:center;gap:var(--calcite-spacing-md);background:color-mix(in srgb,var(--calcite-color-brand) 25%,transparent);padding:var(--calcite-spacing-md);border-radius:var(--calcite-border-radius);width:fit-content;margin-left:auto;justify-content:flex-end}.assistant-chat-card__prompt-avatar{display:flex;align-items:center;justify-content:center}.assistant-chat-card__content-container{display:flex;flex:1;flex-direction:column;width:100%}.assistant-chat-card__response-container{display:flex;flex-direction:column;align-items:flex-start;gap:var(--calcite-spacing-sm);width:100%;text-align:left}.assistant-chat-card__response-icon{padding:var(--calcite-spacing-sm);border-radius:var(--calcite-spacing-xl);background:var(--calcite-color-brand);color:var(--calcite-color-foreground-1)}.assistant-chat-card__footer{display:flex;width:100%;justify-content:space-between;padding:0 var(--calcite-spacing-xxs)}.assistant-chat-card__feedback-actions{display:flex;flex-direction:row;gap:var(--calcite-spacing-xxs)}.assistant-chat-card__log-container{padding:0 var(--calcite-spacing-sm);border-radius:var(--calcite-border-radius);margin-bottom:var(--calcite-spacing-sm)}.assistant-chat-card__log{margin:0;font-size:var(--calcite-font-size-sm);padding:var(--calcite-spacing-sm);background-color:var(--calcite-color-foreground-1);width:100%;overflow:auto}.assistant-chat-card__footer-start{display:flex;gap:var(--calcite-spacing-xxs)}@media(min-width:1280px){.assistant-chat-card__prompt-container,.assistant-chat-card__response-container{max-width:80%}}`,a=class extends s{constructor(){super(...arguments),this._messages=c({blocking:!0}),this._showLog=!1,this.loading=!1,this.type="prompt",this.feedbackDisabled=!1,this.timestampDisabled=!1}static{this.properties={_showLog:16,loading:5,type:1,feedbackDisabled:5,timestampDisabled:5,content:1,loadingMessage:1,log:1,error:1,user:1}}static{this.styles=r}_renderLog(){return this.log&&this._showLog?t`<div class="assistant-chat-card__log-container"><pre class="assistant-chat-card__log">${this.log}</pre></div>`:null}_renderThumbsUpButton(){return t`<calcite-action id=action-thumbs-up icon=thumbs-up scale=s appearance=transparent @click=${()=>{}} text></calcite-action><calcite-tooltip reference-element=action-thumbs-up overlay-positioning=fixed placement=bottom><span>${this._messages.thumbsUpLabel}</span></calcite-tooltip>`}_renderThumbsDownButton(){return t`<calcite-action id=action-thumbs-down icon=thumbs-down scale=s appearance=transparent @click=${()=>{}} text></calcite-action><calcite-tooltip reference-element=action-thumbs-down overlay-positioning=fixed placement=bottom><span>${this._messages.thumbsDownLabel}</span></calcite-tooltip>`}_renderFeedback(){return!this.feedbackDisabled&&!this.error?t`<div class="assistant-chat-card__feedback-actions">${this._renderThumbsUpButton()}${this._renderThumbsDownButton()}</div>`:null}_renderCopyButton(){return this.error?null:t`<calcite-action id=action-copy icon=copy-to-clipboard scale=s appearance=transparent @click=${async()=>{try{this.content&&await navigator.clipboard.writeText(this.content)}catch(n){console.error("Failed to copy text to clipboard:",n)}}} text></calcite-action><calcite-tooltip reference-element=action-copy overlay-positioning=fixed placement=bottom><span>${this._messages.copyButtonLabel}</span></calcite-tooltip>`}_renderLogButton(){return this.log?t`<calcite-action id=action-log icon=access-string-results scale=s appearance=transparent @click=${()=>this._showLog=!this._showLog} .text=${this._messages.logButtonLabel} .active=${this._showLog}></calcite-action><calcite-tooltip reference-element=action-log overlay-positioning=fixed placement=bottom><span>${this._messages.logButtonLabel}</span></calcite-tooltip>`:null}_renderFooter(){return this.loading?null:t`<div class="assistant-chat-card__footer"><slot name=footer-start class="assistant-chat-card__footer-start">${this._renderCopyButton()}${this._renderLogButton()}</slot>${this._renderFeedback()}</div>`}render(){return this.type==="prompt"?t`<div class="assistant-chat-card__prompt-container"><div>${this.content}</div><div class="assistant-chat-card__prompt-avatar"><calcite-avatar .fullName=${this.user} scale=s></calcite-avatar></div></div>`:t`<div class="assistant-chat-card__response-container"><calcite-icon icon=effects class="assistant-chat-card__response-icon"></calcite-icon><div class="assistant-chat-card__content-container"><arcgis-assistant-chat-card-content .loading=${this.loading} .loadingMessage=${this.loadingMessage} .type=${this.error?"error":"text"} .content=${this.error??this.content}></arcgis-assistant-chat-card-content>${this._renderLog()}${this._renderFooter()}</div></div>`}};i("arcgis-assistant-chat-card",a);export{a as ArcgisAssistantChatCard};
|
|
@@ -0,0 +1,4 @@
|
|
|
1
|
+
/*! All material copyright Esri, All Rights Reserved, unless otherwise specified.
|
|
2
|
+
See https://js.arcgis.com/5.0/esri/copyright.txt for details.
|
|
3
|
+
v5.0.0-next.133 */
|
|
4
|
+
import{a as u}from"./2KGO3SIH.js";import"./UIUJKONY.js";import{g as i,h as s,k as a,n as r,o as n,p as c,r as o,t as l}from"./YXLN5DSL.js";import"./46CNQJRX.js";export default $arcgis.t(([{watch:h}])=>{var d=i`.assistant-chat-entry__input-container{display:flex;flex-direction:column}.assistant-chat-entry__footer-start{display:flex;gap:var(--calcite-spacing-md);flex-wrap:wrap;align-items:center}.assistant-chat-entry__footer-end{display:flex;gap:var(--calcite-spacing-md);align-items:center}.assistant-chat-entry__status-indicator{width:9px;height:9px;border-radius:100%;background-color:var(--calcite-color-status-success)}.assistant-chat-entry__status-indicator[data-status=working]{background-color:var(--calcite-color-status-warning)}.assistant-chat-entry__status-indicator[data-status=error]{background-color:var(--calcite-color-status-danger)}.assistant-chat-entry__status-text{text-transform:capitalize}`,e=class extends c{constructor(){super(...arguments),this.#t=r(),this._messages=u({blocking:!0}),this.enterKeySubmits=!0,this.awaitingResponse=!1,this.inputValue="",this.arcgisCancel=a(),this.arcgisSubmit=a()}static{this.properties={enterKeySubmits:5,entryPlaceholder:1,awaitingResponse:5,inputValue:1,status:1}}static{this.styles=d}#t;loaded(){this.manager.onLifecycle(()=>[h(()=>this.inputValue,t=>{this.#t.value&&(this.#t.value.value=t)},{initial:!0})])}async _submitMessage(){if(this.awaitingResponse){this.arcgisCancel.emit();return}let t=this.#t.value?.value.trim();t&&(this.arcgisSubmit.emit(t),this.#t.value&&(this.#t.value.value="",await this.#t.value.setFocus()))}render(){return s`<div class="assistant-chat-entry__input-container"><calcite-text-area .value=${this.#t.value?.value} .placeholder=${this.entryPlaceholder??this._messages.entryPlaceholder} @keydown=${async t=>{t.key==="Enter"&&!t.shiftKey&&this.enterKeySubmits&&(t.preventDefault(),await this._submitMessage())}} ${n(this.#t)}><div slot=footer-start class="assistant-chat-entry__footer-start"><slot name=entry-actions-start></slot></div><div slot=footer-end class="assistant-chat-entry__footer-end">${this.status?s`<div id=tooltip-status class="assistant-chat-entry__status-indicator" data-status=${this.status??o}></div><calcite-tooltip reference-element=tooltip-status offset-distance=12><span class="assistant-chat-entry__status-text">${this.status}</span></calcite-tooltip>`:null}<calcite-button .iconStart=${this.awaitingResponse?"circle-stop":"send"} slot=footer-end round @click=${()=>void this._submitMessage()}>${this.awaitingResponse?this._messages.stopButtonLabel:this._messages.askButtonLabel}</calcite-button></div></calcite-text-area></div>`}};l("arcgis-assistant-chat-entry",e);return e},"core/reactiveUtils")
|
|
@@ -0,0 +1,27 @@
|
|
|
1
|
+
/*! All material copyright Esri, All Rights Reserved, unless otherwise specified.
|
|
2
|
+
See https://js.arcgis.com/5.0/esri/copyright.txt for details.
|
|
3
|
+
v5.0.0-next.133 */
|
|
4
|
+
import"./46CNQJRX.js";var e=`# Navigation Tool Instructions
|
|
5
|
+
|
|
6
|
+
CRITICAL: You are FORBIDDEN from making multiple tool calls. You MUST make exactly ONE tool call.
|
|
7
|
+
|
|
8
|
+
Use the most recent relevant user question from the chat history. The question will **not** be restated again here.
|
|
9
|
+
|
|
10
|
+
Detected intent:
|
|
11
|
+
{intent}
|
|
12
|
+
|
|
13
|
+
{bookmarksSection}
|
|
14
|
+
|
|
15
|
+
{layersSection}
|
|
16
|
+
|
|
17
|
+
{fieldsSection}
|
|
18
|
+
|
|
19
|
+
Current zoom level: {currentZoom}
|
|
20
|
+
|
|
21
|
+
Rules:
|
|
22
|
+
|
|
23
|
+
- Call exactly one navigation tool
|
|
24
|
+
- Use ONLY provided layerIds and fields if present
|
|
25
|
+
- Do NOT invent layerIds or field names
|
|
26
|
+
- If required context is missing, fall back to a valid non-layer tool
|
|
27
|
+
`;export{e as default};
|
|
@@ -0,0 +1,4 @@
|
|
|
1
|
+
/*! All material copyright Esri, All Rights Reserved, unless otherwise specified.
|
|
2
|
+
See https://js.arcgis.com/5.0/esri/copyright.txt for details.
|
|
3
|
+
v5.0.0-next.133 */
|
|
4
|
+
import d from"./A7BGJLHS.js";import{a as i,b as e}from"./FORRN75L.js";import c from"./WOP5ENGJ.js";import"./PEFKT7JJ.js";import"./UIUJKONY.js";import{p as a,t as s}from"./YXLN5DSL.js";import b from"./ZQEX3TGK.js";import"./LILVLE37.js";import"./46CNQJRX.js";export default $arcgis.t(([,,{a:r}])=>{var t=class extends a{constructor(){super(...arguments),this.agent=r}static{this.properties={referenceElement:1}}#t;getContext(){if(!this.#t)throw new Error("arcgis-assistant-navigation-agent requires a mapView");return{mapView:this.#t}}async load(){this.#t=await i(this,"arcgis-assistant-navigation-agent"),e(this)}};s("arcgis-assistant-navigation-agent",t);return t},b,c,d)
|