@arcgis/ai-components 5.2.0-next.5 → 5.2.0-next.6

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.
Files changed (39) hide show
  1. package/dist/cdn/{3WINIQWY.js → 3NI46YCE.js} +1 -1
  2. package/dist/cdn/{GBNUMN4J.js → 47FWPQ2A.js} +1 -1
  3. package/dist/cdn/{GJUXVEOF.js → AEJHYRGT.js} +1 -1
  4. package/dist/cdn/{ERBQSEPQ.js → BFZJNJL6.js} +1 -1
  5. package/dist/cdn/{M6F4MXDK.js → GCQLVNNC.js} +1 -1
  6. package/dist/cdn/{DO2P3PWF.js → JV4SI65E.js} +26 -24
  7. package/dist/cdn/{J5CMRCPS.js → R6HV42YW.js} +1 -1
  8. package/dist/cdn/{3BKUCFKS.js → V7OJRG26.js} +1 -1
  9. package/dist/cdn/{CXWBEDXN.js → VOQX4AVB.js} +1 -1
  10. package/dist/cdn/index.js +1 -1
  11. package/dist/cdn/main.css +1 -1
  12. package/dist/chunks/generateLayerDescriptions.js +153 -145
  13. package/dist/components/arcgis-assistant-chat/customElement.d.ts +6 -1
  14. package/dist/components/arcgis-assistant-chat-entry/customElement.d.ts +2 -1
  15. package/dist/components/arcgis-assistant-interrupt/customElement.d.ts +4 -1
  16. package/dist/components/arcgis-assistant-message/customElement.d.ts +21 -0
  17. package/dist/components/arcgis-assistant-message/index.d.ts +1 -0
  18. package/dist/components/arcgis-assistant-message-block/customElement.d.ts +1 -1
  19. package/dist/components/arcgis-assistant-message-feedback/customElement.d.ts +4 -1
  20. package/dist/components/arcgis-assistant-message-footer/customElement.d.ts +4 -1
  21. package/dist/components/arcgis-assistant-message-loading/customElement.d.ts +4 -1
  22. package/dist/components/arcgis-assistant-message-log/customElement.d.ts +4 -1
  23. package/dist/components/arcgis-assistant-message-read-aloud/customElement.d.ts +4 -1
  24. package/dist/components/arcgis-assistant-message-text/customElement.d.ts +4 -1
  25. package/dist/components/arcgis-assistant-speech-input/customElement.d.ts +6 -1
  26. package/dist/components/arcgis-assistant-suggested-prompts/customElement.d.ts +4 -1
  27. package/dist/components/arcgis-assistant-user-message/customElement.d.ts +4 -1
  28. package/dist/docs/api.json +1 -1
  29. package/dist/docs/docs.json +1 -1
  30. package/dist/docs/vscode.html-custom-data.json +1 -1
  31. package/dist/docs/web-types.json +1 -1
  32. package/dist/index.d.ts +4 -0
  33. package/dist/types/lumina.d.ts +5 -0
  34. package/dist/types/preact.d.ts +6 -0
  35. package/dist/types/react.d.ts +7 -0
  36. package/dist/types/stencil.d.ts +5 -0
  37. package/dist/utils/index.d.ts +2 -11
  38. package/dist/utils/index.js +64 -78
  39. package/package.json +5 -5
@@ -1,2 +1,2 @@
1
1
  /* COPYRIGHT Esri - https://js.arcgis.com/5.2/LICENSE.txt */
2
- import a from"./DO2P3PWF.js";export default $arcgis.t(([,,,,,{f:t}])=>{var y=async(o,r)=>{let i=o.tool_calls??[];if(i.length===0){await t({text:`LLM did not request any tool calls: ${String(o?.content)}`},r);return}await Promise.all(i.map(async a=>await t({text:`LLM invoked ${a.name} tool with arguments: ${JSON.stringify(a.args,null,2)}`},r)))};return y},"identity/IdentityManager","portal/Portal","core/reactiveUtils","layers/FeatureLayer","request",a)
2
+ import a from"./JV4SI65E.js";export default $arcgis.t(([,,,,,{f:t}])=>{var y=async(o,r)=>{let i=o.tool_calls??[];if(i.length===0){await t({text:`LLM did not request any tool calls: ${String(o?.content)}`},r);return}await Promise.all(i.map(async a=>await t({text:`LLM invoked ${a.name} tool with arguments: ${JSON.stringify(a.args,null,2)}`},r)))};return y},"identity/IdentityManager","portal/Portal","core/reactiveUtils","layers/FeatureLayer","request",a)
@@ -1,5 +1,5 @@
1
1
  /* COPYRIGHT Esri - https://js.arcgis.com/5.2/LICENSE.txt */
2
- import d from"./3WINIQWY.js";import c from"./GJUXVEOF.js";import a from"./DO2P3PWF.js";import{Fb as k,Q as V,a as N,b as E}from"./462JBSEV.js";import{a as D,c as O}from"./HB5A5R2E.js";import"./AMP6IALT.js";import"./OAVEHGB6.js";import{v as b,y as A}from"./OH64RMOR.js";import"./YIMNOUTF.js";export default $arcgis.t(([,,,,,,,,,,K,X,,,{f:n,l:z,n:T},{C:R,D:G,E:L,F:P,G:F,H:U,a:j,m:S,n:M,o:p,p:Q},C])=>{var Y=async(e,t)=>(await n({text:"Exiting Data Exploration agent"},t),e),Z=async(e,t)=>{await n({text:"Requesting LLM for layer filter results"},t);let a=await S("data_explore_filter_prompt");if(!t?.configurable)throw new Error("config.configurable is required for layer filter tools");let{userTimezone:c,userTimezoneOffset:l}=L(),s={layerFieldInfo:e.layerFieldInfo,userTimezone:c,userTimezoneOffset:l,queryResponse:e.queryResponse,assignedTask:e.agentExecutionContext.assignedTask,userRequest:e.agentExecutionContext.userRequest,priorSteps:e.agentExecutionContext.priorSteps},r=await T({promptText:a,modelTier:"advanced",messages:e.dataExplorationMessages,inputVariables:s,tools:F}),i=[...e.dataExplorationMessages,r];if(!((r.tool_calls?.length??0)>0))return await n({text:"LLM determined no filter changes needed"},t),{...e,dataExplorationMessages:i};let u=[...i,r],o=r.content.toString();return await C(r,t),{...e,dataExplorationMessages:u,outputMessage:o}},ee=async(e,t)=>{await n({text:"Requesting LLM for layer query results"},t);let a=await S("data_explore_query_prompt");if(!t?.configurable)throw new Error("config.configurable is required for layer query tools");let{userTimezone:c,userTimezoneOffset:l}=L(),s=e.agentExecutionContext.sharedState.lastNavigatedFeatures,r=s&&typeof s=="object"&&"value"in s?s.value:s,i="none";if(r!=null)try{i=JSON.stringify(r)}catch{i="none"}let u={layerFieldInfo:e.layerFieldInfo,userTimezone:c,userTimezoneOffset:l,assignedTask:e.agentExecutionContext.assignedTask,userRequest:e.agentExecutionContext.userRequest,priorSteps:e.agentExecutionContext.priorSteps,lastNavigatedFeatures:i},o=await T({promptText:a,modelTier:"advanced",messages:e.dataExplorationMessages,inputVariables:u,tools:P}),m=o.content.toString();return await C(o,t),{...e,dataExplorationMessages:[...e.dataExplorationMessages,o],outputMessage:m,status:"success",summary:m?M(m):"Query executed."}},te=async(e,t)=>{try{await n({text:"Requesting LLM for summary on query results"},t);let a=await S("summarize_query_response_prompt"),c={queryResponse:e.queryResponse,assignedTask:e.agentExecutionContext.assignedTask,userRequest:e.agentExecutionContext.userRequest,priorSteps:e.agentExecutionContext.priorSteps},l=await z({promptText:a,modelTier:"fast",messages:e.dataExplorationMessages,inputVariables:c}),s=typeof l=="string"?l:l.content,r=new V(s);await n({text:`Received response from LLM: ${s}`},t);let i=s;return{...e,outputMessage:i,status:"success",summary:i?M(i):"Summary generated.",dataExplorationMessages:[...e.dataExplorationMessages,r]}}catch(a){throw await n({text:"Error during filter LLM request"},t),new Error(`Error during filter LLM request: ${a instanceof Error?a.message:String(a)}`)}};async function ae(e,t){let a=await new j(F).invoke({messages:e.dataExplorationMessages},t);return await n({text:`Finished executing layer filter tool: ${a.messages.map(c=>c.content).join(", ")}`},t),{...e}}var se=10,re=["string","small-integer","integer"],ie=async(e,t,{includeSummaryStatistics:a=!0,includeUniqueValues:c=!0}={})=>{let l=null,s=null;try{if(t.type!=="geometry"&&t.type!=="oid"&&t.type!=="global-id"){a&&(l=await K({layer:e,field:t.name}));let r=t.domain?.type==="coded-value"?t.domain:null;c&&(re.includes(t.type)||r)&&(s=(await X({layer:e,field:t.name})).uniqueValueInfos.sort((i,u)=>u.count-i.count).slice(0,se),r&&(s=s.map(i=>({...i,value:r.getName(i.value)??i.value}))))}}catch(r){console.error(`Error fetching statistics for field ${t.name}:`,r)}return{summaryStatistics:l,uniqueValues:s}};function oe(e,t){return["string","small-integer","integer"].includes(e)||t==="coded-value"}async function ne(e,t,a,c=!0){let l=[],s=[],r=[];for(let i of e){let u=function(g){let d=t.get(g)?.layerItem;return d?[d.name&&`Name: ${d.name}`,d.title&&`Title: ${d.title}`,d.description&&`Description: ${d.description}`].filter(Boolean).join(" | "):g},{layerId:o,results:m}=i,f=a.map?.allLayers.find(g=>g.id===o),w=t.get(o)?.fieldRegistry;if(!w)continue;let h=l.find(g=>g.layerId===o);h||(h={layerId:o,layerSummary:u(o),fieldInfos:[]},l.push(h));for(let g of m){let d=w.get(g.name);if(!d)continue;let y=d.statistics,v=c&&!y?.summaryStatistics,q=oe(d.type,d.domain?.type)&&!y?.uniqueValues,_=v||q;if(r.push({layerId:o,fieldName:d.name,didFetchStatistics:_}),_){let J=ie(f,d,{includeSummaryStatistics:v,includeUniqueValues:q}).then($=>{let x={summaryStatistics:y?.summaryStatistics??null,uniqueValues:y?.uniqueValues??null};v&&(x.summaryStatistics=$.summaryStatistics),q&&(x.uniqueValues=$.uniqueValues),w.set(d.name,{...d,statistics:x}),d.statistics=x});s.push(J)}h.fieldInfos.push(d)}}return await Promise.all(s),{layerFieldInfo:l,didFetchStatistics:s.length>0,fieldStatisticsFetchStatus:r}}var W=/\b(average|avg|mean|median|max(?:imum)?|min(?:imum)?|sum|total|count|std(?:dev|\s*deviation)|variance|null\s*count|missing\s*values?|range)\b/iu;function le(e,t){return W.test(e)||W.test(t)}var de=async(e,t)=>{try{await n({text:"Preparing field information for vector search results"},t);let a=p(t,"layersAndFieldsRegistry"),{mapView:c}=G(t),{assignedTask:l,userRequest:s}=e.agentExecutionContext,r=le(l,s),{layerFieldInfo:i,didFetchStatistics:u,fieldStatisticsFetchStatus:o}=await ne(e.vectorSearchFieldResults,a,c,r);u?await n({text:"Statistics fetched"},t):await n({text:"Statistics skipped"},t);for(let m of o)await n({text:` - ${m.fieldName} - stats ${m.didFetchStatistics?"fetched":"skipped"}`},t);return await n({text:"Field information prepared"},t),{...e,layerFieldInfo:i}}catch(a){throw await n({text:"Error during fetching statistics"},t),new Error(`Error during fetching statistics: ${a instanceof Error?a.message:String(a)}`)}},B=.7,ce=10,ue=async(e,t)=>{try{await n({text:"Similarity search to find fields"},t);let a=p(t,"fieldSearch"),c=p(t,"layersAndFieldsRegistry"),l=p(t,"embeddingCache"),s=await a.searchFields({text:e.agentExecutionContext.assignedTask,layerIds:e.vectorSearchLayerIds,minScore:B,topResults:ce,embeddingCache:l}),r=s.map(({layerId:u,results:o})=>{let m=o.map(f=>` - ${f.name} (${f.score.toFixed(2)})`).join(`
2
+ import d from"./3NI46YCE.js";import c from"./AEJHYRGT.js";import a from"./JV4SI65E.js";import{Fb as k,Q as V,a as N,b as E}from"./462JBSEV.js";import{a as D,c as O}from"./HB5A5R2E.js";import"./AMP6IALT.js";import"./OAVEHGB6.js";import{v as b,y as A}from"./OH64RMOR.js";import"./YIMNOUTF.js";export default $arcgis.t(([,,,,,,,,,,K,X,,,{f:n,l:z,n:T},{C:R,D:G,E:L,F:P,G:F,H:U,a:j,m:S,n:M,o:p,p:Q},C])=>{var Y=async(e,t)=>(await n({text:"Exiting Data Exploration agent"},t),e),Z=async(e,t)=>{await n({text:"Requesting LLM for layer filter results"},t);let a=await S("data_explore_filter_prompt");if(!t?.configurable)throw new Error("config.configurable is required for layer filter tools");let{userTimezone:c,userTimezoneOffset:l}=L(),s={layerFieldInfo:e.layerFieldInfo,userTimezone:c,userTimezoneOffset:l,queryResponse:e.queryResponse,assignedTask:e.agentExecutionContext.assignedTask,userRequest:e.agentExecutionContext.userRequest,priorSteps:e.agentExecutionContext.priorSteps},r=await T({promptText:a,modelTier:"advanced",messages:e.dataExplorationMessages,inputVariables:s,tools:F}),i=[...e.dataExplorationMessages,r];if(!((r.tool_calls?.length??0)>0))return await n({text:"LLM determined no filter changes needed"},t),{...e,dataExplorationMessages:i};let u=[...i,r],o=r.content.toString();return await C(r,t),{...e,dataExplorationMessages:u,outputMessage:o}},ee=async(e,t)=>{await n({text:"Requesting LLM for layer query results"},t);let a=await S("data_explore_query_prompt");if(!t?.configurable)throw new Error("config.configurable is required for layer query tools");let{userTimezone:c,userTimezoneOffset:l}=L(),s=e.agentExecutionContext.sharedState.lastNavigatedFeatures,r=s&&typeof s=="object"&&"value"in s?s.value:s,i="none";if(r!=null)try{i=JSON.stringify(r)}catch{i="none"}let u={layerFieldInfo:e.layerFieldInfo,userTimezone:c,userTimezoneOffset:l,assignedTask:e.agentExecutionContext.assignedTask,userRequest:e.agentExecutionContext.userRequest,priorSteps:e.agentExecutionContext.priorSteps,lastNavigatedFeatures:i},o=await T({promptText:a,modelTier:"advanced",messages:e.dataExplorationMessages,inputVariables:u,tools:P}),m=o.content.toString();return await C(o,t),{...e,dataExplorationMessages:[...e.dataExplorationMessages,o],outputMessage:m,status:"success",summary:m?M(m):"Query executed."}},te=async(e,t)=>{try{await n({text:"Requesting LLM for summary on query results"},t);let a=await S("summarize_query_response_prompt"),c={queryResponse:e.queryResponse,assignedTask:e.agentExecutionContext.assignedTask,userRequest:e.agentExecutionContext.userRequest,priorSteps:e.agentExecutionContext.priorSteps},l=await z({promptText:a,modelTier:"fast",messages:e.dataExplorationMessages,inputVariables:c}),s=typeof l=="string"?l:l.content,r=new V(s);await n({text:`Received response from LLM: ${s}`},t);let i=s;return{...e,outputMessage:i,status:"success",summary:i?M(i):"Summary generated.",dataExplorationMessages:[...e.dataExplorationMessages,r]}}catch(a){throw await n({text:"Error during filter LLM request"},t),new Error(`Error during filter LLM request: ${a instanceof Error?a.message:String(a)}`)}};async function ae(e,t){let a=await new j(F).invoke({messages:e.dataExplorationMessages},t);return await n({text:`Finished executing layer filter tool: ${a.messages.map(c=>c.content).join(", ")}`},t),{...e}}var se=10,re=["string","small-integer","integer"],ie=async(e,t,{includeSummaryStatistics:a=!0,includeUniqueValues:c=!0}={})=>{let l=null,s=null;try{if(t.type!=="geometry"&&t.type!=="oid"&&t.type!=="global-id"){a&&(l=await K({layer:e,field:t.name}));let r=t.domain?.type==="coded-value"?t.domain:null;c&&(re.includes(t.type)||r)&&(s=(await X({layer:e,field:t.name})).uniqueValueInfos.sort((i,u)=>u.count-i.count).slice(0,se),r&&(s=s.map(i=>({...i,value:r.getName(i.value)??i.value}))))}}catch(r){console.error(`Error fetching statistics for field ${t.name}:`,r)}return{summaryStatistics:l,uniqueValues:s}};function oe(e,t){return["string","small-integer","integer"].includes(e)||t==="coded-value"}async function ne(e,t,a,c=!0){let l=[],s=[],r=[];for(let i of e){let u=function(g){let d=t.get(g)?.layerItem;return d?[d.name&&`Name: ${d.name}`,d.title&&`Title: ${d.title}`,d.description&&`Description: ${d.description}`].filter(Boolean).join(" | "):g},{layerId:o,results:m}=i,f=a.map?.allLayers.find(g=>g.id===o),w=t.get(o)?.fieldRegistry;if(!w)continue;let h=l.find(g=>g.layerId===o);h||(h={layerId:o,layerSummary:u(o),fieldInfos:[]},l.push(h));for(let g of m){let d=w.get(g.name);if(!d)continue;let y=d.statistics,v=c&&!y?.summaryStatistics,q=oe(d.type,d.domain?.type)&&!y?.uniqueValues,_=v||q;if(r.push({layerId:o,fieldName:d.name,didFetchStatistics:_}),_){let J=ie(f,d,{includeSummaryStatistics:v,includeUniqueValues:q}).then($=>{let x={summaryStatistics:y?.summaryStatistics??null,uniqueValues:y?.uniqueValues??null};v&&(x.summaryStatistics=$.summaryStatistics),q&&(x.uniqueValues=$.uniqueValues),w.set(d.name,{...d,statistics:x}),d.statistics=x});s.push(J)}h.fieldInfos.push(d)}}return await Promise.all(s),{layerFieldInfo:l,didFetchStatistics:s.length>0,fieldStatisticsFetchStatus:r}}var W=/\b(average|avg|mean|median|max(?:imum)?|min(?:imum)?|sum|total|count|std(?:dev|\s*deviation)|variance|null\s*count|missing\s*values?|range)\b/iu;function le(e,t){return W.test(e)||W.test(t)}var de=async(e,t)=>{try{await n({text:"Preparing field information for vector search results"},t);let a=p(t,"layersAndFieldsRegistry"),{mapView:c}=G(t),{assignedTask:l,userRequest:s}=e.agentExecutionContext,r=le(l,s),{layerFieldInfo:i,didFetchStatistics:u,fieldStatisticsFetchStatus:o}=await ne(e.vectorSearchFieldResults,a,c,r);u?await n({text:"Statistics fetched"},t):await n({text:"Statistics skipped"},t);for(let m of o)await n({text:` - ${m.fieldName} - stats ${m.didFetchStatistics?"fetched":"skipped"}`},t);return await n({text:"Field information prepared"},t),{...e,layerFieldInfo:i}}catch(a){throw await n({text:"Error during fetching statistics"},t),new Error(`Error during fetching statistics: ${a instanceof Error?a.message:String(a)}`)}},B=.7,ce=10,ue=async(e,t)=>{try{await n({text:"Similarity search to find fields"},t);let a=p(t,"fieldSearch"),c=p(t,"layersAndFieldsRegistry"),l=p(t,"embeddingCache"),s=await a.searchFields({text:e.agentExecutionContext.assignedTask,layerIds:e.vectorSearchLayerIds,minScore:B,topResults:ce,embeddingCache:l}),r=s.map(({layerId:u,results:o})=>{let m=o.map(f=>` - ${f.name} (${f.score.toFixed(2)})`).join(`
3
3
  `);return`${c.get(u)?.layerItem.name??u}:
4
4
  ${m}`}).join(`
5
5
  `),i;return s.length>0?i=`Vector search completed. Matching layers and fields with scores:
@@ -1,5 +1,5 @@
1
1
  /* COPYRIGHT Esri - https://js.arcgis.com/5.2/LICENSE.txt */
2
- import a from"./DO2P3PWF.js";import{Bb as j,L as q,M as ee,R as z,Za as I,_a as h,g as ge,j as V,k as Q,kb as g,qb as be,u as we}from"./462JBSEV.js";export default $arcgis.t(([$e,M,Ce,,Ne,oe,tt,{addressToLocations:rt},ot,at,Re,{createRenderer:nt},{getSchemesByTag:it,getSchemes:st},{getBackgroundColorTheme:ke},{createAgeRenderer:lt,createContinuousRenderer:ct},{getSchemesByTag:pe},{createContinuousRenderer:ut},{createRenderer:dt},{getSchemesByTag:pt},{createRenderer:mt},{getSchemesByTag:ht},{createRenderer:ft},{getSchemesByTag:yt},{createRenderer:gt},{getSchemesByTag:wt},{createAgeRenderer:bt,createContinuousRenderer:vt},{createRenderer:Tt},{getSchemesByTag:St},xt,_e,qe,{formatDateOnly:Et,convertDateFormatToIntlOptions:U,formatTimeOnly:It,formatDate:Fe},$t,Nt,kt,Ft,Mt,ze,,{fetchKnowledgeGraph:Me,executeQueryStreaming:At,executeSearchStreaming:Ct},Rt,{a:i,c:L,d:ve,f:T,g:S,m:Te}])=>{var Ie=e=>Array.isArray(e)&&e.every(q),Ze=e=>typeof e=="object"&&e!=null&&"messages"in e&&Ie(e.messages),Ye=e=>typeof e=="object"&&e!=null&&"lg_tool_call"in e,B=class extends be{tools;handleToolErrors=!0;trace=!1;constructor(e,t){let{name:r,tags:o,handleToolErrors:a}=t??{};super({name:r,tags:o,func:(n,s)=>this.run(n,s)}),this.tools=e,this.handleToolErrors=a??this.handleToolErrors}async runTool(e,t){let r=this.tools.find(o=>o.name===e.name);try{if(r===void 0)throw new Error(`Tool "${e.name}" not found.`);let o=await r.invoke({...e,type:"tool_call"},t);return q(o)&&o.getType()==="tool"||Q(o)?o:new ee({status:"success",name:r.name,content:typeof o=="string"?o:JSON.stringify(o),tool_call_id:e.id})}catch(o){if(!this.handleToolErrors||we(o))throw o;return new ee({status:"error",content:`Error: ${o.message}
2
+ import a from"./JV4SI65E.js";import{Bb as j,L as q,M as ee,R as z,Za as I,_a as h,g as ge,j as V,k as Q,kb as g,qb as be,u as we}from"./462JBSEV.js";export default $arcgis.t(([$e,M,Ce,,Ne,oe,tt,{addressToLocations:rt},ot,at,Re,{createRenderer:nt},{getSchemesByTag:it,getSchemes:st},{getBackgroundColorTheme:ke},{createAgeRenderer:lt,createContinuousRenderer:ct},{getSchemesByTag:pe},{createContinuousRenderer:ut},{createRenderer:dt},{getSchemesByTag:pt},{createRenderer:mt},{getSchemesByTag:ht},{createRenderer:ft},{getSchemesByTag:yt},{createRenderer:gt},{getSchemesByTag:wt},{createAgeRenderer:bt,createContinuousRenderer:vt},{createRenderer:Tt},{getSchemesByTag:St},xt,_e,qe,{formatDateOnly:Et,convertDateFormatToIntlOptions:U,formatTimeOnly:It,formatDate:Fe},$t,Nt,kt,Ft,Mt,ze,,{fetchKnowledgeGraph:Me,executeQueryStreaming:At,executeSearchStreaming:Ct},Rt,{a:i,c:L,d:ve,f:T,g:S,m:Te}])=>{var Ie=e=>Array.isArray(e)&&e.every(q),Ze=e=>typeof e=="object"&&e!=null&&"messages"in e&&Ie(e.messages),Ye=e=>typeof e=="object"&&e!=null&&"lg_tool_call"in e,B=class extends be{tools;handleToolErrors=!0;trace=!1;constructor(e,t){let{name:r,tags:o,handleToolErrors:a}=t??{};super({name:r,tags:o,func:(n,s)=>this.run(n,s)}),this.tools=e,this.handleToolErrors=a??this.handleToolErrors}async runTool(e,t){let r=this.tools.find(o=>o.name===e.name);try{if(r===void 0)throw new Error(`Tool "${e.name}" not found.`);let o=await r.invoke({...e,type:"tool_call"},t);return q(o)&&o.getType()==="tool"||Q(o)?o:new ee({status:"success",name:r.name,content:typeof o=="string"?o:JSON.stringify(o),tool_call_id:e.id})}catch(o){if(!this.handleToolErrors||we(o))throw o;return new ee({status:"error",content:`Error: ${o.message}
3
3
  Please fix your mistakes.`,name:e.name,tool_call_id:e.id??""})}}async run(e,t){let r;if(Ye(e))r=[await this.runTool(e.lg_tool_call,t)];else{let n;if(Ie(e))n=e;else if(Ze(e))n=e.messages;else throw new Error("ToolNode only accepts BaseMessage[] or { messages: BaseMessage[] } as input.");let s=new Set(n.filter(u=>u.getType()==="tool").map(u=>u.tool_call_id)),l;for(let u=n.length-1;u>=0;u-=1){let c=n[u];if(z(c)){l=c;break}}if(l==null||!z(l))throw new Error("ToolNode only accepts AIMessages as input.");r=await Promise.all(l.tool_calls?.filter(u=>u.id==null||!s.has(u.id)).map(u=>this.runTool(u,t))??[])}if(!r.some(Q))return Array.isArray(e)?r:{messages:r};let o=[],a=null;for(let n of r)Q(n)?n.graph===V.PARENT&&Array.isArray(n.goto)&&n.goto.every(s=>ge(s))?a?a.goto.push(...n.goto):a=new V({graph:V.PARENT,goto:n.goto}):o.push(n):o.push(Array.isArray(e)?[n]:{messages:[n]});return a&&o.push(a),o}};var Fn=g.Root({llmInputMessages:g({reducer:(e,t)=>j([],t),default:()=>[]})});var O=(e,t)=>t??e,ji=g.Root({...ve(),intent:g({reducer:O}),vectorSearchLayerResults:g({reducer:O,default:()=>[]}),vectorSearchFieldResults:g({reducer:O}),navigationInternalState:g({reducer:O,default:()=>({toolCallMessage:void 0})})});async function _t(e,t){let r=M.getDefault().helperServices,o=r.geocode.find(d=>d.name==="ArcGIS World Geocoding Service")??r.geocode[0];if(!o)throw new Error("No geocoding service found in helperServices.");let a=o.url,n=`${oe.assetsPath?.endsWith("/")?oe.assetsPath:`${oe.assetsPath}/`}esri/images/search/search-symbol-32.png`,s=(await rt(a,{address:{SingleLine:e},outFields:["Match_addr"]}))?.[0];if(!s?.extent||!s.location)throw new Error(`Could not find location for: ${e}`);let l=new ot({url:n,width:24,height:24}),u=new tt({geometry:s.location,symbol:l});t.graphics.removeAll(),t.graphics.add(u),await t.goTo(s.extent);let c={address:s.address??"",location:s.location?s.location.toJSON():null,extent:s.extent?s.extent.toJSON():null};return{text:`Successfully zoomed to ${e}.`,sharedStatePatch:{lastResolvedLocation:{value:c}}}}var qt=["mapView"];function $(e){let t=e?.configurable?.context;if(!t||typeof t!="object")throw new Error("NavigationAgent context missing");let r=qt.filter(o=>!(o in t));if(r.length)throw new Error(`NavigationAgent context missing: ${r.join(", ")}`);return t}async function zt({address:e},t){let{mapView:r}=$(t);return await _t(e,r)}var jt=i.object({address:i.string().describe("The full address or place name to locate.")}),Li=h(zt,{name:"goToAddress",description:"Geocodes an address using Esri's World Geocoding Service and zooms the map to that location.",schema:jt});async function Lt(e,t){let r=t.map.bookmarks;if(!r||r.length===0)throw new Error("No bookmarks found in the map.");let o=r.find(n=>n.name===e);if(!o)throw new Error(`Bookmark with name "${e}" not found.`);let a=o.viewpoint;if(!a)throw new Error(`Bookmark with name "${e}" does not have a valid viewpoint.`);return await t.goTo(a),{text:`Navigated to bookmark: ${e}`}}async function Ot({bookmarkName:e},t){let{mapView:r}=$(t);return await Promise.resolve(Lt(e,r))}var Dt=I.object({bookmarkName:I.string().describe("The name of the bookmark to navigate to.")}),Oi=h(Ot,{name:"goToBookmark",description:"Go to the extent of the bookmark with the given name.",schema:Dt});async function Pt(e,t,r){let o=r.map?.allLayers.find(s=>s.id===e);if(!o)return{text:`Error: Layer with id ${e} not found`};let a=t?.trim()?t:"1=1",n=o.createQuery();n.where=a;try{let{extent:s,count:l}=await o.queryExtent(n);if(l===0)return{text:`No features found in ${o.title} matching: ${a}`,where:a};if(s)await r.goTo(s);else return{text:`Error: Unable to determine extent for ${o.title}`,where:a};let u={layerId:e,layerTitle:o.title??e,where:a,count:l};return{text:`Successfully zoomed to ${l} feature(s) in ${o.title} matching: ${a}`,where:a,sharedStatePatch:{lastNavigatedFeatures:{value:u}}}}catch(s){return console.error("Error in goToFeatures:",s),{text:`Error: ${s instanceof Error?s.message:"Unknown error"}`,where:a}}}async function Gt({layerId:e,where:t},r){let{mapView:o}=$(r);return await Pt(e,t,o)}var Vt=I.object({layerId:I.string().describe("The layerId of the layer to zoom to."),where:I.string().describe("The sql-92 where clause used to query features to zoom to")}),Di=h(Gt,{name:"goToFeatures",description:"Go to the features that match the given filter related to the given layerId.",schema:Vt});async function Qt(e){let t=new at({xmin:-180,ymin:-90,xmax:180,ymax:90,spatialReference:{wkid:4326}}).expand(.7);return await e.goTo(t),{text:"Successfully zoomed to world extent"}}async function Bt(e,t){let{mapView:r}=$(t);return await Qt(r)}var Ut=I.object({}),Pi=h(Bt,{name:"goToFullExtent",description:"Zooms the map to the full world extent using Esri's Geocoding Service.",schema:Ut});async function Kt(e){let t=e.map.initialViewProperties?.viewpoint?.targetGeometry;if(t)await e.goTo(t);else throw new Error("Initial extent is undefined");return{text:"Successfully zoomed to home extent"}}async function Wt(e,t){let{mapView:r}=$(t);return await Kt(r)}var Ht=i.object({}),Gi=h(Wt,{name:"goToHomeExtent",description:"Go to the initial web map view extent",schema:Ht});async function Jt(e,t){await t.when();let r=t.map?.allLayers.find(a=>a.id===e);if(!r)return console.warn(`[goToLayer] No matching FeatureLayer found for: ${e}`),{text:`Could not find layer for: ${e}`};let o;return(r.type==="link-chart"||r.type==="knowledge-graph-sublayer")&&t.map?.activeLinkChartLayer?o=t.map.diagramNodesExtent:o=r.fullExtent,o?(await t.goTo(o),r.visible=!0,{text:`Successfully zoomed to: ${r.title??""}`}):{text:"Layer has no defined extent. Cannot zoom to layer."}}async function Zt({layerId:e},t){let{mapView:r}=$(t);return await Jt(e,r)}var Yt=I.object({layerId:I.string().describe("The id of the layer to navigate to")}),Vi=h(Zt,{name:"goToLayer",description:"Zooms the map view to the full extent of the top matching layer.",schema:Yt});async function Xt(e,t){return await t.goTo({scale:e}),{text:`Successfully zoomed to: ${e}`}}async function er({scale:e},t){let{mapView:r}=$(t);return await Xt(e,r)}var tr=i.object({scale:i.number().describe("The map scale of the view to go to.")}),Qi=h(er,{name:"goToScale",description:"Go to the specified view scale.",schema:tr});async function rr(e,t,r){let o={target:new Re({longitude:e.longitude,latitude:e.latitude,spatialReference:{wkid:4326}})};return r?.zoom!==void 0&&(o.zoom=r.zoom),r?.scale!==void 0&&(o.scale=r.scale),await t.goTo(o),{text:`Successfully navigated to: ${[`(${e.latitude}\xB0, ${e.longitude}\xB0)`,r?.zoom!==void 0?`zoom ${r.zoom}`:"",r?.scale!==void 0?`scale 1:${r.scale}`:""].filter(Boolean).join(", ")}`}}async function or({center:e,zoom:t,scale:r},o){let{mapView:a}=$(o);return await rr(e,a,{zoom:t,scale:r})}var ar=i.object({center:i.object({longitude:i.number().describe("The longitude (x-coordinate) of the point to navigate to."),latitude:i.number().describe("The latitude (y-coordinate) of the point to navigate to.")}),zoom:i.number().optional().describe("The zoom level. Higher values = more zoomed in."),scale:i.number().optional().describe("The map scale. Alternative to zoom. Smaller numbers = more zoomed in.")}),Bi=h(or,{name:"goToViewpoint",description:"Go to the specified viewpoint. This can contain a combination of scale, center, zoom, etc.",schema:ar});async function nr(e,t){return await t.goTo({zoom:e}),{text:`Successfully zoomed to: ${e}`}}async function ir({zoom:e},t){let{mapView:r}=$(t);return await nr(e,r)}var sr=i.object({zoom:i.number().min(1).max(20).describe("The zoom level of the view to go to.")}),Ui=h(ir,{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:sr}),Ae=Object.assign({"../agents/arcgisKnowledge/prompts/arcgis_knowledge_current_lc_context.md":()=>import("./KMQ3SP4I.js").then(e=>e.default),"../agents/arcgisKnowledge/prompts/arcgis_knowledge_current_map_context.md":()=>import("./5QAHYX7Y.js").then(e=>e.default),"../agents/arcgisKnowledge/prompts/arcgis_knowledge_lucene_generation_prompt.md":()=>import("./5ZZGKP7N.js").then(e=>e.default),"../agents/arcgisKnowledge/prompts/arcgis_knowledge_summarize_result_prompt.md":()=>import("./AXDZBBNL.js").then(e=>e.default),"../agents/arcgisKnowledge/prompts/arcgis_knowledge_tool_prompt.md":()=>import("./ZS2TZ6BF.js").then(e=>e.default),"../agents/dataExploration/prompts/data_explore_filter_prompt.md":()=>import("./LQ6R5YRN.js").then(e=>e.default),"../agents/dataExploration/prompts/data_explore_query_prompt.md":()=>import("./X2ZDYHCG.js").then(e=>e.default),"../agents/dataExploration/prompts/summarize_query_response_prompt.md":()=>import("./ZLXN7NMF.js").then(e=>e.default),"../agents/help/prompts/help_prompt.md":()=>import("./F2AHA4GB.js").then(e=>e.default),"../agents/layerStyling/prompts/layer_styling_prompt.md":()=>import("./FX7UOGHP.js").then(e=>e.default),"../agents/navigation/prompts/navigation_intent_prompt.md":()=>import("./NE7E52YR.js").then(e=>e.default),"../agents/navigation/prompts/navigation_tool_prompt.md":()=>import("./6YMR4QSD.js").then(e=>e.default)});async function ne(e){let t=Object.entries(Ae).find(([r])=>r.endsWith(`/${e}.md`));if(!t)throw new Error(`Prompt not found: ${e}
4
4
  Available prompts:
5
5
  ${Object.keys(Ae).join(`
@@ -1,5 +1,5 @@
1
1
  /* COPYRIGHT Esri - https://js.arcgis.com/5.2/LICENSE.txt */
2
- import b from"./GJUXVEOF.js";import a from"./DO2P3PWF.js";import{Fb as f,a as h,b as l}from"./462JBSEV.js";import{a as y,c as E}from"./HB5A5R2E.js";import"./AMP6IALT.js";import"./OAVEHGB6.js";import{v as u,y as d}from"./OH64RMOR.js";import"./YIMNOUTF.js";export default $arcgis.t(([,,,,,,,,,,,,,,,{f:p,n:x},{I:c,J:H,a:S,m:_,n:w,o:m,p:v}])=>{var C=[H],b=e=>{if(!e||e.size===0)return"No layers available in this map.";let t=Array.from(e.values()).map(({layerItem:o,fieldRegistry:a},s)=>{let r=Array.from(a.values()).map(n=>n.name).slice(0,10).join(", "),i=a.size>10?` (and ${a.size-10} more)`:"";return`${s+1}. "${o.title}". Description: ${o.description}
2
+ import b from"./AEJHYRGT.js";import a from"./JV4SI65E.js";import{Fb as f,a as h,b as l}from"./462JBSEV.js";import{a as y,c as E}from"./HB5A5R2E.js";import"./AMP6IALT.js";import"./OAVEHGB6.js";import{v as u,y as d}from"./OH64RMOR.js";import"./YIMNOUTF.js";export default $arcgis.t(([,,,,,,,,,,,,,,,{f:p,n:x},{I:c,J:H,a:S,m:_,n:w,o:m,p:v}])=>{var C=[H],b=e=>{if(!e||e.size===0)return"No layers available in this map.";let t=Array.from(e.values()).map(({layerItem:o,fieldRegistry:a},s)=>{let r=Array.from(a.values()).map(n=>n.name).slice(0,10).join(", "),i=a.size>10?` (and ${a.size-10} more)`:"";return`${s+1}. "${o.title}". Description: ${o.description}
3
3
  Fields: ${r}${i}`}).join(`
4
4
 
5
5
  `);return`This map contains ${e.size} layer(s):
@@ -1,5 +1,5 @@
1
1
  /* COPYRIGHT Esri - https://js.arcgis.com/5.2/LICENSE.txt */
2
- import c from"./3WINIQWY.js";import b from"./GJUXVEOF.js";import a from"./DO2P3PWF.js";import{Fb as I,a as w,b as h,q as E}from"./462JBSEV.js";import{a as v,c as F}from"./HB5A5R2E.js";import"./AMP6IALT.js";import"./OAVEHGB6.js";import{v as x,y as S}from"./OH64RMOR.js";import"./YIMNOUTF.js";export default $arcgis.t(([,,,,,,,,,,,,,,,{f:n,n:L},{A:z,B:u,a:$,m:C,o:y,p:N,q:A,r:R,s:T,t:b,u:_,v:V,w:q,x:j,y:k,z:M},D])=>{var B=.7,P=10,J=async(t,r)=>{try{await n({text:"Similarity search to find fields"},r);let e=y(r,"fieldSearch"),i=y(r,"layersAndFieldsRegistry"),o=y(r,"embeddingCache"),a=await e.searchFields({text:t.agentExecutionContext.assignedTask,layerIds:t.vectorSearchLayerIds,minScore:B,topResults:P,embeddingCache:o}),m=a.map(({layerId:c,results:d})=>{let g=d.map(s=>` - ${s.name} (${s.score.toFixed(2)})`).join(`
2
+ import c from"./3NI46YCE.js";import b from"./AEJHYRGT.js";import a from"./JV4SI65E.js";import{Fb as I,a as w,b as h,q as E}from"./462JBSEV.js";import{a as v,c as F}from"./HB5A5R2E.js";import"./AMP6IALT.js";import"./OAVEHGB6.js";import{v as x,y as S}from"./OH64RMOR.js";import"./YIMNOUTF.js";export default $arcgis.t(([,,,,,,,,,,,,,,,{f:n,n:L},{A:z,B:u,a:$,m:C,o:y,p:N,q:A,r:R,s:T,t:b,u:_,v:V,w:q,x:j,y:k,z:M},D])=>{var B=.7,P=10,J=async(t,r)=>{try{await n({text:"Similarity search to find fields"},r);let e=y(r,"fieldSearch"),i=y(r,"layersAndFieldsRegistry"),o=y(r,"embeddingCache"),a=await e.searchFields({text:t.agentExecutionContext.assignedTask,layerIds:t.vectorSearchLayerIds,minScore:B,topResults:P,embeddingCache:o}),m=a.map(({layerId:c,results:d})=>{let g=d.map(s=>` - ${s.name} (${s.score.toFixed(2)})`).join(`
3
3
  `);return`${i.get(c)?.layerItem.name??c}:
4
4
  ${g}`}).join(`
5
5
  `),l;return a.length>0?l=`Vector search completed. Matching layers and fields with scores: