@arcgis/ai-components 5.2.0-next.66 → 5.2.0-next.67
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/dist/cdn/{A5TBHRSO.js → CXW5URTF.js} +1 -1
- package/dist/cdn/{YOPJT7YC.js → DTIVDIDY.js} +1 -1
- package/dist/cdn/{NUBBUVUB.js → E5ZKBC24.js} +1 -1
- package/dist/cdn/{HCVN3AF6.js → EKZTQFYI.js} +1 -1
- package/dist/cdn/{DE5XIQ4L.js → GP6NDTUE.js} +1 -1
- package/dist/cdn/{5NH7XQEL.js → HTBMJ557.js} +1 -1
- package/dist/cdn/{ATXIBER5.js → JMIXLFSZ.js} +1 -1
- package/dist/cdn/{GYYYODCA.js → KQHLOYKL.js} +1 -1
- package/dist/cdn/{3CQ4KFEK.js → MBIIANTX.js} +1 -1
- package/dist/cdn/{DJZQS3RI.js → MW5S2XCB.js} +1 -1
- package/dist/cdn/{54XBKEUT.js → PUFTYLJ2.js} +1 -1
- package/dist/cdn/{GEGBP3Y7.js → QXGXNOTJ.js} +1 -1
- package/dist/cdn/{LWCHUKSA.js → ST5FQYT7.js} +1 -1
- package/dist/cdn/{DIR5LQFZ.js → SXHH575T.js} +17 -17
- package/dist/cdn/{V74PXMI2.js → UAKSN7EQ.js} +1 -1
- package/dist/cdn/{FM2X5ZI6.js → WVPU4QOO.js} +1 -1
- package/dist/cdn/agent-utils/index.js +1 -1
- package/dist/cdn/index.js +1 -1
- package/dist/chunks/generateLayerDescriptions.js +198 -191
- package/dist/docs/api.json +1 -1
- package/dist/docs/docs.json +1 -1
- package/dist/docs/web-types.json +1 -1
- package/package.json +4 -4
|
@@ -1,5 +1,5 @@
|
|
|
1
1
|
/* COPYRIGHT Esri - https://js.arcgis.com/5.2/LICENSE.txt */
|
|
2
|
-
import c from"./3ZPPYCNL.js";import b from"./
|
|
2
|
+
import c from"./3ZPPYCNL.js";import b from"./ST5FQYT7.js";import a from"./SXHH575T.js";import{a as i}from"./HJG7QM2R.js";import{Va as S,a as u,b as p,s as f}from"./TFT6HK3O.js";export default $arcgis.t(([,,,,,,{r:x},{A:_,B:h,a:w,m:E,o:y,p:I,q:L,r:v,s:F,t:$,u:C,v:N,w:R,x:T,y:b,z:A},q])=>{var V=.7,z=10,D=async(a,t)=>{try{await i({text:"Similarity search to find fields"},t);let e=y(t,"fieldSearch"),n=y(t,"layersAndFieldsRegistry"),o=y(t,"embeddingCache"),r=await e.searchFields({text:a.agentExecutionContext.assignedTask,layerIds:a.vectorSearchLayerIds,minScore:V,topResults:z,embeddingCache:o}),m=r.map(({layerId:d,results:c})=>{let g=c.map(s=>` - ${s.name} (${s.score.toFixed(2)})`).join(`
|
|
3
3
|
`);return`${n.get(d)?.layerItem.name??d}:
|
|
4
4
|
${g}`}).join(`
|
|
5
5
|
`),l;return r.length>0?l=`Vector search completed. Matching layers and fields with scores:
|
|
@@ -1,2 +1,2 @@
|
|
|
1
1
|
/* COPYRIGHT Esri - https://js.arcgis.com/5.2/LICENSE.txt */
|
|
2
|
-
import{a as u,b as S,c as v}from"./M3MRIGDZ.js";import b from"./HBLRVXEB.js";import{b as f,c as y}from"./57OMVTIU.js";import a from"./
|
|
2
|
+
import{a as u,b as S,c as v}from"./M3MRIGDZ.js";import b from"./HBLRVXEB.js";import{b as f,c as y}from"./57OMVTIU.js";import a from"./SXHH575T.js";import"./R74ZHFA6.js";import"./HJG7QM2R.js";import{c as d}from"./YHQJ66WJ.js";import{b as c}from"./ICYUPLZM.js";import{X as g,y as l}from"./TFT6HK3O.js";import"./LUY6V4TP.js";import"./VXFQANGJ.js";import"./MWYBF3F3.js";import"./UZLQALHY.js";export default $arcgis.t(([,,,{watch:T},,{property:m,subclass:_},{f:h},w])=>{var k=Object.defineProperty,x=Object.getOwnPropertyDescriptor,a=(e,s,t,r)=>{for(var o=r>1?void 0:r?x(s,t):s,n=e.length-1,p;n>=0;n--)(p=e[n])&&(o=(r?p(s,t,o):p(o))||o);return r&&o&&k(s,t,o),o},i=class extends w{constructor(e){super(e),this.modelTier="default"}initialize(){this.addHandles(T(()=>[this.description,this.inputSchema,this.modelTier,this.name,this.outputSchema,this.prompt,this.tools],()=>{this.generate()},{initial:!0,sync:!0}))}getSchemas(){return[this.inputSchema,this.outputSchema].filter(Boolean)}generate(){let e=f(this.getSchemas());this._set("workspace",e);let s=this.id,t={[s]:this._invoke.bind(this)},r=[{from:s,decide:()=>{}}];this._set("createGraph",()=>y(t,r,e,{agent:this,entryNode:s,middlewares:this.middlewares}))}async _invoke(e,s){try{return this.outputSchema?await this._invokeStructured(e,s):await this._invokeUnstructured(e,s)}catch(t){if(l(t))throw t;let r=t instanceof Error?t.message:String(t);return u({outputMessage:r},"failed",r)}}async _invokeStructured(e,s){if(!this.outputSchema)throw new Error("Output schema is required for structured invocation.");let t=await c({model:await h({modelTier:this.modelTier}),systemPrompt:await this._getPromptWithInputVariables(e),tools:this._getTools(),checkpointer:!0,middleware:d(this.middlewares),responseFormat:this.outputSchema}).invoke({messages:e.agentExecutionContext.messages},s);if(!("structuredResponse"in t)||t.structuredResponse===void 0)throw new Error("LLMAgent did not receive structured output from createAgent.");return S(t.structuredResponse,this.outputSchema,t.messages)}async _invokeUnstructured(e,s){let t=(await c({model:await h({modelTier:this.modelTier}),systemPrompt:await this._getPromptWithInputVariables(e),tools:this._getTools(),checkpointer:!0,middleware:d(this.middlewares)}).invoke({messages:e.agentExecutionContext.messages},s)).messages,r=t.at(-1)?.content??"",o=typeof r=="string"?r:JSON.stringify(r),n=o.trim()||"LLMAgent completed.";return u({agentExecutionContext:{...e.agentExecutionContext,messages:t},outputMessage:o},"success",n)}async _getPromptWithInputVariables(e){let s=v(e,this.inputSchema);for(let{outputKey:t}of this.middlewares)t&&(s[String(t)]=e[t]);return await g.fromTemplate(this.prompt).format(s)}_getTools(){return this.tools?.map(e=>e.getTool())??[]}};a([m()],i.prototype,"prompt",2);a([m()],i.prototype,"tools",2);a([m()],i.prototype,"inputSchema",2);a([m()],i.prototype,"outputSchema",2);a([m()],i.prototype,"modelTier",2);i=a([_("LLMAgent")],i);return i},"identity/IdentityManager","portal/Portal","request","core/reactiveUtils","layers/FeatureLayer","core/accessorSupport/decorators",a,b)
|
|
@@ -1,5 +1,5 @@
|
|
|
1
1
|
/* COPYRIGHT Esri - https://js.arcgis.com/5.2/LICENSE.txt */
|
|
2
|
-
import c from"./3ZPPYCNL.js";import b from"./
|
|
2
|
+
import c from"./3ZPPYCNL.js";import b from"./ST5FQYT7.js";import a from"./SXHH575T.js";import{a as g}from"./HJG7QM2R.js";import{Va as $,a as k,b as E}from"./TFT6HK3O.js";import{a as f}from"./VXFQANGJ.js";export default $arcgis.t(([,,,,,,{q:N,r:T},{a:b,b:x,c:v,d:C,e:F,f:R,g:L,h:_,i:I,j:M,k:Z,l:A,m:S,n:q,o:p,p:j},V])=>{var w=[C,F,R,L,_,I,M,Z,A];async function B(e,t){let a=await S("navigation_tool_prompt"),{mapView:r}=v(t),c=r.map.bookmarks?.map(h=>h.name).filter(Boolean)??[],s=e.vectorSearchLayerResults?.length>0?e.vectorSearchLayerResults.map((h,G)=>`${G+1}. layerId=${h.id} | title=${h.title??""} | name=${h.name??""} | score=${h.score.toFixed(2)}`).join(`
|
|
3
3
|
`):"",l=e.vectorSearchFieldResults?.length>0?JSON.stringify(e.vectorSearchFieldResults,null,2):"",i=e.intent==="goToBookmark"&&c.length?`Available bookmarks:
|
|
4
4
|
${c.map(h=>`- ${h}`).join(`
|
|
5
5
|
`)}`:"",o=(e.intent==="goToLayer"||e.intent==="goToFeatures")&&e.vectorSearchLayerResults?.length?`Candidate layers:
|
|
@@ -1,2 +1,2 @@
|
|
|
1
1
|
/* COPYRIGHT Esri - https://js.arcgis.com/5.2/LICENSE.txt */
|
|
2
|
-
import d from"./
|
|
2
|
+
import d from"./CXW5URTF.js";import c from"./3ZPPYCNL.js";import b from"./ST5FQYT7.js";import a from"./SXHH575T.js";import{a as s,c as e}from"./V6HOUZPZ.js";import"./3UEKINYC.js";import"./RLEHNAIA.js";import{v as i,z as r}from"./2XQAM2Q3.js";import"./R74ZHFA6.js";import"./HJG7QM2R.js";import"./ICYUPLZM.js";import"./TFT6HK3O.js";import"./LUY6V4TP.js";import"./VXFQANGJ.js";import"./MWYBF3F3.js";import"./UZLQALHY.js";export default $arcgis.t(([,,,,,,,,,,,,,,o])=>{var t=class extends i{constructor(){super(...arguments),this.agent=o}static{this.properties={referenceElement:1}}#t;#i;getContext(){if(!this.#t)throw new Error("arcgis-assistant-layer-styling-agent requires a mapView");return{mapView:this.#t}}load(){this.#t=s(this,"arcgis-assistant-layer-styling-agent"),this.#i=e(this)}disconnectedCallback(){this.#i?.unregister(this.agent.id),super.disconnectedCallback()}};r("arcgis-assistant-layer-styling-agent",t);return t},"identity/IdentityManager","portal/Portal","request","config","core/reactiveUtils","layers/FeatureLayer","intl","smartMapping/statistics/summaryStatistics","smartMapping/statistics/uniqueValues","views/LinkChartView","rest/knowledgeGraphService",a,b,c,d)
|
|
@@ -1,5 +1,5 @@
|
|
|
1
1
|
/* COPYRIGHT Esri - https://js.arcgis.com/5.2/LICENSE.txt */
|
|
2
|
-
import c from"./3ZPPYCNL.js";import b from"./
|
|
2
|
+
import c from"./3ZPPYCNL.js";import b from"./ST5FQYT7.js";import a from"./SXHH575T.js";import{a as n}from"./HJG7QM2R.js";import{Va as N,a as I,b as S}from"./TFT6HK3O.js";import{ca as $}from"./LUY6V4TP.js";export default $arcgis.t(([,,,,,,P,U,{p:k,r:T},{C:M,D:z,E:L,F:D,G:F,H:O,a:A,m:w,n:R,o:y,p:V},b])=>{var W=async(e,t)=>(await n({text:"Exiting Data Exploration agent"},t),e),B=async(e,t)=>{await n({text:"Requesting LLM for layer filter results"},t);let a=await w("data_explore_filter_prompt");if(!t?.configurable)throw new Error("config.configurable is required for layer filter tools");let{userTimezone:d,userTimezoneOffset:o}=L(),s={layerFieldInfo:e.layerFieldInfo,userTimezone:d,userTimezoneOffset:o,queryResponse:e.queryResponse,assignedTask:e.agentExecutionContext.assignedTask,userRequest:e.agentExecutionContext.userRequest,priorSteps:e.agentExecutionContext.priorSteps},i=await T({promptText:a,modelTier:"advanced",config:t,messages:e.dataExplorationMessages,inputVariables:s,tools:F}),r=[...e.dataExplorationMessages,i];if(!((i.tool_calls?.length??0)>0))return await n({text:"LLM determined no filter changes needed"},t),{...e,dataExplorationMessages:r};let c=r,l=i.content.toString();return await b(i,t),{...e,dataExplorationMessages:c,outputMessage:l}},H=async(e,t)=>{await n({text:"Requesting LLM for layer query results"},t);let a=await w("data_explore_query_prompt");if(!t?.configurable)throw new Error("config.configurable is required for layer query tools");let{userTimezone:d,userTimezoneOffset:o}=L(),s=e.agentExecutionContext.sharedState,i=s.lastNavigatedFeatures?.value,r=s.lastResolvedLocation?.value,c="none";if(i!=null)try{c=JSON.stringify(i)}catch{c="none"}let l="none";if(r!=null)try{l=JSON.stringify({address:r.address,location:r.location})}catch{l="none"}let g={layerFieldInfo:e.layerFieldInfo,userTimezone:d,userTimezoneOffset:o,assignedTask:e.agentExecutionContext.assignedTask,userRequest:e.agentExecutionContext.userRequest,priorSteps:e.agentExecutionContext.priorSteps,lastNavigatedFeatures:c,lastResolvedLocation:l},m=await T({promptText:a,modelTier:"advanced",config:t,messages:e.dataExplorationMessages,inputVariables:g,tools:D}),h=(m.tool_calls?.length??0)>0,f=m.content.toString();return await b(m,t),{...e,dataExplorationMessages:[...e.dataExplorationMessages,m],...h?{}:{outputMessage:f},status:"success",summary:f&&!h?R(f):"Query planning completed."}},J=async(e,t)=>{try{await n({text:"Requesting LLM for summary on query results"},t);let a=await w("summarize_query_response_prompt"),d={queryResponse:e.queryResponse,assignedTask:e.agentExecutionContext.assignedTask,userRequest:e.agentExecutionContext.userRequest,priorSteps:e.agentExecutionContext.priorSteps},o=await k({promptText:a,modelTier:"fast",config:t,messages:e.dataExplorationMessages,inputVariables:d}),s=typeof o=="string"?o:o.content,i=new $(s);await n({text:`Received response from LLM: ${s}`},t);let r=s;return{...e,outputMessage:r,status:"success",summary:r?R(r):"Summary generated.",dataExplorationMessages:[...e.dataExplorationMessages,i]}}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 K(e,t){if((e.queryResponse??[]).some(d=>{let o=d.details;return typeof o=="object"&&o!==null&&"error"in o}))return await n({text:"Skipping layer filter tool because query response contains an error."},t),{...e};let a=await new A(F,{handleToolErrors:!1}).invoke({messages:e.dataExplorationMessages},t);return await n({text:`Finished executing layer filter tool: ${a.messages.map(d=>d.content).join(", ")}`},t),{...e}}var X=10,Y=["string","small-integer","integer"],Z=async(e,t,{includeSummaryStatistics:a=!0,includeUniqueValues:d=!0}={})=>{let o=null,s=null;try{if(t.type!=="geometry"&&t.type!=="oid"&&t.type!=="global-id"){a&&(o=await P({layer:e,field:t.name}));let i=t.domain?.type==="coded-value"?t.domain:null;d&&(Y.includes(t.type)||i)&&(s=(await U({layer:e,field:t.name})).uniqueValueInfos.sort((r,c)=>c.count-r.count).slice(0,X),i&&(s=s.map(r=>({...r,value:i.getName(r.value)??r.value}))))}}catch(i){console.error(`Error fetching statistics for field ${t.name}:`,i)}return{summaryStatistics:o,uniqueValues:s}};function ee(e,t){return["string","small-integer","integer"].includes(e)||t==="coded-value"}async function te(e,t,a,d=!0){let o=[],s=[],i=[];for(let r of e){let c=function(p){let u=t.get(p)?.layerItem;return u?[u.name&&`Name: ${u.name}`,u.title&&`Title: ${u.title}`,u.description&&`Description: ${u.description}`].filter(Boolean).join(" | "):p},{layerId:l,results:g}=r,m=a.map?.allLayers.find(p=>p.id===l),h=t.get(l)?.fieldRegistry;if(!h)continue;let f=o.find(p=>p.layerId===l);f||(f={layerId:l,layerSummary:c(l),fieldInfos:[]},o.push(f));for(let p of g){let u=h.get(p.name);if(!u)continue;let x=u.statistics,v=d&&!x?.summaryStatistics,q=ee(u.type,u.domain?.type)&&!x?.uniqueValues,_=v||q;if(i.push({layerId:l,fieldName:u.name,didFetchStatistics:_}),_){let G=Z(m,u,{includeSummaryStatistics:v,includeUniqueValues:q}).then(C=>{let E={summaryStatistics:x?.summaryStatistics??null,uniqueValues:x?.uniqueValues??null};v&&(E.summaryStatistics=C.summaryStatistics),q&&(E.uniqueValues=C.uniqueValues),h.set(u.name,{...u,statistics:E}),u.statistics=E});s.push(G)}f.fieldInfos.push(u)}}return await Promise.all(s),{layerFieldInfo:o,didFetchStatistics:s.length>0,fieldStatisticsFetchStatus:i}}var j=/\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 ae(e,t){return j.test(e)||j.test(t)}var se=async(e,t)=>{try{await n({text:"Preparing field information for vector search results"},t);let a=y(t,"layersAndFieldsRegistry"),{mapView:d}=z(t),{assignedTask:o,userRequest:s}=e.agentExecutionContext,i=ae(o,s),{layerFieldInfo:r,didFetchStatistics:c,fieldStatisticsFetchStatus:l}=await te(e.vectorSearchFieldResults,a,d,i);c?await n({text:"Statistics fetched"},t):await n({text:"Statistics skipped"},t);for(let g of l)await n({text:` - ${g.fieldName} - stats ${g.didFetchStatistics?"fetched":"skipped"}`},t);return await n({text:"Field information prepared"},t),{...e,layerFieldInfo:r}}catch(a){throw await n({text:"Error during fetching statistics"},t),new Error(`Error during fetching statistics: ${a instanceof Error?a.message:String(a)}`)}},Q=.7,re=10,ie=async(e,t)=>{try{await n({text:"Similarity search to find fields"},t);let a=y(t,"fieldSearch"),d=y(t,"layersAndFieldsRegistry"),o=y(t,"embeddingCache"),s=await a.searchFields({text:e.agentExecutionContext.assignedTask,layerIds:e.vectorSearchLayerIds,minScore:Q,topResults:re,embeddingCache:o}),i=s.map(({layerId:c,results:l})=>{let g=l.map(m=>` - ${m.name} (${m.score.toFixed(2)})`).join(`
|
|
3
3
|
`);return`${d.get(c)?.layerItem.name??c}:
|
|
4
4
|
${g}`}).join(`
|
|
5
5
|
`),r;return s.length>0?r=`Vector search completed. Matching layers and fields with scores:
|
|
@@ -1,2 +1,2 @@
|
|
|
1
1
|
/* COPYRIGHT Esri - https://js.arcgis.com/5.2/LICENSE.txt */
|
|
2
|
-
import d from"./
|
|
2
|
+
import d from"./E5ZKBC24.js";import c from"./3ZPPYCNL.js";import b from"./ST5FQYT7.js";import a from"./SXHH575T.js";import{a as s,c as o}from"./V6HOUZPZ.js";import"./3UEKINYC.js";import"./RLEHNAIA.js";import{v as i,z as r}from"./2XQAM2Q3.js";import"./R74ZHFA6.js";import"./HJG7QM2R.js";import"./ICYUPLZM.js";import"./TFT6HK3O.js";import"./LUY6V4TP.js";import"./VXFQANGJ.js";import"./MWYBF3F3.js";import"./UZLQALHY.js";export default $arcgis.t(([,,,,,,,,,,,,,,a])=>{var t=class extends i{constructor(){super(...arguments),this.agent=a}static{this.properties={referenceElement:1}}#t;#i;getContext(){if(!this.#t)throw new Error("arcgis-assistant-navigation-agent requires a mapView");return{mapView:this.#t}}load(){this.#t=s(this,"arcgis-assistant-navigation-agent"),this.#i=o(this)}disconnectedCallback(){this.#i?.unregister(this.agent.id),super.disconnectedCallback()}};r("arcgis-assistant-navigation-agent",t);return t},"identity/IdentityManager","portal/Portal","request","config","core/reactiveUtils","layers/FeatureLayer","intl","smartMapping/statistics/summaryStatistics","smartMapping/statistics/uniqueValues","views/LinkChartView","rest/knowledgeGraphService",a,b,c,d)
|
|
@@ -1,2 +1,2 @@
|
|
|
1
1
|
/* COPYRIGHT Esri - https://js.arcgis.com/5.2/LICENSE.txt */
|
|
2
|
-
import d from"./
|
|
2
|
+
import d from"./PUFTYLJ2.js";import c from"./3ZPPYCNL.js";import b from"./ST5FQYT7.js";import a from"./SXHH575T.js";import{a as s,c as e}from"./V6HOUZPZ.js";import"./3UEKINYC.js";import"./RLEHNAIA.js";import{v as i,z as r}from"./2XQAM2Q3.js";import"./R74ZHFA6.js";import"./HJG7QM2R.js";import"./ICYUPLZM.js";import"./TFT6HK3O.js";import"./LUY6V4TP.js";import"./VXFQANGJ.js";import"./MWYBF3F3.js";import"./UZLQALHY.js";export default $arcgis.t(([,,,,,,,,,,,,,,o])=>{var t=class extends i{constructor(){super(...arguments),this.agent=o}static{this.properties={referenceElement:1}}#t;#i;getContext(){if(!this.#t)throw new Error("arcgis-assistant-help-agent requires a mapView");return{mapView:this.#t}}load(){this.#t=s(this,"arcgis-assistant-help-agent"),this.#i=e(this)}disconnectedCallback(){this.#i?.unregister(this.agent.id),super.disconnectedCallback()}};r("arcgis-assistant-help-agent",t);return t},"identity/IdentityManager","portal/Portal","request","config","core/reactiveUtils","layers/FeatureLayer","intl","smartMapping/statistics/summaryStatistics","smartMapping/statistics/uniqueValues","views/LinkChartView","rest/knowledgeGraphService",a,b,c,d)
|
|
@@ -1,3 +1,3 @@
|
|
|
1
1
|
/* COPYRIGHT Esri - https://js.arcgis.com/5.2/LICENSE.txt */
|
|
2
|
-
import a from"./
|
|
2
|
+
import a from"./SXHH575T.js";import{b as E}from"./R74ZHFA6.js";import{a as g}from"./HJG7QM2R.js";import{Va as A,a as v,b as I,ba as S,y as R}from"./TFT6HK3O.js";import{ca as b,oa as C}from"./LUY6V4TP.js";export default $arcgis.t(([N,U,H,T,_,{a:k,d:D,e:f,g:$,h:M,o:W}])=>{var G=async e=>{let t=await z(),n=await k("default"),s=U.getDefault(),r=(await N.getCredential(`${s.url}/sharing`)).token,a={type:"generateEmbeddings",webmapEmbeddings:e,auth:{apiUrl:n,token:r}};return t.postMessage(a),await new Promise((i,c)=>{let o=u=>{u.data==="completed"&&(t.removeEventListener("message",o),i())},d=u=>{t.removeEventListener("message",o),c(u instanceof Error?u:new Error("Embeddings worker error"))};t.addEventListener("message",o),t.addEventListener("error",d,{once:!0})}),t},z=async()=>{{let e=(await import("./OKVLGJAG.js")).default;return new e}},Q=e=>{e.currentIntent="none"},B=async(e,t)=>{let n=f(t);if(e.agentExecutionContext.userRequest){let r=new C(e.agentExecutionContext.userRequest.trim());e.agentExecutionContext.messages=[...e.agentExecutionContext.messages,r],Q(e)}let s=n?.services.agentRegistry.list().map(r=>r.agent.id)??[];return await g({text:`Available agents: ${[...s].join(", ")}`},t),await g({text:"Analyzing user input"},t),e},J=async(e,t)=>(await g({text:"Exiting..."},t),e),q=e=>typeof e=="object"&&e!==null&&!Array.isArray(e),K=(e,t)=>{if(!q(e)){e!==void 0&&console.warn(`Agent "${t}" returned invalid sharedStatePatch. Ignoring it.`);return}let n={};for(let[s,r]of Object.entries(e)){if(!q(r)||!("value"in r)){console.warn(`Agent "${t}" returned invalid sharedStatePatch entry for key "${s}". Ignoring that entry.`);continue}n[s]={value:r.value}}return n},V=e=>{let{previousSharedState:t,patch:n,agentId:s}=e;if(!n)return t;let r=Date.now(),a={...t};for(let[i,c]of Object.entries(n))c?.value!==void 0&&(a[i]={value:c.value,meta:{updatedByAgentId:s,updatedAt:r}});return a},F=e=>typeof e!="string"?void 0:e.trim()||void 0,X=e=>{switch(e){case"failed":return"Agent failed without a summary.";case"unknown":return"Agent returned with unknown status.";case"success":return"Agent completed without a summary.";default:return"Agent completed without a summary."}},Y=(e,t)=>{let n=F(t?.outputMessage),s=F(t?.summary),r=t?.status,a=r==="success"||r==="failed"?r:"unknown";a==="unknown"&&console.warn(`Agent "${e}" returned missing/invalid status. Defaulting to "unknown".`);let i=K(t?.sharedStatePatch,e);return{outputMessage:n,summary:s??n??X(a),status:a,sharedStatePatch:i}},L=4e3,Z=async(e,t)=>{let n=f(t);if(t?.signal?.aborted)return await g({text:"Run cancelled; skipping agent execution"},t),{...e,currentIntent:"none",requiresFollowUp:!1};let{agentRegistry:s}=n?.services??{},r=s?.get(e.currentIntent);if(!r)return console.warn(`No agent found for intent: ${e.currentIntent}`),e;await g({text:`Executing registered agent: ${r.agent.name}`},t);let a={...t??{},configurable:{...n??{},agentId:r.agent.id,context:r.getContext?await r.getContext():void 0}},i;try{let d=await r.agent.createGraph().compile().invoke({agentExecutionContext:{...e.agentExecutionContext,messages:[...e.agentExecutionContext.messages],priorSteps:structuredClone(e.agentExecutionContext.priorSteps??[]),sharedState:structuredClone(e.agentExecutionContext.sharedState??{})}},a);i=Y(r.agent.name,d),await g({text:`Finished executing registered agent: ${r.agent.name}`},t)}catch(d){if(R(d)||t?.signal?.aborted||d instanceof Error&&d.name==="AbortError")throw d;let u=d instanceof Error?d.message:String(d);console.error(`Agent "${r.agent.name}" failed:`,d),await g({text:`Registered agent failed: ${r.agent.name}. ${u}`},t),i={status:"failed",outputMessage:`Agent execution failed: ${u}`,summary:`Agent execution failed: ${u}`}}let c=i.outputMessage,o=[...e.agentExecutionContext.messages];if(c){let d=c.length>L?`${c.slice(0,L-14)}
|
|
3
3
|
[truncated]`:c;o.push(new b(d))}return{...e,stepCount:e.stepCount+1,lastExecutedAgent:r.agent.id,requiresFollowUp:i.status==="failed"?!0:e.requiresFollowUp,finalOutputMessage:c??"",agentExecutionContext:{...e.agentExecutionContext,messages:o,priorSteps:[...e.agentExecutionContext.priorSteps??[],{agentId:r.agent.id,assignedTask:e.agentExecutionContext.assignedTask,summary:i?.summary||"No summary provided.",status:i?.status||"unknown"}],sharedState:V({previousSharedState:e.agentExecutionContext.sharedState,patch:i.sharedStatePatch,agentId:r.agent.id})}}},ee=async(e,t)=>{if(e.routing.mode!=="direct")throw new Error("Direct agent assignment requires direct routing.");return await g({text:`Doing a direct route to agent: ${e.routing.agentId}`},t),{...e,currentIntent:e.routing.agentId,requiresFollowUp:!1,agentExecutionContext:{...e.agentExecutionContext,assignedTask:e.agentExecutionContext.userRequest}}},te=3,re=e=>e.routing.mode==="direct"?"assignDirectAgent":"intentLLM",ne=e=>e.routing.mode==="direct"||e.stepCount>=te||!e.requiresFollowUp?"exit":"intentLLM",se=()=>new A(D).addNode("ingestInput",B).addNode("assignDirectAgent",ee).addNode("intentLLM",M).addNode("executeRegisteredAgent",Z).addNode("exit",J).addEdge(v,"ingestInput").addConditionalEdges("ingestInput",re).addEdge("assignDirectAgent","executeRegisteredAgent").addConditionalEdges("intentLLM",e=>e.currentIntent==="none"||e.currentIntent===e.lastExecutedAgent?"exit":"executeRegisteredAgent").addConditionalEdges("executeRegisteredAgent",ne).addEdge("exit",I),w=class{constructor(){this.agentRegistry=new Map}register(t){let{agent:n}=t;if(this.agentRegistry.has(n.id))throw new Error(`Duplicate agent id: ${n.id}`);this.agentRegistry.set(n.id,t)}get(t){return this.agentRegistry.get(t)}list(){return[...this.agentRegistry.values()]}},x=class{constructor(t,n){this.graph=t,this.config={...n}}async waitForUser(){return await new Promise((t,n)=>{this.resolveWait=t,this.rejectWait=n})}handle(t,n){try{let s={agentId:t.agentId,id:t.id,payload:n},r=this.graph.streamEvents(null,{...this.config,configurable:{...this.config.configurable,hitlResponse:s},subgraphs:!0,version:"v2"});this.resolveWait?.(r)}catch(s){this.rejectWait?.(s)}finally{this.resolveWait=void 0,this.rejectWait=void 0}}cancel(){this.rejectWait&&(this.rejectWait(new Error("Request cancelled by user.")),this.resolveWait=void 0,this.rejectWait=void 0)}},ae=async e=>{try{return await(await $()).embedDocuments(e)}catch(t){throw console.error("Failed to generate embeddings:",t),t}},O=async(e,t)=>{let n=t.get(e);if(n)return n;let s=await ae([e]);return t.set(e,s[0]),s[0]};async function ie(e,t,n,s){let r=`req-${Date.now()}`,a={type:"layerSearch",precomputedEmbedding:s?await O(e,s):void 0,requestId:r,minScore:n};return await new Promise(i=>{let c=o=>{o.data.requestId===r&&i(o.data.results)};t.addEventListener("message",c,{once:!0}),t.postMessage(a)})}function oe(e){let{worker:t}=e;return{async searchLayers({text:n,minScore:s,embeddingCache:r}){return await ie(n,t,s,r)}}}var de=async({combinedQuery:e,layerIds:t,embeddingsWorker:n,minScore:s,topResults:r,embeddingCache:a})=>{let i=`req-${Date.now()}`,c=a?await O(e,a):void 0,o={type:"fieldSearch",layerIdForFieldsSearch:t,precomputedEmbedding:c,requestId:i,minScore:s,topResults:r};return await new Promise(d=>{let u=p=>{if(p.data.requestId!==i)return;let y=p.data.results.map(({layerId:l,results:m})=>({layerId:l,results:m}));d(y)};n.addEventListener("message",u,{once:!0}),n.postMessage(o)})};function ce(e){let{worker:t}=e;return{async searchFields({text:n,layerIds:s,minScore:r,topResults:a,embeddingCache:i}){return await de({combinedQuery:n,layerIds:s,embeddingsWorker:t,minScore:r,topResults:a,embeddingCache:i})}}}var ue=e=>{let t=W.safeParse(e);if(!t.success)throw new Error("Embeddings response validation failed. Regenerate embeddings.");return t.data},ge=(e,t)=>{let n=new Map,s=new Map;if(t.allLayers.forEach(r=>{r instanceof T&&s.set(r.id,r)}),e.length!==s.size)throw new Error("Layer count mismatch during registry restoration. Regenerate embeddings.");for(let r of e){let a=s.get(r.id);if(!a)throw new Error(`Layer with ID ${r.id} not found in the original map during registry restoration. Regenerate embeddings.`);if(r.fields.length!==a.fields.length)throw new Error(`Field count mismatch for layer ID ${r.id} during registry restoration. Regenerate embeddings.`);let i={name:r.name,title:r.title,description:r.description},c=new Map;for(let o of r.fields){let d=a.fieldsIndex.get(o.name);if(!d)throw new Error(`Field with name ${o.name} not found in the original layer ${r.id} during registry restoration. Regenerate embeddings.`);c.set(o.name,{name:o.name,alias:a.getFieldAlias(o.name)??o.alias,description:o.description,type:d.type||"unknown",valueType:d.valueType||"unknown",domain:a.getFieldDomain(o.name)??void 0})}n.set(r.id,{layerItem:i,fieldRegistry:c})}return n},le=async e=>{try{return(await _(e,{responseType:"json"})).data}catch(t){throw new Error(`Failed to fetch data from ${e}: ${String(t)}`)}},he=async e=>{let t=e.map;if(!t?.portalItem)throw new Error("WebMap portal item is missing.");let{resources:n}=await t.portalItem.fetchResources(),s=n.find(a=>a.resource.path==="embeddings-v01.json");if(!s?.resource.url)throw new Error("Embeddings resource 'embeddings-v01.json' not found in the webmap portal item.");let r=await le(s.resource.url);return ue(r)},j=class e{constructor(){this.orchestratorReady=!1,this.chatHistory=[],this.priorSteps=[],this.sharedState={},this.agentRegistry=new w,this.activeRunId="",this.cancelledRunIds=new Set,this.streamEpoch=0}static async init(t){let n=new e;try{if(t.view?.map){await H.whenOnce(()=>t.view.ready);let s=await he(t.view),r=ge(s.layers,t.view.map);n.layersAndFieldsRegistry=r,n.embeddingsWorker=await G(s)}return t.agents?.forEach(s=>{n.agentRegistry.register(s)}),n.orchestratorReady=!0,n}catch(s){throw console.error("Orchestrator initialization failed:",s),s}}async*ask(t,n={}){if(!this.orchestratorReady)throw new Error("Orchestrator is not ready yet.");if(!this.agentRegistry.list().length)throw new Error("Orchestrator has no registered agents.");let s=this.createRequestAgentRegistry(n);if(!s.list().length)throw new Error("Orchestrator has no agents selected for this request.");if(++this.streamEpoch,!t.trim())return;let r=E();this.activeRunId=r,this.activeAbortController=new AbortController,this.graph||(this.graph=se().compile({checkpointer:new S}));let a=this.embeddingsWorker?oe({worker:this.embeddingsWorker}):void 0,i=this.embeddingsWorker?ce({worker:this.embeddingsWorker}):void 0,c=new Map,o=n.routing==="direct"?{mode:"direct",agentId:n.agentId}:{mode:"auto"},d={thread_id:r,hitlResponse:null,services:{layerSearch:a,fieldSearch:i,layersAndFieldsRegistry:this.layersAndFieldsRegistry,agentRegistry:s,embeddingCache:c}},u={version:"v2",streamMode:"custom",signal:this.activeAbortController.signal,configurable:d,subgraphs:!0},p=this.graph?.streamEvents({routing:o,agentExecutionContext:{userRequest:t,messages:this.chatHistory,priorSteps:this.priorSteps,sharedState:this.sharedState}},u),y=++this.streamEpoch;if(yield*this.pipeStream(p,y,r),this.isRunCancelled(r)){yield{runId:r,timestamp:Date.now(),type:"cancelled",reason:"user"};return}for(;;){if(this.isRunCancelled(r)){yield{runId:r,timestamp:Date.now(),type:"cancelled",reason:"user"};return}let m=(await this.graph.getState(u,{subgraphs:!0})).tasks.find(h=>h.interrupts.length>0)?.interrupts[0]?.value;if(!m)break;this.currentInterrupt=m,this.interruptHandler=new x(this.graph,u),yield{runId:r,timestamp:Date.now(),type:"interrupt",interrupt:m};try{let h=await this.interruptHandler.waitForUser(),P=++this.streamEpoch;yield*this.pipeStream(h,P,r)}catch(h){if(this.isRunCancelled(r)){yield{runId:r,timestamp:Date.now(),type:"cancelled",reason:"user"};return}if(h){yield{runId:r,timestamp:Date.now(),type:"error",error:{message:h?.message}};return}}}if(this.isRunCancelled(r)){yield{runId:r,timestamp:Date.now(),type:"cancelled",reason:"user"};return}let l=(await this.graph.getState(u,{subgraphs:!0})).values;if(this.isRunCancelled(r)){yield{runId:r,timestamp:Date.now(),type:"cancelled",reason:"user"};return}this.chatHistory=l.agentExecutionContext.messages.length?l.agentExecutionContext.messages:this.chatHistory,this.priorSteps=l.agentExecutionContext.priorSteps?.slice(-5)??[],this.sharedState=l.agentExecutionContext.sharedState??{},yield{runId:r,timestamp:Date.now(),type:"completed",result:{content:l.finalOutputMessage}}}newConversation(){this.chatHistory=[],this.priorSteps=[],this.sharedState={}}resumeInterrupt(t){if(!this.currentInterrupt||!this.interruptHandler)throw new Error("No pending interrupt to resume.");this.interruptHandler.handle(this.currentInterrupt,t)}cancelInterrupt(){this.interruptHandler&&this.interruptHandler.cancel()}cancel(){this.activeRunId&&(this.cancelledRunIds.add(this.activeRunId),this.activeAbortController?.abort(),++this.streamEpoch,this.interruptHandler?.cancel())}async*pipeStream(t,n,s){for await(let r of t){if(this.isRunCancelled(s)||n!==this.streamEpoch)break;r.event==="on_custom_event"&&r.name==="trace_message"?yield{runId:s,timestamp:Date.now(),type:"trace",data:r.data}:r.name==="graph_ux_suggestion"&&(yield{runId:s,timestamp:Date.now(),type:"ux-suggestion",suggestion:r.data})}}isRunCancelled(t){return this.cancelledRunIds.has(t)}createRequestAgentRegistry(t){let n=t.routing==="direct"?[t.agentId]:t.agentIds,s=n?n.map(a=>{let i=this.agentRegistry.get(a);if(!i)throw new Error(`Agent is not registered: ${a}`);return i}):this.agentRegistry.list(),r=new w;return s.forEach(a=>r.register(a)),r}dispose(){this.embeddingsWorker&&(this.embeddingsWorker.terminate(),this.embeddingsWorker=void 0),this.orchestratorReady=!1}};return{a:ae,b:j}},"identity/IdentityManager","portal/Portal","core/reactiveUtils","layers/FeatureLayer","request",a)
|
|
@@ -1,2 +1,2 @@
|
|
|
1
1
|
/* COPYRIGHT Esri - https://js.arcgis.com/5.2/LICENSE.txt */
|
|
2
|
-
import c from"./
|
|
2
|
+
import c from"./MW5S2XCB.js";import b from"./ST5FQYT7.js";import a from"./SXHH575T.js";import{c as s,d as n}from"./V6HOUZPZ.js";import"./3UEKINYC.js";import"./RLEHNAIA.js";import{v as r,z as o}from"./2XQAM2Q3.js";import"./R74ZHFA6.js";import"./HJG7QM2R.js";import"./ICYUPLZM.js";import"./TFT6HK3O.js";import"./LUY6V4TP.js";import"./VXFQANGJ.js";import"./MWYBF3F3.js";import"./UZLQALHY.js";export default $arcgis.t(([,,,,,,,,,{fetchKnowledgeGraph:p},,,a])=>{var i=class extends r{constructor(){super(...arguments),this.agent=a}static{this.properties={referenceElement:1,serviceUrl:3,context:0}}#e;#i;#t;#r;get serviceUrl(){return this.#i}set serviceUrl(t){this.#i=t}async getContext(){let t=this.context?{...this.context,knowledgeGraph:void 0,view:void 0}:{};if(this.#e)return{...t,view:this.#e};if(this.#t)try{let e=await this.#t;return{...t,knowledgeGraph:e}}catch(e){console.error("Failed to load knowledge graph via service URL:",e)}if(!this.context?.knowledgeGraph&&!this.context?.view)throw new Error("arcgis-assistant-knowledge-agent requires either a knowledgeGraph or view in context, and neither were provided");return this.context}willUpdate(t){t.has("serviceUrl")&&this.serviceUrl?this.#t=p(this.serviceUrl):this.#t=void 0}load(){this.#e=n(this)??void 0,this.#r=s(this)}disconnectedCallback(){this.#r?.unregister(this.agent.id),super.disconnectedCallback()}};o("arcgis-assistant-knowledge-agent",i);return i},"identity/IdentityManager","portal/Portal","request","config","core/reactiveUtils","layers/FeatureLayer","intl","smartMapping/statistics/summaryStatistics","smartMapping/statistics/uniqueValues","rest/knowledgeGraphService",a,b,c)
|
|
@@ -1,5 +1,5 @@
|
|
|
1
1
|
/* COPYRIGHT Esri - https://js.arcgis.com/5.2/LICENSE.txt */
|
|
2
|
-
import b from"./
|
|
2
|
+
import b from"./ST5FQYT7.js";import a from"./SXHH575T.js";import{a as c,b as k}from"./HJG7QM2R.js";import{Va as x,a as w,b as d,j as f}from"./TFT6HK3O.js";import{ca as u}from"./LUY6V4TP.js";export default $arcgis.t(([,,,,,,{p:_,r:b},{K:y,L:K,M:q,N:S,O:M,P:T,Q:E,R:C,S:G,T:N,U:R,a:v,m:m,n:h,p:A}])=>{var z=[T,E,N,C,M,R,G];async function $(e,a){let o=await m("arcgis_knowledge_tool_prompt"),s=K(a),n={assignedTask:e.agentExecutionContext.assignedTask,userRequest:e.agentExecutionContext.userRequest,priorSteps:e.agentExecutionContext.priorSteps,contextType:s},r=await b({promptText:o,messages:e.arcgisKnowledgeMessages,inputVariables:n,tools:z,config:a}),i=(r.tool_calls?.length??0)>0,t=typeof r.text=="string"?r.text.trim():"",l=t.length>0,p=r.content.toString();return!i&&(s==="map"||s==="knowledgeGraph")?{...e,arcgisKnowledgeMessages:[...e.arcgisKnowledgeMessages,r],outputMessage:s==="map"?"No tools were found for the current view and prompt. Maps do not support changing nonspatial visibility, layout changes, or generation from queries.":"No tools were found for the current prompt and knowledge graph service. A knowledge graph service only supports search and query.",status:"success"}:{...e,arcgisKnowledgeMessages:[...e.arcgisKnowledgeMessages,r],outputMessage:i?p:t,status:i?e.status:l?"success":"failed",summary:p?h(p):"ArcGIS Knowledge Agent tool executed."}}var L={generateCypher:"generated-cypher-query",queryGraphData:"graph-query-result",searchGraphData:"graph-search-result",addRecords:"added-records",applyLayout:"applied-layout",changeNonspatialVisibility:"changed-nonspatial-visibility",createLinkChart:"created-link-chart"};function I(e){return!!e&&e.status==="success"&&!!L[e.toolName]}function D(e){return{type:L[e.toolName],data:e.details}}async function F(e,a){let o=new v(z,{handleToolErrors:!1});try{let s=await o.invoke({messages:e.arcgisKnowledgeMessages},a),n=[];for(let t of s.messages){let l;if(typeof t.content!="string")throw new Error(`Unexpected tool message content type: ${typeof t.content}. Expected string.`);try{l=JSON.parse(t.content)}catch{throw new Error(`Failed to parse tool message content as JSON. Tool: ${t.name??"unknown"}.
|
|
3
3
|
|
|
4
4
|
Original Content: ${t.content}`)}if(!l||typeof l!="object"||!("toolName"in l))throw new Error(`Parsed tool message content does not have expected structure. Parsed content: ${JSON.stringify(l)}`);n.push(l)}await c({text:`Finished executing ArcGIS Knowledge Agent tools: ${s.messages.filter(t=>t.name).map(t=>t.name).join(", ")}`},a);let r=n.filter(t=>typeof t!="string").map(t=>`- Called Tool: ${t.toolName}, Status: ${t.status}`),i=n[0];return i&&I(i)&&await k(D(i),a),{...e,outputMessage:r.join(`
|
|
5
5
|
`),summary:r.length?h(r.join(`
|
|
@@ -1,5 +1,5 @@
|
|
|
1
1
|
/* COPYRIGHT Esri - https://js.arcgis.com/5.2/LICENSE.txt */
|
|
2
|
-
import d from"./3ZPPYCNL.js";import b from"./
|
|
2
|
+
import d from"./3ZPPYCNL.js";import b from"./ST5FQYT7.js";import a from"./SXHH575T.js";import{a as p}from"./HJG7QM2R.js";import{Va as c,a as u,b as i}from"./TFT6HK3O.js";export default $arcgis.t(([,,,,,,{r:g},{I:d,J:E,a:h,m:f,n:y,o:m,p:x},S])=>{var _=[E],v=e=>{if(!e||e.size===0)return"No layers available in this map.";let t=Array.from(e.values()).map(({layerItem:r,fieldRegistry:s},o)=>{let a=Array.from(s.values()).map(n=>n.name).slice(0,10).join(", "),l=s.size>10?` (and ${s.size-10} more)`:"";return`${o+1}. "${r.title}". Description: ${r.description}
|
|
3
3
|
Fields: ${a}${l}`}).join(`
|
|
4
4
|
|
|
5
5
|
`);return`This map contains ${e.size} layer(s):
|
|
@@ -1,2 +1,2 @@
|
|
|
1
1
|
/* COPYRIGHT Esri - https://js.arcgis.com/5.2/LICENSE.txt */
|
|
2
|
-
import e from"./
|
|
2
|
+
import e from"./GP6NDTUE.js";import d from"./3ZPPYCNL.js";import c from"./ST5FQYT7.js";import b from"./SXHH575T.js";import{a,c as s}from"./V6HOUZPZ.js";import"./3UEKINYC.js";import"./RLEHNAIA.js";import{v as i,z as r}from"./2XQAM2Q3.js";import"./R74ZHFA6.js";import"./HJG7QM2R.js";import"./ICYUPLZM.js";import"./TFT6HK3O.js";import"./LUY6V4TP.js";import"./VXFQANGJ.js";import"./MWYBF3F3.js";import"./UZLQALHY.js";export default $arcgis.t(([,,,,,,,,,,,o])=>{var t=class extends i{constructor(){super(...arguments),this.agent=o}static{this.properties={referenceElement:1}}#t;#i;getContext(){if(!this.#t)throw new Error("arcgis-assistant-data-exploration-agent requires a mapView");return{mapView:this.#t}}load(){this.#t=a(this,"arcgis-assistant-data-exploration-agent"),this.#i=s(this)}disconnectedCallback(){this.#i?.unregister(this.agent.id),super.disconnectedCallback()}};r("arcgis-assistant-data-exploration-agent",t);return t},"identity/IdentityManager","portal/Portal","request","config","core/reactiveUtils","layers/FeatureLayer","views/LinkChartView","rest/knowledgeGraphService",b,c,d,e)
|
|
@@ -1,5 +1,5 @@
|
|
|
1
1
|
/* COPYRIGHT Esri - https://js.arcgis.com/5.2/LICENSE.txt */
|
|
2
|
-
import a from"./
|
|
2
|
+
import a from"./SXHH575T.js";import{a as S,b as x}from"./HJG7QM2R.js";import{Ca as xe,Pa as D,g as Te,ha as b,j as B,k as U,y as Se}from"./TFT6HK3O.js";import{Bc as y,Q as z,U as oe,da as j}from"./LUY6V4TP.js";import{a as l}from"./VXFQANGJ.js";import{Dd as N}from"./MWYBF3F3.js";export default $arcgis.t(([Me,F,Ae,ie,je,,nt,{addressToLocations:it},st,lt,De,{createRenderer:ct},{getSchemesByTag:dt,getSchemes:ut},{getBackgroundColorTheme:Re},{createAgeRenderer:pt,createContinuousRenderer:mt},{getSchemesByTag:ge},{createContinuousRenderer:ht},{createRenderer:ft},{getSchemesByTag:yt},{createRenderer:gt},{getSchemesByTag:wt},{createRenderer:bt},{getSchemesByTag:vt},{createRenderer:Tt},{getSchemesByTag:St},{createAgeRenderer:xt,createContinuousRenderer:Et},{createRenderer:It},{getSchemesByTag:Nt},kt,Le,Oe,{formatDateOnly:$t,convertDateFormatToIntlOptions:W,formatTimeOnly:Ft,formatDate:Ce},Mt,At,Rt,Ct,qt,Pe,,{fetchKnowledgeGraph:qe,executeQueryStreaming:_t,executeSearchStreaming:zt},jt,{getBindParametersFromCypherQuery:Dt},{b:L,c:Ee,q:Ie}])=>{var Fe=e=>Array.isArray(e)&&e.every(z),tt=e=>typeof e=="object"&&e!=null&&"messages"in e&&Fe(e.messages),rt=e=>typeof e=="object"&&e!=null&&"lg_tool_call"in e,K=class extends xe{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,r){let o=this.tools.find(a=>a.name===e.name);try{if(o===void 0)throw new Error(`Tool "${e.name}" not found.`);let a={...e,type:"tool_call"},n={...t,state:r,toolCallId:e.id??"",config:t,context:t.context,store:t.store??null,writer:t.writer??t.configurable?.writer??null},s=await o.invoke(a,n);return z(s)&&s.getType()==="tool"||U(s)?s:new oe({status:"success",name:o.name,content:typeof s=="string"?s:JSON.stringify(s),tool_call_id:e.id})}catch(a){if(!this.handleToolErrors||Se(a))throw a;return new oe({status:"error",content:`Error: ${a.message}
|
|
3
3
|
Please fix your mistakes.`,name:e.name,tool_call_id:e.id??""})}}async run(e,t){let r;if(rt(e)){let{lg_tool_call:n,...s}=e;r=[await this.runTool(n,t,s)]}else{let n;if(Fe(e))n=e;else if(tt(e))n=e.messages;else throw new Error("ToolNode only accepts BaseMessage[] or { messages: BaseMessage[] } as input.");let s=new Set(n.filter(d=>d.getType()==="tool").map(d=>d.tool_call_id)),i;for(let d=n.length-1;d>=0;d-=1){let c=n[d];if(j(c)){i=c;break}}if(i==null||!j(i))throw new Error("ToolNode only accepts AIMessages as input.");r=await Promise.all(i.tool_calls?.filter(d=>d.id==null||!s.has(d.id)).map(d=>this.runTool(d,t,e))??[])}if(!r.some(U))return Array.isArray(e)?r:{messages:r};let o=[],a=null;for(let n of r)U(n)?n.graph===B.PARENT&&Array.isArray(n.goto)&&n.goto.every(s=>Te(s))?a?a.goto.push(...n.goto):a=new B({graph:B.PARENT,goto:n.goto}):o.push(n):o.push(Array.isArray(e)?[n]:{messages:[n]});return a&&o.push(a),o}};var Dn=b.Root({llmInputMessages:b({reducer:(e,t)=>D([],t),default:()=>[]})});var O=(e,t)=>t??e,Wi=b.Root({...Ee(),intent:b({reducer:O}),vectorSearchLayerResults:b({reducer:O,default:()=>[]}),vectorSearchFieldResults:b({reducer:O}),navigationInternalState:b({reducer:O,default:()=>({toolCallMessage:void 0})})});async function Lt(e,t){let r=F.getDefault().helperServices,o=r.geocode.find(u=>u.name==="ArcGIS World Geocoding Service")??r.geocode[0];if(!o)throw new Error("No geocoding service found in helperServices.");let a=o.url,n=`${ie.assetsPath?.endsWith("/")?ie.assetsPath:`${ie.assetsPath}/`}esri/images/search/search-symbol-32.png`,s=(await it(a,{address:{SingleLine:e},outFields:["Match_addr"]}))?.[0];if(!s?.extent||!s.location)throw new Error(`Could not find location for: ${e}`);let i=new st({url:n,width:24,height:24}),d=new nt({geometry:s.location,symbol:i});t.graphics.removeAll(),t.graphics.add(d),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 Ot=["mapView"];function k(e){let t=e?.configurable?.context;if(!t||typeof t!="object")throw new Error("NavigationAgent context missing");let r=Ot.filter(o=>!(o in t));if(r.length)throw new Error(`NavigationAgent context missing: ${r.join(", ")}`);return t}async function Pt({address:e},t){let{mapView:r}=k(t);return await Lt(e,r)}var Gt=l.object({address:l.string().describe("The full address or place name to locate.")}),Hi=y(Pt,{name:"goToAddress",description:"Geocodes an address using Esri's World Geocoding Service and zooms the map to that location.",schema:Gt});async function Vt(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 Qt({bookmarkName:e},t){let{mapView:r}=k(t);return await Promise.resolve(Vt(e,r))}var Bt=N.object({bookmarkName:N.string().describe("The name of the bookmark to navigate to.")}),Ji=y(Qt,{name:"goToBookmark",description:"Go to the extent of the bookmark with the given name.",schema:Bt});async function Ut(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:i}=await o.queryExtent(n);if(i===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 d={layerId:e,layerTitle:o.title??e,where:a,count:i};return{text:`Successfully zoomed to ${i} feature(s) in ${o.title} matching: ${a}`,where:a,sharedStatePatch:{lastNavigatedFeatures:{value:d}}}}catch(s){return console.error("Error in goToFeatures:",s),{text:`Error: ${s instanceof Error?s.message:"Unknown error"}`,where:a}}}async function Kt({layerId:e,where:t},r){let{mapView:o}=k(r);return await Ut(e,t,o)}var Wt=N.object({layerId:N.string().describe("The layerId of the layer to zoom to."),where:N.string().describe("ArcGIS SQL-92 WHERE expression used for `query.where` on the selected layer. Start with a fresh filter for the current request unless the task explicitly refers to prior results. Use only field name values from the selected layer, not aliases. Use field metadata only to interpret intent: prefer LIKE '%value%' for string fields, and use =, <, >, BETWEEN, IN, IS NULL, AND/OR/NOT as appropriate for number/date fields. For coded-value domain fields, use the domain code already provided in layerInfo.domain.codedValues, never the display label. Respect range-domain bounds when they are provided. Do NOT include subqueries, nested SELECT, JOIN, GROUP BY, HAVING, ORDER BY, or semicolons.")}),Zi=y(Kt,{name:"goToFeatures",description:"Go to the features that match the given filter for the given layerId. Use coded-value domain codes from layer field metadata when building the WHERE clause.",schema:Wt});async function Ht(e){let t=new lt({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 Jt(e,t){let{mapView:r}=k(t);return await Ht(r)}var Zt=N.object({}),Yi=y(Jt,{name:"goToFullExtent",description:"Zooms the map to the full world extent using Esri's Geocoding Service.",schema:Zt});async function Yt(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 Xt(e,t){let{mapView:r}=k(t);return await Yt(r)}var er=l.object({}),Xi=y(Xt,{name:"goToHomeExtent",description:"Go to the initial web map view extent",schema:er});async function tr(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 rr({layerId:e},t){let{mapView:r}=k(t);return await tr(e,r)}var or=N.object({layerId:N.string().describe("The id of the layer to navigate to")}),es=y(rr,{name:"goToLayer",description:"Zooms the map view to the full extent of the top matching layer.",schema:or});async function ar(e,t){return await t.goTo({scale:e}),{text:`Successfully zoomed to: ${e}`}}async function nr({scale:e},t){let{mapView:r}=k(t);return await ar(e,r)}var ir=l.object({scale:l.number().describe("The map scale of the view to go to.")}),ts=y(nr,{name:"goToScale",description:"Go to the specified view scale.",schema:ir});async function sr(e,t,r){let o={target:new De({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 lr({center:e,zoom:t,scale:r},o){let{mapView:a}=k(o);return await sr(e,a,{zoom:t,scale:r})}var cr=l.object({center:l.object({longitude:l.number().describe("The longitude (x-coordinate) of the point to navigate to."),latitude:l.number().describe("The latitude (y-coordinate) of the point to navigate to.")}),zoom:l.number().optional().describe("The zoom level. Higher values = more zoomed in."),scale:l.number().optional().describe("The map scale. Alternative to zoom. Smaller numbers = more zoomed in.")}),rs=y(lr,{name:"goToViewpoint",description:"Go to the specified viewpoint. This can contain a combination of scale, center, zoom, etc.",schema:cr});async function dr(e,t){return await t.goTo({zoom:e}),{text:`Successfully zoomed to: ${e}`}}async function ur({zoom:e},t){let{mapView:r}=k(t);return await dr(e,r)}var pr=l.object({zoom:l.number().min(1).max(20).describe("The zoom level of the view to go to.")}),os=y(ur,{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:pr}),_e=Object.assign({"../agents/arcgisKnowledge/prompts/arcgis_knowledge_current_lc_context.md":()=>import("./J6A4AS7E.js").then(e=>e.default),"../agents/arcgisKnowledge/prompts/arcgis_knowledge_current_map_context.md":()=>import("./TPULIO6I.js").then(e=>e.default),"../agents/arcgisKnowledge/prompts/arcgis_knowledge_cypher_query_prompt.md":()=>import("./IHP25JWI.js").then(e=>e.default),"../agents/arcgisKnowledge/prompts/arcgis_knowledge_lucene_generation_prompt.md":()=>import("./CEKOEHB3.js").then(e=>e.default),"../agents/arcgisKnowledge/prompts/arcgis_knowledge_summarize_result_prompt.md":()=>import("./VAXH6RUQ.js").then(e=>e.default),"../agents/arcgisKnowledge/prompts/arcgis_knowledge_tool_prompt.md":()=>import("./AOVJ34QE.js").then(e=>e.default),"../agents/dataExploration/prompts/data_explore_filter_prompt.md":()=>import("./PQ2DPOFM.js").then(e=>e.default),"../agents/dataExploration/prompts/data_explore_query_prompt.md":()=>import("./SDWWUWAF.js").then(e=>e.default),"../agents/dataExploration/prompts/summarize_query_response_prompt.md":()=>import("./FYZATVB3.js").then(e=>e.default),"../agents/help/prompts/help_prompt.md":()=>import("./NEV6OZN3.js").then(e=>e.default),"../agents/layerStyling/prompts/layer_styling_prompt.md":()=>import("./ICBIUFK7.js").then(e=>e.default),"../agents/navigation/prompts/navigation_intent_prompt.md":()=>import("./JEBRN3EU.js").then(e=>e.default),"../agents/navigation/prompts/navigation_tool_prompt.md":()=>import("./UHEYPSOR.js").then(e=>e.default)});async function Z(e){let t=Object.entries(_e).find(([r])=>r.endsWith(`/${e}.md`));if(!t)throw new Error(`Prompt not found: ${e}
|
|
4
4
|
Available prompts:
|
|
5
5
|
${Object.keys(_e).join(`
|