@arcgis/ai-components 5.2.0-next.72 → 5.2.0-next.74
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/agent-utils/LLMAgent.d.ts +5 -2
- package/dist/agent-utils/LLMAgent.js +1 -1
- package/dist/agentic-workflow/jsonTypes.d.ts +8 -1
- package/dist/agentic-workflow/nodes/AgentNode.d.ts +2 -0
- package/dist/agentic-workflow/nodes/tools/ArcgisTool.d.ts +21 -0
- package/dist/cdn/253R5CBD.js +2 -0
- package/dist/cdn/2VBPA27M.js +18 -0
- package/dist/cdn/{DWYODVWW.js → 323DHVYA.js} +5 -5
- package/dist/cdn/34O57OGV.js +2 -0
- package/dist/cdn/{FSMHR7GK.js → 4HDDRBIY.js} +1 -1
- package/dist/cdn/4MFEKBKL.js +11 -0
- package/dist/cdn/{Y5UFOH54.js → 4NJ2FF7H.js} +1 -1
- package/dist/cdn/4YXYLX4H.js +2 -0
- package/dist/cdn/5DVRVY4L.js +2 -0
- package/dist/cdn/5PJXNTLZ.js +2 -0
- package/dist/cdn/5R6QUF5B.js +2 -0
- package/dist/cdn/5RVELJU4.js +36 -0
- package/dist/cdn/5WLNL4HZ.js +2 -0
- package/dist/cdn/66SKMECC.js +2 -0
- package/dist/cdn/6CLF7KIK.js +2 -0
- package/dist/cdn/{S6ZAQRC6.js → 6KFMRBAA.js} +1 -1
- package/dist/cdn/77QFSIWW.js +5 -0
- package/dist/cdn/7E2QMWK6.js +2 -0
- package/dist/cdn/{HO2YDJI2.js → 7M6VKBTK.js} +1 -1
- package/dist/cdn/{HJG7QM2R.js → 7VAQUCBU.js} +1 -1
- package/dist/cdn/ACJTJLZN.js +2 -0
- package/dist/cdn/AI6DYOKR.js +181 -0
- package/dist/cdn/AT4XVTJR.js +44 -0
- package/dist/cdn/BS2PFNU4.js +2 -0
- package/dist/cdn/CCC6LBMY.js +2 -0
- package/dist/cdn/CGXQAB3A.js +2 -0
- package/dist/cdn/{M3MRIGDZ.js → CP5BVGJU.js} +1 -1
- package/dist/cdn/CWD37QFT.js +2 -0
- package/dist/cdn/DY36ATOA.js +2 -0
- package/dist/cdn/DYASSC7Z.js +2 -0
- package/dist/cdn/EAEQONP7.js +2 -0
- package/dist/cdn/EMLOVMD4.js +2 -0
- package/dist/cdn/EWLXNGKH.js +208 -0
- package/dist/cdn/FAR3DFFK.js +2 -0
- package/dist/cdn/FDOMMK2M.js +2 -0
- package/dist/cdn/GRHIFCQX.js +2 -0
- package/dist/cdn/{S3XUYAUX.js → HHFNQR6Z.js} +1 -1
- package/dist/cdn/{WQKNV6KK.js → HMUWQCXU.js} +1 -1
- package/dist/cdn/HZ5ARNAM.js +2 -0
- package/dist/cdn/I6PD2HSL.js +2 -0
- package/dist/cdn/IDUC4CPV.js +2 -0
- package/dist/cdn/IRNSIUBT.js +2 -0
- package/dist/cdn/{OYNIFMCJ.js → J6SZIQJA.js} +1 -1
- package/dist/cdn/K335IAIE.js +2 -0
- package/dist/cdn/K33MZ726.js +2 -0
- package/dist/cdn/KA3FF3ZO.js +2 -0
- package/dist/cdn/{DBHLKLKM.js → KPO4XX6J.js} +1 -1
- package/dist/cdn/{I4L45WQS.js → L7XTRDFM.js} +1 -1
- package/dist/cdn/LCFIADOZ.js +2 -0
- package/dist/cdn/MDM2K3U7.js +2 -0
- package/dist/cdn/MM33KJPF.js +2 -0
- package/dist/cdn/NIY32GK2.js +2 -0
- package/dist/cdn/{3ZPPYCNL.js → ONMNQBPO.js} +1 -1
- package/dist/cdn/ONQ6JSBJ.js +2 -0
- package/dist/cdn/{6QJFOL6M.js → OWTGH34K.js} +1 -1
- package/dist/cdn/{XPTCV6YV.js → PSYRZMX2.js} +1 -1
- package/dist/cdn/Q4IQUEZN.js +14 -0
- package/dist/cdn/QNNGPA3Q.js +2 -0
- package/dist/cdn/QRHZXLZN.js +2 -0
- package/dist/cdn/QVOMX3R6.js +2 -0
- package/dist/cdn/QZ3NQTNQ.js +2 -0
- package/dist/cdn/RADWN4ZP.js +2 -0
- package/dist/cdn/RU2T7GUX.js +2 -0
- package/dist/cdn/S6OYR4VI.js +156 -0
- package/dist/cdn/T2GJLEYV.js +2 -0
- package/dist/cdn/TKYI5QRL.js +2 -0
- package/dist/cdn/{5SFZS2RD.js → TQXLSW4A.js} +2 -2
- package/dist/cdn/{NJJYZP3R.js → U6FBRUM4.js} +1 -1
- package/dist/cdn/UIXX3XEN.js +2 -0
- package/dist/cdn/UPWAOZXQ.js +2 -0
- package/dist/cdn/{5SF6DEMO.js → VNJMTA6O.js} +1 -1
- package/dist/cdn/VOKXKU7M.js +56 -0
- package/dist/cdn/{33BF35AO.js → VYTYVWR6.js} +4 -4
- package/dist/cdn/WMZ24LWS.js +2 -0
- package/dist/cdn/{JYVBCHR6.js → WP7ORLSB.js} +1 -1
- package/dist/cdn/WS3T73IY.js +2 -0
- package/dist/cdn/{UZL6UVE4.js → ZLWWWTH4.js} +1 -1
- package/dist/cdn/{PAUIFUMO.js → ZQMBJ6MI.js} +1 -1
- package/dist/cdn/agent-utils/index.js +1 -1
- package/dist/cdn/agent-utils/middlewares/humanInTheLoop.js +1 -1
- package/dist/cdn/agent-utils/middlewares/middleware.js +1 -1
- package/dist/cdn/agent-utils/middlewares/trace.js +1 -1
- package/dist/cdn/index.js +1 -1
- package/dist/chunks/adapter.js +938 -1938
- package/dist/chunks/adapter10.js +21 -0
- package/dist/chunks/adapter11.js +30 -0
- package/dist/chunks/adapter12.js +22 -0
- package/dist/chunks/adapter13.js +22 -0
- package/dist/chunks/adapter14.js +109 -0
- package/dist/chunks/adapter15.js +40 -0
- package/dist/chunks/adapter16.js +154 -0
- package/dist/chunks/adapter17.js +141 -0
- package/dist/chunks/adapter18.js +127 -0
- package/dist/chunks/adapter2.js +52 -0
- package/dist/chunks/adapter3.js +30 -0
- package/dist/chunks/adapter4.js +50 -0
- package/dist/chunks/adapter5.js +27 -0
- package/dist/chunks/adapter6.js +24 -0
- package/dist/chunks/adapter7.js +26 -0
- package/dist/chunks/adapter8.js +21 -0
- package/dist/chunks/adapter9.js +42 -0
- package/dist/chunks/arcgisKnowledgeGraph.js +5 -5
- package/dist/chunks/dataExplorationGraph.js +30 -27
- package/dist/chunks/fetchAgentContext.js +13 -0
- package/dist/chunks/fetchService.js +10 -0
- package/dist/chunks/formatFeatureAttributes.js +132 -0
- package/dist/chunks/generateLayerDescriptions.js +145 -148
- package/dist/chunks/helpGraph.js +11 -9
- package/dist/chunks/layerStylingGraph.js +22 -21
- package/dist/chunks/mergeWhereClauses.js +15 -0
- package/dist/chunks/navigationGraph.js +68 -57
- package/dist/chunks/types.js +59 -0
- package/dist/components/arcgis-assistant-agent/customElement.js +404 -279
- package/dist/components/arcgis-assistant-data-exploration-agent/customElement.js +15 -5
- package/dist/components/arcgis-assistant-help-agent/customElement.js +21 -5
- package/dist/components/arcgis-assistant-knowledge-agent/customElement.js +39 -22
- package/dist/components/arcgis-assistant-layer-styling-agent/customElement.js +22 -5
- package/dist/components/arcgis-assistant-navigation-agent/customElement.js +13 -5
- package/dist/docs/api.json +1 -1
- package/dist/docs/docs.json +1 -1
- package/dist/docs/web-types.json +1 -1
- package/dist/types/stencil.d.ts +2 -2
- package/dist/utils/index.d.ts +4 -5
- package/dist/utils/index.js +19 -20
- package/package.json +8 -8
- package/dist/cdn/55M2HE4U.js +0 -2
- package/dist/cdn/5RZGG4F2.js +0 -2
- package/dist/cdn/BAB3MK4Y.js +0 -2
- package/dist/cdn/BMBV6Y2A.js +0 -2
- package/dist/cdn/D3RKQSWS.js +0 -2
- package/dist/cdn/E7KEOJZG.js +0 -208
- package/dist/cdn/IGQFAL3H.js +0 -2
- package/dist/cdn/LUY6V4TP.js +0 -181
- package/dist/cdn/NSXX2KYS.js +0 -2
- package/dist/cdn/OFRFP4BX.js +0 -2
- package/dist/cdn/OUFGJV3R.js +0 -2
- package/dist/cdn/RWM5T4XB.js +0 -180
- package/dist/cdn/SRFLL6ET.js +0 -2
- package/dist/cdn/WDOM6Z5O.js +0 -18
- package/dist/cdn/WZFC5HUX.js +0 -56
- package/dist/cdn/Z4XUJQ2I.js +0 -36
- package/dist/cdn/ZJEWP2ND.js +0 -44
|
@@ -0,0 +1,156 @@
|
|
|
1
|
+
/* COPYRIGHT Esri - https://js.arcgis.com/5.2/LICENSE.txt */
|
|
2
|
+
import i from"./T2GJLEYV.js";import h from"./Q4IQUEZN.js";import f from"./WS3T73IY.js";import e from"./4MFEKBKL.js";import c from"./AT4XVTJR.js";import{e as R,f as le}from"./7M6VKBTK.js";import{a as de}from"./BS2PFNU4.js";import{a as ue}from"./UIXX3XEN.js";import a from"./KA3FF3ZO.js";import{a as b,b as T}from"./7VAQUCBU.js";import{Fa as se,Sa as A,g as ne,j as D,k as P,ka as y,y as ie}from"./EWLXNGKH.js";import{Dc as g,S as $,W as B,fa as N}from"./AI6DYOKR.js";import{a as d}from"./VXFQANGJ.js";export default $arcgis.t(([ve,_,Se,,_e,,{createRenderer:Fe},{getSchemesByTag:Le,getSchemes:Qe},{getBackgroundColorTheme:xe},{createAgeRenderer:Ge,createContinuousRenderer:Ve},{getSchemesByTag:re},{createContinuousRenderer:Be},{createRenderer:Ke},{getSchemesByTag:Ue},{createRenderer:He},{getSchemesByTag:We},{createRenderer:Je},{getSchemesByTag:Ze},{createRenderer:Ye},{getSchemesByTag:Xe},{createAgeRenderer:et,createContinuousRenderer:tt},{createRenderer:rt},{getSchemesByTag:ot},at,ke,,{fetchKnowledgeGraph:Ee,executeQueryStreaming:nt,executeSearchStreaming:it},st,{getBindParametersFromCypherQuery:lt},pe,{o:ce},fe,ye,he,me])=>{var Te=e=>Array.isArray(e)&&e.every($),De=e=>typeof e=="object"&&e!=null&&"messages"in e&&Te(e.messages),Pe=e=>typeof e=="object"&&e!=null&&"lg_tool_call"in e,O=class extends se{tools;handleToolErrors=!0;trace=!1;constructor(e,t){let{name:r,tags:o,handleToolErrors:a}=t??{};super({name:r,tags:o,func:(i,s)=>this.run(i,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"},i={...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,i);return $(s)&&s.getType()==="tool"||P(s)?s:new B({status:"success",name:o.name,content:typeof s=="string"?s:JSON.stringify(s),tool_call_id:e.id})}catch(a){if(!this.handleToolErrors||ie(a))throw a;return new B({status:"error",content:`Error: ${a.message}
|
|
3
|
+
Please fix your mistakes.`,name:e.name,tool_call_id:e.id??""})}}async run(e,t){let r;if(Pe(e)){let{lg_tool_call:i,...s}=e;r=[await this.runTool(i,t,s)]}else{let i;if(Te(e))i=e;else if(De(e))i=e.messages;else throw new Error("ToolNode only accepts BaseMessage[] or { messages: BaseMessage[] } as input.");let s=new Set(i.filter(c=>c.getType()==="tool").map(c=>c.tool_call_id)),n;for(let c=i.length-1;c>=0;c-=1){let l=i[c];if(N(l)){n=l;break}}if(n==null||!N(n))throw new Error("ToolNode only accepts AIMessages as input.");r=await Promise.all(n.tool_calls?.filter(c=>c.id==null||!s.has(c.id)).map(c=>this.runTool(c,t,e))??[])}if(!r.some(P))return Array.isArray(e)?r:{messages:r};let o=[],a=null;for(let i of r)P(i)?i.graph===D.PARENT&&Array.isArray(i.goto)&&i.goto.every(s=>ne(s))?a?a.goto.push(...i.goto):a=new D({graph:D.PARENT,goto:i.goto}):o.push(i):o.push(Array.isArray(e)?[i]:{messages:[i]});return a&&o.push(a),o}};var zo=y.Root({llmInputMessages:y({reducer:(e,t)=>A([],t),default:()=>[]})});var I=(e,t)=>t??e,La=y.Root({...le(),intent:y({reducer:I}),vectorSearchLayerResults:y({reducer:I,default:()=>[]}),vectorSearchFieldResults:y({reducer:I}),navigationInternalState:y({reducer:I,default:()=>({toolCallMessage:void 0})})}),Me=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 L(e){let t=Object.entries(Me).find(([r])=>r.endsWith(`/${e}.md`));if(!t)throw new Error(`Prompt not found: ${e}
|
|
4
|
+
Available prompts:
|
|
5
|
+
${Object.keys(Me).join(`
|
|
6
|
+
`)}`);return await t[1]()}var ct=(e,t=300)=>{let r=e.replace(/\s+/gu," ").replace(/[*_`#>\-]/gu,"").trim();return r.length>t?`${r.slice(0,t)}...`:r},Qa=(e,t)=>(r,o)=>{let a=o?.configurable?.services;for(let i of e)if(!a?.[i])throw new Error(`${t} requires services.${i} to be available.`);return r};async function dt(e){let{fields:t,layer:r,view:o,styleName:a,colorSchemeTags:i}=e,s;return i?s=Le({basemapTheme:await xe(o),geometryType:r.geometryType,includedTags:i,numColors:Math.min(t.length,8)})[0]:s=Qe({basemapTheme:await xe(o),geometryType:r.geometryType,numColors:Math.min(t.length,8)}).primaryScheme,{layer:r,view:o,attributes:t.map(n=>({field:n,label:r.fields.find(c=>c.name===n)?.alias??""})).slice(0,8),outlineOptimizationEnabled:!0,sizeOptimizationEnabled:!0,includeSizeVariable:a.includes("Size"),pieChartScheme:s}}async function ut(e){return await Fe(e)}async function pt({arcgisMap:e,arcgisMapView:t,layerId:r,fields:o,colorSchemes:a,includeSize:i}){let s=t,n=e?.allLayers.find(l=>l.id===r);if(!n)return`Could not find layer for id: ${r}`;let c={styleName:i?"chart-size":"chart",fields:o,layer:n,view:s,colorSchemeTags:a};try{let l=await dt(c),u=await ut(l);return n.renderer=u.renderer,n.visible=!0,`Chart renderer applied to layer: ${n.title??n.id} using fields ${o.join(", ")}`}catch(l){return`Error applying chart renderer: ${l instanceof Error?l.message:String(l)}`}}var mt=["mapView"];function v(e){let t=e?.configurable?.context;if(!t||typeof t!="object")throw new Error("LayerStylingAgent context missing");let r=mt.filter(o=>!(o in t));if(r.length)throw new Error(`LayerStylingAgent context missing: ${r.join(", ")}`);return t}async function ht({layerId:e,fields:t,colorSchemes:r,includeSize:o},a){let{mapView:i}=v(a);return await T({type:"show-legend",data:{layerIds:[e]}},a),await pt({arcgisMap:i.map,arcgisMapView:i,layerId:e,fields:t,colorSchemes:r,includeSize:o})}var yt=d.object({layerId:d.string().describe("The id of the layer to apply the chart renderer to"),fields:d.array(d.string()).describe("The fields to use for the chart renderer (multiple numeric fields)"),colorSchemes:d.array(d.string()).optional().describe("Optional color scheme tags to use"),includeSize:d.boolean().optional().describe("Whether to vary the chart size (chart-size)")}),Ga=g(ht,{name:"chart",description:`Label: Charts
|
|
7
|
+
Description: Show the values of two or more categories as a proportion of the total using a pie chart.
|
|
8
|
+
Keywords: pie, chart, all categories, breakdown, proportion
|
|
9
|
+
Example: Show the total number of homes built in each decade using a pie chart for each feature.
|
|
10
|
+
Fields: This style requires 2-8 number fields.
|
|
11
|
+
|
|
12
|
+
Label: Charts and Size
|
|
13
|
+
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.
|
|
14
|
+
Keywords: pie, chart, all categories, breakdown, proportion, total, amount, how much, sum, graduated size, proportional size
|
|
15
|
+
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.
|
|
16
|
+
Fields: This style requires 2-8 number fields.`,schema:yt});function ft(e){let{fields:t,layer:r,view:o,theme:a,colorSchemeTags:i}=e,s=t[0],n;return i&&(n=re({geometryType:r.geometryType,includedTags:i,theme:a||"high-to-low"})[0]),{layer:r,view:o,startTime:s,endTime:new Date,theme:a,sizeOptimizationEnabled:!0,outlineOptimizationEnabled:!0,colorScheme:n}}async function gt(e){return await Ge(e)}async function wt({arcgisMap:e,arcgisMapView:t,layerId:r,fields:o,colorSchemes:a,theme:i}){let s=t,n=e?.allLayers.find(l=>l.id===r);if(!n)return`Could not find layer for id: ${r}`;let c={styleName:"color-age",fields:o,layer:n,view:s,colorSchemeTags:a,theme:i};try{let l=ft(c),u=await gt(l);return n.renderer=u.renderer,n.visible=!0,`Color-age renderer applied to layer: ${n.title??n.id} using fields ${o.join(", ")}`}catch(l){return`Error applying color-age renderer: ${l instanceof Error?l.message:String(l)}`}}async function bt({layerId:e,fields:t,colorSchemes:r,theme:o},a){let{mapView:i}=v(a);return await T({type:"show-legend",data:{layerIds:[e]}},a),await wt({arcgisMap:i.map,arcgisMapView:i,layerId:e,fields:t,colorSchemes:r,theme:o})}var Tt=d.object({layerId:d.string().describe("The id of the layer to apply the color-age renderer to"),fields:d.array(d.string()).describe("The field(s) to use for the color-age renderer (temporal/date data)"),colorSchemes:d.array(d.string()).optional().describe("Optional color scheme tags to use"),theme:d.enum(["above-and-below","above","below","centered-on","extremes","high-to-low"]).optional().describe("Optional theme for the color ramp")}),Va=g(bt,{name:"color-age",description:`Label: Age (color)
|
|
17
|
+
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.
|
|
18
|
+
Keywords: since, age, how old, how long
|
|
19
|
+
Example: Show the age of each feature based on its reported date.
|
|
20
|
+
Fields: This style requires at least one field with a date type.`,schema:Tt});function vt(e){let{fields:t,layer:r,view:o,colorSchemeTags:a}=e,{theme:i}=e,s=t[1],n=t[0],c;return a&&(c=re({geometryType:r.geometryType,includedTags:a,theme:i||"high-to-low"})[0]),{layer:r,view:o,field:n,normalizationField:s,theme:i,sizeOptimizationEnabled:!0,outlineOptimizationEnabled:!0,colorScheme:c}}async function St(e){return await Ve(e)}async function xt({arcgisMap:e,arcgisMapView:t,layerId:r,fields:o,colorSchemes:a,theme:i}){let s=t,n=e?.allLayers.find(l=>l.id===r);if(!n)return`Could not find layer for id: ${r}`;let c={styleName:"color",fields:o,layer:n,view:s,colorSchemeTags:a,theme:i};try{let l=vt(c),u=await St(l);return n.renderer=u.renderer,n.visible=!0,`Color renderer applied to layer: ${n.title??n.id} using fields ${o.join(", ")}`}catch(l){return`Error applying color renderer: ${l instanceof Error?l.message:String(l)}`}}async function Et({layerId:e,fields:t,colorSchemes:r,theme:o},a){let{mapView:i}=v(a);return await T({type:"show-legend",data:{layerIds:[e]}},a),await xt({arcgisMap:i.map,arcgisMapView:i,layerId:e,fields:t,colorSchemes:r,theme:o})}var Mt=d.object({layerId:d.string().describe("The id of the layer to apply the color renderer to"),fields:d.array(d.string()).describe("The field(s) to use for the color renderer"),colorSchemes:d.array(d.string()).optional().describe("Optional color scheme tags to use"),theme:d.enum(["above-and-below","above","below","centered-on","extremes","high-to-low"]).optional().describe("Optional theme for the color ramp")}),Ba=g(Et,{name:"color",description:`Label: Counts and Amounts (color)
|
|
21
|
+
Description: Vary color along a continuous color ramp to represent numeric or ranked data.
|
|
22
|
+
Keywords: graduated color, choropleth, continuous color, hue, color, gradation, saturation, lightness, percent, rate, ratio, index, how much, increase, decrease
|
|
23
|
+
Example: Color each feature based on the population density.
|
|
24
|
+
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:Mt});function _t(e){let{fields:t,layer:r,view:o,colorSchemeTags:a,theme:i}=e,s,n,c=t[0];return a&&(n=re({geometryType:r.geometryType,includedTags:a,theme:i||"high-to-low"})[0]),{layer:r,view:o,field:c,normalizationField:s,theme:i,colorOptions:{colorScheme:n}}}async function kt(e){return await Be(e)}async function $t({arcgisMap:e,arcgisMapView:t,layerId:r,fields:o,colorSchemes:a,theme:i}){let s=t,n=e?.allLayers.find(l=>l.id===r);if(!n)return`Could not find layer for id: ${r}`;let c={styleName:"color-size-univariate",fields:o,layer:n,view:s,colorSchemeTags:a,theme:i};try{let l=_t(c),u=await kt(l);return n.renderer=u.renderer,n.visible=!0,`Color-size-univariate renderer applied to layer: ${n.title??n.id} using fields ${o.join(", ")}`}catch(l){return`Error applying color-size-univariate renderer: ${l instanceof Error?l.message:String(l)}`}}async function Nt({layerId:e,fields:t,colorSchemes:r,theme:o},a){let{mapView:i}=v(a);return await T({type:"show-legend",data:{layerIds:[e]}},a),await $t({arcgisMap:i.map,arcgisMapView:i,layerId:e,fields:t,colorSchemes:r,theme:o})}var At=d.object({layerId:d.string().describe("The id of the layer to apply the color-size univariate renderer to"),fields:d.array(d.string()).describe("The fields to use for the color-size univariate renderer"),colorSchemes:d.array(d.string()).optional().describe("Optional color scheme tags to use"),theme:d.enum(["above-and-below","above","below","centered-on","extremes","high-to-low"]).optional().describe("Optional theme for the color and size ramps")}),Ka=g(Nt,{name:"color-size-univariate",description:`Label: Color and Size (univariate)
|
|
25
|
+
Description: Vary symbol size and color based on the values of two numeric attributes.
|
|
26
|
+
Keywords: continuous color, hue, color, size, gradation, saturation, lightness, percent, rate, ratio, index, how much, increase, decrease, amount
|
|
27
|
+
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.
|
|
28
|
+
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:At});function Rt(e){let{fields:t,layer:r,view:o,colorSchemeTags:a}=e,i;return a&&(i=Ue({includedTags:a,numColors:Math.min(t.length,8)})[0]),{layer:r,view:o,legendOptions:{unit:"units"},attributes:t.map(s=>({field:s,label:r.fields.find(n=>n.name===s)?.alias??""})).slice(0,8),outlineOptimizationEnabled:!0,dotDensityScheme:i}}async function It(e){return await Ke(e)}async function Ct({arcgisMap:e,arcgisMapView:t,layerId:r,fields:o,colorSchemes:a}){let i=t,s=e?.allLayers.find(c=>c.id===r);if(!s)return`Could not find layer for id: ${r}`;let n={styleName:"dot-density",fields:o,layer:s,view:i,colorSchemeTags:a};try{let c=Rt(n),l=await It(c);return s.renderer=l.renderer,s.visible=!0,`Dot Density renderer applied to layer: ${s.title??s.id} using fields ${o.join(", ")}`}catch(c){return`Error applying dot density renderer: ${c instanceof Error?c.message:String(c)}`}}async function qt({layerId:e,fields:t,colorSchemes:r},o){let{mapView:a}=v(o);return await T({type:"show-legend",data:{layerIds:[e]}},o),await Ct({arcgisMap:a.map,arcgisMapView:a,layerId:e,fields:t,colorSchemes:r})}var zt=d.object({layerId:d.string().describe("The id of the layer to apply the dot density renderer to"),fields:d.array(d.string()).describe("The field(s) to use for the dot density renderer (population or count data)"),colorSchemes:d.array(d.string()).optional().describe("Optional color scheme tags to use")}),Ua=g(qt,{name:"dot-density",description:`Dot Density
|
|
29
|
+
Use dot density to visualize the distribution of one attribute or compare the density of multiple attributes. This is only valid for polygon layers.
|
|
30
|
+
**Use cases:**
|
|
31
|
+
- Population distribution visualization
|
|
32
|
+
- Comparing multiple categories within areas
|
|
33
|
+
- Showing spatial distribution patterns
|
|
34
|
+
**Examples:**
|
|
35
|
+
- Show the density of the population based on various race/ethnic groups
|
|
36
|
+
- Visualize distribution of different crops across regions
|
|
37
|
+
- Display demographic patterns within census tracts
|
|
38
|
+
**Fields:** Requires 2-8 number fields.
|
|
39
|
+
**Keywords:** density, how much, how many, total, number, amount`,schema:zt});function Dt(e){let{fields:t,layer:r,view:o,colorSchemeTags:a}=e,i,s=t[0];return a&&(i=We({includedTags:a,basemap:o.map?.basemap||"topo"})[0]),{layer:r,view:o,field:s,heatmapScheme:i}}async function Pt(e){return await He(e)}async function Ot({arcgisMap:e,arcgisMapView:t,layerId:r,fields:o,colorSchemes:a}){let i=t,s=e?.allLayers.find(c=>c.id===r);if(!s)return`Could not find layer for id: ${r}`;let n={styleName:"heatmap",fields:o,layer:s,view:i,colorSchemeTags:a};try{let c=Dt(n),l=await Pt(c);return s.renderer=l.renderer,s.visible=!0,`Heatmap renderer applied to layer: ${s.title??s.id} using fields ${o.join(", ")}`}catch(c){return`Error applying heatmap renderer: ${c instanceof Error?c.message:String(c)}`}}async function jt({layerId:e,fields:t,colorSchemes:r},o){let{mapView:a}=v(o);return await T({type:"show-legend",data:{layerIds:[e]}},o),await Ot({arcgisMap:a.map,arcgisMapView:a,layerId:e,fields:t,colorSchemes:r})}var Ft=d.object({layerId:d.string().describe("The id of the layer to apply the heatmap renderer to"),fields:d.array(d.string()).describe("The field(s) to use for the heatmap renderer (typically point density)"),colorSchemes:d.array(d.string()).optional().describe("Optional color scheme tags to use")}),Ha=g(jt,{name:"heatmap",description:`Label: Heat Map
|
|
40
|
+
Description: Show areas of high density with colors that appear to glow hotter. This is only valid for point layers.
|
|
41
|
+
Keywords: density, heatmap, hot spots, pattern, cluster
|
|
42
|
+
Example: Create a heatmap
|
|
43
|
+
Fields: This typically requires zero or one field of type number.`,schema:Ft});function Lt(e){let{fields:t,layer:r,view:o,styleName:a,colorSchemeTags:i}=e,s;return i&&(s=Ze({geometryType:r.geometryType,includedTags:i,numColors:Math.min(t.length,10)})[0]),{layer:r,view:o,fields:t.map(n=>({name:n})).slice(0,9),outlineOptimizationEnabled:!0,sizeOptimizationEnabled:!0,includeSizeVariable:a.includes("Size"),predominanceScheme:s}}async function Qt(e){return await Je(e)}async function Gt({arcgisMap:e,arcgisMapView:t,layerId:r,fields:o,colorSchemes:a,includeSize:i}){let s=t,n=e?.allLayers.find(l=>l.id===r);if(!n)return`Could not find layer for id: ${r}`;let c={styleName:i?"predominance-size":"predominance",fields:o,layer:n,view:s,colorSchemeTags:a};try{let l=Lt(c),u=await Qt(l);return n.renderer=u.renderer,n.visible=!0,`Predominance renderer applied to layer: ${n.title??n.id} using fields ${o.join(", ")}`}catch(l){return`Error applying predominance renderer: ${l instanceof Error?l.message:String(l)}`}}async function Vt({layerId:e,fields:t,colorSchemes:r,includeSize:o},a){let{mapView:i}=v(a);return await T({type:"show-legend",data:{layerIds:[e]}},a),await Gt({arcgisMap:i.map,arcgisMapView:i,layerId:e,fields:t,colorSchemes:r,includeSize:o})}var Bt=d.object({layerId:d.string().describe("The id of the layer to apply the predominance renderer to"),fields:d.array(d.string()).describe("The fields to use for the predominance renderer (competing categories)"),colorSchemes:d.array(d.string()).optional().describe("Optional color scheme tags to use"),includeSize:d.boolean().optional().describe("Whether to include size visualization (predominance-size)")}),Wa=g(Vt,{name:"predominance",description:`Label: Predominant category
|
|
44
|
+
Description: Compare attributes that share a common subject and unit of measurement to see which has the highest value.
|
|
45
|
+
Keywords: predominant, winner, won, competing, most, most common, most frequent, dominant, prevalent, top
|
|
46
|
+
Example: Using fields for Corn Acres, Wheat Acres, and Cotton Acres, show the predominant crop harvested in each area.
|
|
47
|
+
Fields: This style relies on 2-10 number fields.
|
|
48
|
+
|
|
49
|
+
Label: Predominant category and Size
|
|
50
|
+
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.
|
|
51
|
+
Keywords: predominant, winner, won, competing, most, most common, most frequent, dominant, prevalent, top, amount, total, how much, proportional size, graduated size, sum
|
|
52
|
+
Example: Show the predominant crop in each area and vary the size of each symbol based on the total of all categories.
|
|
53
|
+
Fields: This style relies on 2-10 number fields.`,schema:Bt});function Kt(e){let{fields:t,layer:r,view:o,colorSchemeTags:a}=e,i,s={field:t[0]},n={field:t[1]};return a&&(i=Xe({geometryType:r.geometryType,includedTags:a})[0]),{layer:r,view:o,field1:s,field2:n,outlineOptimizationEnabled:!0,sizeOptimizationEnabled:!0,relationshipScheme:i}}async function Ut(e){return await Ye(e)}async function Ht({arcgisMap:e,arcgisMapView:t,layerId:r,fields:o,colorSchemes:a}){let i=t,s=e?.allLayers.find(c=>c.id===r);if(!s)return`Could not find layer for id: ${r}`;let n={styleName:"relationship",fields:o,layer:s,view:i,colorSchemeTags:a};try{let c=Kt(n),l=await Ut(c);return s.renderer=l.renderer,s.visible=!0,`Relationship renderer applied to layer: ${s.title??s.id} using fields ${o.join(", ")}`}catch(c){return`Error applying relationship renderer: ${c instanceof Error?c.message:String(c)}`}}async function Wt({layerId:e,fields:t,colorSchemes:r},o){let{mapView:a}=v(o);return await T({type:"show-legend",data:{layerIds:[e]}},o),await Ht({arcgisMap:a.map,arcgisMapView:a,layerId:e,fields:t,colorSchemes:r})}var Jt=d.object({layerId:d.string().describe("The id of the layer to apply the relationship renderer to"),fields:d.array(d.string()).describe("The two fields to use for the relationship renderer (bivariate visualization)"),colorSchemes:d.array(d.string()).optional().describe("Optional color scheme tags to use")}),Ja=g(Wt,{name:"relationship",description:`Label: Relationship
|
|
54
|
+
Description: Overlays two color ramps to represent the relationship between two numeric attributes.
|
|
55
|
+
Keywords: relationship, correlation, compare, related, bivariate choropleth, bivariate color
|
|
56
|
+
Example: Show the relationship between tree height and carbon storage
|
|
57
|
+
Fields: This style requires two number fields.`,schema:Jt});function Zt(e){let{fields:t,layer:r,view:o,theme:a}=e,i=t[0];return{layer:r,view:o,startTime:i,endTime:new Date,theme:a,sizeOptimizationEnabled:!0,outlineOptimizationEnabled:!0}}async function Yt(e){return await et(e)}async function Xt({arcgisMap:e,arcgisMapView:t,layerId:r,fields:o,colorSchemes:a,theme:i}){let s=t,n=e?.allLayers.find(l=>l.id===r);if(!n)return`Could not find layer for id: ${r}`;let c={styleName:"size-age",fields:o,layer:n,view:s,colorSchemeTags:a,theme:i};try{let l=Zt(c),u=await Yt(l);return n.renderer=u.renderer,n.visible=!0,`Size-age renderer applied to layer: ${n.title??n.id} using fields ${o.join(", ")}`}catch(l){return`Error applying size-age renderer: ${l instanceof Error?l.message:String(l)}`}}async function er({layerId:e,fields:t,colorSchemes:r,theme:o},a){let{mapView:i}=v(a);return await T({type:"show-legend",data:{layerIds:[e]}},a),await Xt({arcgisMap:i.map,arcgisMapView:i,layerId:e,fields:t,colorSchemes:r,theme:o})}var tr=d.object({layerId:d.string().describe("The id of the layer to apply the size-age renderer to"),fields:d.array(d.string()).describe("The field(s) to use for the size-age renderer (temporal data with size)"),colorSchemes:d.array(d.string()).optional().describe("Optional color scheme tags to use"),theme:d.enum(["above-and-below","above","below","centered-on","extremes","high-to-low"]).optional().describe("Optional theme for the size ramp")}),Za=g(er,{name:"size-age",description:`Label: Age (size)
|
|
58
|
+
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.
|
|
59
|
+
Keywords: since, age, how old, how long
|
|
60
|
+
Example: Change the size of features so older features are larger than new features.
|
|
61
|
+
Fields: This style requires at least one field with a date type.`,schema:tr});function rr(e){let{fields:t,layer:r,view:o}=e,{theme:a}=e,i=t[1],s=t[0];return{layer:r,view:o,field:s,normalizationField:i,theme:a,sizeOptimizationEnabled:!0,outlineOptimizationEnabled:!0}}async function or(e){return await tt(e)}async function ar({arcgisMap:e,arcgisMapView:t,layerId:r,fields:o,colorSchemes:a,theme:i}){let s=t,n=e?.allLayers.find(l=>l.id===r);if(!n)return`Could not find layer for id: ${r}`;let c={styleName:"size",fields:o,layer:n,view:s,colorSchemeTags:a,theme:i};try{let l=rr(c),u=await or(l);return n.renderer=u.renderer,n.visible=!0,`Size renderer applied to layer: ${n.title??n.id} using fields ${o.join(", ")}`}catch(l){return`Error applying size renderer: ${l instanceof Error?l.message:String(l)}`}}async function nr({layerId:e,fields:t,colorSchemes:r,theme:o},a){let{mapView:i}=v(a);return await T({type:"show-legend",data:{layerIds:[e]}},a),await ar({arcgisMap:i.map,arcgisMapView:i,layerId:e,fields:t,colorSchemes:r,theme:o})}var ir=d.object({layerId:d.string().describe("The id of the layer to apply the size renderer to"),fields:d.array(d.string()).describe("The field(s) to use for the size renderer (numeric data)"),colorSchemes:d.array(d.string()).optional().describe("Optional color scheme tags to use"),theme:d.enum(["above-and-below","above","below","centered-on","extremes","high-to-low"]).optional().describe("Optional theme for the size ramp")}),Ya=g(nr,{name:"size",description:`Label: Counts and Amounts (size)
|
|
62
|
+
Description: Vary symbol sizes along a continuous ramp to represent numeric or ranked data.
|
|
63
|
+
Keywords: graduated size, proportional size, how much, total, number, amount, size
|
|
64
|
+
Example: Vary the size of each point based on the total population.
|
|
65
|
+
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.
|
|
66
|
+
|
|
67
|
+
Label: Continuous Timeline (size)
|
|
68
|
+
Description: Vary symbol sizes along a continuous ramp to represent dates.
|
|
69
|
+
Keywords: graduated size, proportional size, classed size, how much, total, number, when
|
|
70
|
+
Example: Vary the size of each feature based on the date a ticket was completed.
|
|
71
|
+
Fields: This style requires a single field with a date type.`,schema:ir});function sr(e){let{fields:t,layer:r,view:o,colorSchemeTags:a}=e,i=t[0],s=t[1],n=t[2],c;return a&&(c=ot({geometryType:r.geometryType,includedTags:a})[0]),{layer:r,view:o,field:i,field2:s,field3:n,outlineOptimizationEnabled:!0,sizeOptimizationEnabled:!0,typeScheme:c}}async function lr(e){return await rt(e)}async function cr({arcgisMap:e,arcgisMapView:t,layerId:r,fields:o,colorSchemes:a,theme:i}){let s=t,n=e?.allLayers.find(l=>l.id===r);if(!n)return`Could not find layer for id: ${r}`;let c={styleName:"type",fields:o,layer:n,view:s,colorSchemeTags:a,theme:i};try{let l=sr(c),u=await lr(l);return n.renderer=u.renderer,n.visible=!0,`Type renderer applied to layer: ${n.title??n.id} using fields ${o.join(", ")}`}catch(l){return`Error applying type renderer: ${l instanceof Error?l.message:String(l)}`}}async function dr({layerId:e,fields:t,colorSchemes:r,theme:o},a){let{mapView:i}=v(a);return await T({type:"show-legend",data:{layerIds:[e]}},a),await cr({arcgisMap:i.map,arcgisMapView:i,layerId:e,fields:t,colorSchemes:r,theme:o})}var ur=d.object({layerId:d.string().describe("The id of the layer to apply the type renderer to"),fields:d.array(d.string()).describe("The field(s) to use for the type renderer (categorical data)"),colorSchemes:d.array(d.string()).optional().describe("Optional color scheme tags to use"),theme:d.enum(["above-and-below","above","below","centered-on","extremes","high-to-low"]).optional().describe("Optional theme for the color scheme")}),Xa=g(dr,{name:"type",description:`Label: Types (unique symbols)
|
|
72
|
+
Description: Represent features as categories with different symbol colors or shapes. Examples include type of tree, road class, or province name.
|
|
73
|
+
Keywords: categorical, category, type, unique, discrete, point of interest, region, group
|
|
74
|
+
Example: Color each feature based on the region it belongs to
|
|
75
|
+
Fields: This style requires a single field which may be a string, number, or date type. It is usually a string.`,schema:ur}),en=y.Root({...R(),vectorSearchLayerIds:y(),vectorSearchFieldResults:y(),layerFieldInfo:y(),selectedLayerId:y()}),tn=y.Root({...R(),vectorSearchLayerIds:y(),vectorSearchFieldResults:y(),layerFieldInfo:y(),queryResponse:y(),dataExplorationMessages:y({reducer:A,default:()=>[]})}),pr=[me,he,ye,fe],rn=[pe,ue,de],mr=new O(pr,{handleToolErrors:!1});async function on(e,t){let{messages:r}=await mr.invoke({messages:e.dataExplorationMessages},t),o=[],a=[];for(let i of r){let s=i.content,n;typeof s!="string"&&(n={tool:i.name??"unknown",layerName:"unknown",summary:"Query failed",details:{error:"Skipping non-string tool output:",raw:s}});try{typeof s=="string"?n=JSON.parse(s):n={tool:i.name??"unknown",layerName:"unknown",summary:"Query failed",details:{error:"Invalid tool output type",raw:s}}}catch{n={tool:i.name??"unknown",layerName:"unknown",summary:"Query failed",details:{error:s}}}o.push(n),n.details&&typeof n.details=="object"&&"error"in n.details?a.push(`- ${n.tool}: Error - ${String(n.details.error)}`):a.push(`- ${n.layerName}: ${n.summary}`)}return await b({text:`Finished executing layer query tool: ${a.join(", ")}`},t),{...e,dataExplorationMessages:[...e.dataExplorationMessages,...r],queryResponse:o,status:"success",summary:a.length>0?ct(a.join(`
|
|
76
|
+
`)):"Query executed."}}var an=y.Root({...R(),helpInternalState:y({reducer:I,default:()=>({toolCallMessage:void 0})})}),nn=y.Root({...R(),intent:y({reducer:(e,t)=>t}),arcgisKnowledgeMessages:y({reducer:A,default:()=>[]}),arcgisKnowledgeToolResult:y({reducer:(e,t)=>t,default:()=>null})});function oe(e){let t=e.map?.allLayers.filter(r=>r.type==="knowledge-graph");if(!t||t?.length!==1)throw new Error("The Knowledge Agent currently only supports maps with exactly one Knowledge Graph Layer.")}function x(e){return!!e?.map&&!("activeLinkChartLayer"in e.map)}async function Q(e){!e||x(e)||!e.map?.diagramNodesExtent||await e.goTo(e.map.diagramNodesExtent)}function q(e){let t=e?.configurable?.context;if(!t||typeof t!="object")throw new Error("ArcgisKnowledgeAgent context missing");if(!("view"in t))throw new Error("View context missing");let r=t.view;return r.map&&!("activeLinkChartLayer"in r.map)&&oe(r),{view:r}}function sn(e){let t=e?.configurable?.context;if($e(e)==="knowledgeGraph")return"knowledgeGraph";let r=t.view;return x(r)?(oe(r),"map"):"linkChart"}async function z(e){let t=e?.configurable?.context;if($e(e)==="knowledgeGraph")return t;{let r=t.view.map;if(r&&"activeLinkChartLayer"in r){let o=r.knowledgeGraph?.url;if(!o)throw new Error("Knowledge graph url missing from link chart.");return{knowledgeGraph:await Ee(o)}}else{oe(t.view);let o=(t.view.map?.allLayers.find(a=>a.type==="knowledge-graph")).url;if(!o)throw new Error("Knowledge graph url missing from map.");return{knowledgeGraph:await Ee(o)}}}}function $e(e){let t=e?.configurable?.context;if(!t||typeof t!="object")throw new Error("ArcgisKnowledgeAgent context missing");if("knowledgeGraph"in t&&"view"in t)throw new Error("Knowledge Graph context should only have a view or knowledgeGraph, but never both.");if("knowledgeGraph"in t)return"knowledgeGraph";if("view"in t)return"view";throw new Error("ArcgisKnowledgeAgent context must have either a view or knowledgeGraph property.")}var H=class{constructor(t){this.dataModel=t,this.kind="GraphQueryGenerationRequest",this.explainQuery=!0,this.schemaInformation=W.fromDataModel(t)}},W=class e{constructor(){this.schemaType="ArcgisGraphSchema",this.entityTypes=[],this.relationshipTypes=[],this.identifierInfo={mappingInfo:{identifierMapsTo:"UniformPropertyIdentifier",identifierPropertyName:"globalid"}}}static fromDataModel(t){let r=new e;for(let o of t.entityTypes)r.entityTypes.push(C.fromEntityType(o));for(let o of t.relationshipTypes)r.relationshipTypes.push(J.fromRelationshipType(o));return r.identifierInfo={mappingInfo:{identifierMapsTo:hr(t.identifierInfo.identifierMappingInfo.identifierInfoType),identifierPropertyName:t.identifierInfo.identifierMappingInfo.uniformPropertyIdentifier.identifierPropertyName}},r.spatialReference=JSON.parse(JSON.stringify(t.spatialReference)),r}static getDataModelTypesSummary(t){let r=t.entityTypes.map(a=>a.name).join(", "),o=t.relationshipTypes.map(a=>a.name).join(", ");return`Entity Types: ${r}.
|
|
77
|
+
Relationship Types: ${o}.`}},C=class e{constructor(){this.name="",this.properties=[]}static fromEntityType(t){let r=new e;r.name=t.name,r.alias=t.alias?t.alias:void 0,r.role=yr(t.role);for(let o of t.properties){let a={name:o.name,alias:o.alias?o.alias:void 0,fieldType:o.fieldType,role:fr(o.role),geometryDef:o.fieldType==="esriFieldTypeGeometry"?{geometryType:o.geometryType??"esriGeometryAny",hasM:o.hasM?o.hasM:void 0,hasZ:o.hasZ?o.hasZ:void 0}:void 0};r.properties.push(a)}return r}},J=class extends C{constructor(){super(...arguments),this.observedEndPoints=[]}static fromRelationshipType(t){let r=C.fromEntityType(t);r.observedEndPoints=[];for(let o of t.endPoints)r.observedEndPoints.push({originEntityType:o.originEntityType,destinationEntityType:o.destinationEntityType});return r}},hr=e=>{switch(e){case"esriIdentifierInfoTypeUNSPECIFIED":return"UNSPECIFIED";case"esriIdentifierInfoTypeDatabaseNative":return"DatabaseNative";case"esriIdentifierInfoTypeUniformProperty":return"UniformPropertyIdentifier";default:return e}},yr=e=>{switch(e){case"Regular":return"esriGraphNamedObjectRegular";case"Provenance":return"esriGraphNamedObjectProvenance";case"Document":return"esriGraphNamedObjectDocument";default:return e}};function fr(e){switch(e){case"esriGraphPropertyRegular":return"Regular";case"esriGraphPropertyDocumentName":return"Document_Name";case"esriGraphPropertyDocumentTitle":return"Document_Title";case"esriGraphPropertyDocumentUrl":return"Document_Url";case"esriGraphPropertyDocumentText":return"Document_Text";case"esriGraphPropertyDocumentKeywords":return"Document_Keywords";case"esriGraphPropertyDocumentContentType":return"Document_ContentType";case"esriGraphPropertyDocumentMetadata":return"Document_Metadata";case"esriGraphPropertyDocumentFileExtension":return"Document_FileExtension";case"esriGraphPropertyProvenanceInstanceId":return"Provenance_InstanceId";case"esriGraphPropertyProvenanceSourceType":return"Provenance_SourceType";case"esriGraphPropertyProvenanceSourceName":return"Provenance_SourceName";case"esriGraphPropertyProvenanceSource":return"Provenance_Source";case"esriGraphPropertyProvenanceComment":return"Provenance_Comment";case"esriGraphPropertyProvenanceTypeName":return"Provenance_TypeName";case"esriGraphPropertyProvenancePropertyName":return"Provenance_PropertyName";default:return"Regular"}}function G(e){return e?.signal}async function gr(e,t){let r=await L("arcgis_knowledge_cypher_query_prompt");return t?`${e} ${r}
|
|
78
|
+
|
|
79
|
+
Your previous attempt to generate a cypher query failed. See the details below and generate a new cypher query that avoids this error.
|
|
80
|
+
|
|
81
|
+
Attempt Number: ${t.attemptCount}
|
|
82
|
+
Execution Error: ${t.executionError}
|
|
83
|
+
Failed Query:
|
|
84
|
+
${t.failedGraphQuery}`:`${e} ${r}`}async function wr(e,t,r,o){let{graphQuery:a,explanation:i}=await ae(e,t,r,o);return{graphQuery:a,explanation:i}}async function ae(e,t,r,o,a){let i={message:await gr(e,a),context:new H(t)},s=G(o);await b({text:"Attempting to generate a cypher query from your prompt..."},o);let n=await Se(`${r}/chat`,{method:"post",body:JSON.stringify(i),headers:{"Content-Type":"application/json",token:ve.findCredential(_.getDefault().url)?.token??""},signal:s});if(n.httpStatus!==200)throw new Error(`Graph query service returned an error: ${n.httpStatus}`,{cause:n.data});let c=!1,l=Date.now(),u=n.data.sequenceNumber,p="",m="",w=1;for(;!c;){await new Promise(f=>setTimeout(f,1e3)),await b({text:`Periodically requesting status of job from ArcGIS AI Services${"...".substring(0,w)}`},o),w=w%3+1;let h=await Se(`${r}/chat`,{method:"post",body:JSON.stringify({conversationId:n.data.conversationId,inquiryId:n.data.inquiryId,ackSequenceNumber:u}),headers:{"Content-Type":"application/json",token:ve.findCredential(_.getDefault().url)?.token??""},signal:s});if(h.httpStatus!==200)throw new Error(`Graph query service polling returned an error: ${h.httpStatus}`,{cause:h.data});if(h.data.context?.kind){if(h.data.context.kind!=="GraphQueryGenerationResponse")throw new Error(`Unexpected response from graph query service polling. Message: ${h.data.message}`,{cause:h.data});p=h.data.context.graphQuery,m=h.data.message||"",c=!0}else if(!h.data.hasMore)c=!0;else if(Date.now()-l>6e4)throw new Error("Graph query service polling timed out after 1 minute.");u=h.data.sequenceNumber}return{graphQuery:p,explanation:m}}function br(e,t){E(e,r=>{t.set(`${r.typeName}__${r.id}`,{id:r.id,typeName:r.typeName})})}function E(e,t){if(!(!e||typeof e!="object")){if(vr(e))for(let r of e.path)E(r,t);else if(Tr(e))t(e);else if(Array.isArray(e))for(let r of e)E(r,t);else if(Sr(e))for(let r of Object.values(e.properties??{}))E(r,t)}}function Tr(e){return!e||typeof e!="object"||Array.isArray(e)?!1:"id"in e&&"typeName"in e}function vr(e){return!e||typeof e!="object"||Array.isArray(e)?!1:e&&"path"in e&&Array.isArray(e.path)}function Sr(e){return!e||typeof e!="object"||Array.isArray(e)||"id"in e?!1:"properties"in e&&typeof e.properties=="object"}function xr(e,t){let r=[],o=[],a=[[t.dataModel.entityTypes,r],[t.dataModel.relationshipTypes,o]];for(let[i,s]of a)for(let n of i){let c=e.getMemberIdsByType(n.name);s.push(...c)}return{entityIds:r,relationshipIds:o}}function Er(e,t){let r={entityIds:new Array,relationshipIds:new Array},o=[],a=e?.allLayers.find(n=>n.type==="knowledge-graph")?.inclusionModeDefinition;if(!a)return{allNamedTypesFullyDynamic:!0,bindParameters:r,nonDynamicTypes:o};let i=[[t.dataModel.entityTypes,r.entityIds],[t.dataModel.relationshipTypes,r.relationshipIds]],s=!0;for(let[n,c]of i)for(let l of n){let u=a.namedTypeDefinitions.get(l.name);if(!u){s=!1,o.push(l.name);continue}if(!u.useAllData){s=!1,o.push(l.name);for(let[p]of u.members||[])c.push(p)}}return{allNamedTypesFullyDynamic:s,bindParameters:r,nonDynamicTypes:o}}var M=3;function Ne(e,t=100){let r={};for(let o of Object.entries(e.properties??{})){let[a,i]=o;typeof i=="string"&&i.length>t?r[a]=`${i.slice(0,t)}... (truncated, original length: ${i.length})`:r[a]=i}return e.properties=r,e}function k(e){return typeof e!="object"||e===null?String(e):"details"in e&&typeof e.details=="object"&&e.details!==null&&"errorMessage"in e.details&&typeof e.details.errorMessage=="string"?e.details.errorMessage:"message"in e&&typeof e.message=="string"?e.message:String(e)}var Mr=async({kg:e,queryParams:t,targetStructure:r,targetStructureReducer:o,requestOptions:a,queryRowLimit:i,queryTimeoutMs:s})=>{let n=null,c=r,l=new AbortController,u=a?.signal,p=()=>{l.abort(u?.reason)};u&&(u.aborted?l.abort(u.reason):u.addEventListener("abort",p,{once:!0}));try{let m=await nt(e,t,a);n=m.resultHeader;let w=m.resultRowsStream.getReader(),h=0,f=Date.now(),S=!1;for(;;){let{done:V,value:Ce}=await w.read();if(V)break;if(!S&&s&&Date.now()-f>s)return l.abort(),{type:"timeout"};for(let qe of Ce){if(h++,i&&h>i)return l.abort(),{type:"success",rowLimitReached:!0,resultHeader:n,processedResult:c};c=o(c,qe)}}}catch(m){return l.signal.aborted?{type:"aborted"}:{type:"error",errorMessage:k(m),error:m}}finally{u?.removeEventListener("abort",p)}return{type:"success",rowLimitReached:!1,resultHeader:n,processedResult:c}};async function Ae({prompt:e,bindParameters:t,kg:r,graphQueryServiceUrl:o,targetStructure:a,targetStructureReducer:i,requestOptions:s,queryRowLimit:n,queryTimeoutMs:c,config:l}){let u;for(let p=1;p<=M;p++){let m;try{m=await ae(e,r.dataModel,o,l,u)}catch(S){return{type:"generation-error",errorMessage:k(S),error:S}}await b({text:`Attempting to execute query: ${m.graphQuery.substring(0,500)}${m.graphQuery.length>500?"...":""}`},l);let w=await _r(m.graphQuery,t),h=await Mr({kg:r,queryParams:new ke({openCypherQuery:m.graphQuery,bindParameters:w}),targetStructure:a,targetStructureReducer:i,requestOptions:s,queryRowLimit:n,queryTimeoutMs:c}),f=h.type==="aborted"?"Query execution was aborted.":h.type==="timeout"?"Query execution timed out.":h.type==="error"?`Query failed with error: ${h.errorMessage}`:"";if(h.type==="success")return{type:"success",graphQuery:m.graphQuery,explanation:m.explanation,rowLimitReached:h.rowLimitReached,resultHeader:h.resultHeader,processedResult:h.processedResult};if(h.type==="aborted")return{type:"aborted",errorMessage:f,graphQuery:m.graphQuery,explanation:m.explanation};if(p>=M)return h.type==="timeout"?{type:"timeout",errorMessage:f,graphQuery:m.graphQuery,explanation:m.explanation}:{type:"execution-error",errorMessage:f,error:h.error,graphQuery:m.graphQuery,explanation:m.explanation};u={failedGraphQuery:m.graphQuery,executionError:f,attemptCount:p},await b({text:`Attempt ${p} failed with error: ${f}. Retrying...`},l)}throw new Error(`Failed to execute generated cypher due to an unexpected error after ${M} attempts.`)}var _r=async(e,t)=>{if(!t)return{};let{bindParameters:r,parseErrors:o}=await lt(e);if(o)return t;let a={};for(let i of r)i in t&&(a[i]=t[i]);return a},kr=async({kg:e,searchQuery:t,typeCategoryFilter:r,namedTypesFilter:o,searchResultLimit:a,requestOptions:i})=>{let s=[],n=[r];r==="both"&&!e.serviceDefinition.serviceCapabilities.searchCapabilities.searchTypeFilterCapabilities.includes("esriTypeBoth")&&(n=["entity","relationship"]);let c=a??1/0;try{for(let l of n){let u=c-s.length;if(u<=0)break;let p=(await it(e,new st({searchQuery:t,typeCategoryFilter:l,namedTypesFilter:o??void 0,num:u}),i)).resultRowsStream.getReader(),m=!1;for(;!m;){let{done:w,value:h}=await p.read();if(w){m=!0;break}for(let f of h)for(let S of f)s.push(S)}}}catch(l){let u=k(l);return i?.signal?.aborted?{type:"aborted",errorMessage:u,error:l}:{type:"error",errorMessage:u,error:l}}return{type:"success",results:s}},Re="IMPORTANT: The generated cypher query must return entire entities and relationships ONLY.";async function Ie({prompt:e,view:t,knowledgeGraph:r,includeReturnEntityAndRelationshipContext:o=!1}){let a=[e];if(o&&a.push(Re),!x(t)&&t.map){let u=await L("arcgis_knowledge_current_lc_context"),p=xr(t.map,r);return a.push(u),{enhancedPrompt:a.join(`
|
|
85
|
+
|
|
86
|
+
`),bindParameters:p,allNamedTypesFullyDynamic:!1}}let i=t.map,{allNamedTypesFullyDynamic:s,bindParameters:n,nonDynamicTypes:c}=Er(i,r);if(s)return{enhancedPrompt:a.join(`
|
|
87
|
+
|
|
88
|
+
`),bindParameters:n,allNamedTypesFullyDynamic:!0};let l=(await L("arcgis_knowledge_current_map_context")).replaceAll("{nonDynamicTypes}",JSON.stringify(c));return a.push(l),{enhancedPrompt:a.join(`
|
|
89
|
+
|
|
90
|
+
`),bindParameters:n,allNamedTypesFullyDynamic:s}}async function $r(e,t,r,o,a,i){let{view:s}=a,n=await Ae({prompt:e,bindParameters:t,kg:r,graphQueryServiceUrl:o,targetStructure:new Map,targetStructureReducer:(m,w)=>{for(let h of w)br(h,m);return m},requestOptions:{signal:G(i),timeout:i?.timeout},config:i});if(n.type!=="success"){let m=n.type==="generation-error"?n.errorMessage:`${n.errorMessage} Cypher query: ${n.graphQuery}`;throw new Error(`Failed to add records to the link chart. ${m}`)}let{graphQuery:c,explanation:l,processedResult:u}=n,p=Array.from(u.values());return await b({text:`Query Results parsed into ${p.length} unique relationships and entities. Atempting to add to link chart...`},i),!x(s)&&s?.map?(await s.map.addRecords(p),await Q(s),{generatedQuery:c,explanation:l,addedIdTypePairs:p}):(await s?.map?.allLayers.find(m=>m.type==="knowledge-graph")?.addRecords(p),{generatedQuery:c,explanation:l,addedIdTypePairs:p})}var j="addRecords",Nr=d.object({prompt:d.string().describe("The user's inquiry and context required in order to generate a cypher query that will be used to add records to the link chart.")}),Ar=async({prompt:e},t)=>{let{knowledgeGraph:r}=await z(t),o=q(t),{view:a}=o,i=_.getDefault().helperServices,{enhancedPrompt:s,bindParameters:n,allNamedTypesFullyDynamic:c}=await Ie({prompt:e,view:a,knowledgeGraph:r,includeReturnEntityAndRelationshipContext:!0});if(c)return{toolName:j,status:"success",summary:"No records have been added to the map because all data in the knowledge graph is contained in the map.",details:{generatedQuery:"N/A",explanation:"All named types in the knowledge graph are fully dynamic and therefore all data is already contained in the map. No records have been added.",addedIdTypePairs:[]}};try{let{generatedQuery:l,explanation:u,addedIdTypePairs:p}=await $r(s,n,r,`${i.aiAssistantServices.url}${i.aiAssistantServices.graphQueryAssistant}`,o,t);return{toolName:j,status:"success",summary:`Records added successfully. Cypher Query used: ${l}
|
|
91
|
+
|
|
92
|
+
Number of records added: ${p.length}`,details:{generatedQuery:l,explanation:u,addedIdTypePairs:p}}}catch(l){let u=k(l);return{toolName:j,status:"error",errorMessage:`Failed to add records to the link chart. ${u}`,error:l}}},ln=g(Ar,{name:j,description:`Adds records (entities or relationships) to the current link chart visualization from an inquiry into the knowledge graph data. The inquiry will retrieve data from the graph database that will serve as the basis for the records to be added to the link chart. The user should have explicitly requested to add records to the current link chart from their prompt. "add to new link chart" is not a valid prompt for this tool.
|
|
93
|
+
|
|
94
|
+
example prompts:
|
|
95
|
+
- "add all suppliers and the parts they produce to the link chart"
|
|
96
|
+
- "show me the competitors of company x and add them to the link chart"
|
|
97
|
+
- "add the relationships between company x and company y to the link chart"
|
|
98
|
+
- "expand all the companies"
|
|
99
|
+
- "expand company x through all the buildings it owns"
|
|
100
|
+
- "connect company x and company y"
|
|
101
|
+
- "connect all buildings on the link chart"
|
|
102
|
+
`,schema:Nr});async function Rr(e,t){return await t.map?.applyLayout(e),await Q(t),{appliedLayout:e}}var Z="applyLayout",Ir=d.object({layout:d.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")}),Cr=async({layout:e},t)=>{let{view:r}=q(t);if(x(r))return{toolName:Z,status:"error",errorMessage:"The applyLayout tool can only be used with a LinkChartView.",error:new Error};{let{appliedLayout:o}=await Rr(e,r);return{toolName:Z,status:"success",summary:`Successfully applied layout: ${o}.`,details:{appliedLayout:o}}}},cn=g(Cr,{name:Z,description:"Apply a diagram layout to the link chart",schema:Ir});async function qr(e,t){return t.map?.changeNonspatialDataDisplay(e),await Q(t),{appliedNonspatialDataDisplayMode:e}}var Y="changeNonspatialVisibility",zr=d.object({setting:d.enum(["hidden","visible"]).describe("The setting of nonspatial visibility")}),Dr=async({setting:e},t)=>{let{view:r}=q(t);if(x(r))return{toolName:Y,status:"error",errorMessage:"The changeNonspatialVisibility tool can only be used with a LinkChartView.",error:new Error};{let{appliedNonspatialDataDisplayMode:o}=await qr(e,r);return{toolName:Y,status:"success",summary:`Successfully applied nonspatial visibility setting: ${o}.`,details:{appliedNonspatialDataDisplayMode:o}}}},dn=g(Dr,{name:Y,description:"Change whether or not nonspatial data is visible in the link chart. The value must be either 'hidden' or 'visible'.",schema:zr});async function Pr(e,t,r,o,a){let i,s="";for(let n=1;n<=M;n++){let{graphQuery:c,explanation:l}=await ae(e,t.dataModel,r,a,i);try{await b({text:`Attempting to create link chart from derived query: ${c}`},a);let u=await at.fromCypherQuery(t,new ke({openCypherQuery:c}));await b({text:"Link chart created successfully, loading..."},a),await u.load();let p=o.map;return o.map=u,await o.when(),await _e.whenOnce(()=>!o.updating),u.entityCount===0&&u.relationshipCount===0?(o.map===u&&(o.map=p),u.destroy(),{type:"error",errorMessage:`Query returned no results. Cypher Query used to create the link chart:
|
|
103
|
+
${c}
|
|
104
|
+
|
|
105
|
+
Explanation: ${l}`}):(await Q(o),{type:"success",graphQuery:c,explanation:l})}catch(u){let p=k(u);if(n>=M){s=p;break}i={failedGraphQuery:c,executionError:p,attemptCount:n},await b({text:`Attempt ${n} to create link chart failed with error: ${p}. Retrying ...`},a)}}return{type:"error",errorMessage:`Failed to create link chart after ${M} attempts. Last error: ${s}`}}var F="createLinkChart",Or=d.object({prompt:d.string().describe("The user's inquiry and context required in order to generate a cypher query that will be used to create a link chart visualization. Only include information relevant to generating a cypher query. Do not suggest entity types, relationship types or properties. Do not include limits or formatting instructions for the query results unless specifically requested by the user. The prompt should be focused on the data the user wants to see in the link chart, not how to generate it.")}),jr=async({prompt:e},t)=>{let{knowledgeGraph:r}=await z(t),{view:o}=q(t);if(x(o))return{toolName:F,status:"error",errorMessage:"The createLinkChart tool can only be used with a LinkChartView.",error:new Error};{let a=_.getDefault().helperServices,i=await Pr(`${e}
|
|
106
|
+
|
|
107
|
+
${Re}`,r,`${a.aiAssistantServices.url}${a.aiAssistantServices.graphQueryAssistant}`,o,t);if(i.type==="error")return{toolName:F,status:"error",errorMessage:i.errorMessage,error:new Error};let{graphQuery:s,explanation:n}=i;return{toolName:F,status:"success",summary:`Link chart created successfully. Cypher Query used to create the link chart:
|
|
108
|
+
${s}
|
|
109
|
+
|
|
110
|
+
Explanation: ${n}`,details:{generatedQuery:s,explanation:n}}}},un=g(jr,{name:F,description:"Creates a new link chart visualization from an inquiry into the knowledge graph data. The inquiry will retrieve data from the graph database that will serve as the basis for the new link chart. The user should have explicitly requested the creation of a new link chart from their prompt using language like 'create new link chart' or 'add to new link chart'.",schema:Or}),X="queryGraphData",Fr=d.object({prompt:d.string().describe("The user's inquiry into the knowledge graph, from which a cypher query will be generated and executed to answer the inquiry. Only include entity types, relationship types or properties if they are provided in the user prompt or prior steps. Do not suggest entity types, relationship types or properties. Do not include limits, information on what to return, instructions on how to write the query, or formatting instructions for the query results unless specifically requested by the user.")}),Lr=async({prompt:e},t)=>{let{knowledgeGraph:r}=await z(t),o=_.getDefault().helperServices,a=e,i=null,s=null;try{({view:s}=q(t))}catch{}s&&({enhancedPrompt:a,bindParameters:i}=await Ie({prompt:e,view:s,knowledgeGraph:r,includeReturnEntityAndRelationshipContext:!1}));let n=await Ae({prompt:a,bindParameters:i,kg:r,graphQueryServiceUrl:`${o.aiAssistantServices.url}${o.aiAssistantServices.graphQueryAssistant}`,targetStructure:new Array,targetStructureReducer:(f,S)=>(f.push(S),f),requestOptions:{signal:G(t),timeout:t?.timeout},config:t});if(n.type!=="success"){let f=n.type==="generation-error"?n.errorMessage:`${n.errorMessage} Cypher query: ${n.graphQuery}`;return{toolName:X,status:"error",errorMessage:`Failed to query the knowledge graph. ${f}`,error:"error"in n?n.error:null}}let{graphQuery:c,explanation:l,processedResult:u,resultHeader:p}=n,m=p.headerKeys;for(let f of u)for(let S of f)E(S,V=>Ne(V));let w=50,h=u.slice(0,w).map(f=>JSON.stringify(f));return{toolName:X,status:"success",summary:`To answer the inquiry, the following cypher query was executed against the knowledge graph:
|
|
111
|
+
|
|
112
|
+
\`\`\`cypher
|
|
113
|
+
${c}
|
|
114
|
+
\`\`\`
|
|
115
|
+
|
|
116
|
+
Query Results:
|
|
117
|
+
${h.length} result(s) found.
|
|
118
|
+
|
|
119
|
+
Column Headers: ${m.join(", ")}
|
|
120
|
+
|
|
121
|
+
${h.length>w?`Showing top ${w} results:
|
|
122
|
+
|
|
123
|
+
`:`Results:
|
|
124
|
+
|
|
125
|
+
`}${h.join(`
|
|
126
|
+
`)}
|
|
127
|
+
`,details:{generatedQuery:c,explanation:l,resultHeader:p,queryResults:u}}},pn=g(Lr,{name:X,description:"Allows users to explore the data in their knowledge graph via cypher query. Generates and executes a cypher query based on the user's inquiry into the knowledge graph, and displays the results in the chat pane without modifying the user's link chart if any. Use this tool when the user is asking an exploratory question about their data as a whole that can be answered via cypher query, for example 'What are the top 5 suppliers by total parts cost?' or 'How many employees do we have in each department?'.",schema:Fr}),ee="generateCypher",Qr=d.object({prompt:d.string().describe("The user's inquiry into the knowledge graph that needs to be translated into a cypher query.")}),Gr=async({prompt:e},t)=>{let{knowledgeGraph:r}=await z(t),o=_.getDefault().helperServices;try{let{graphQuery:a,explanation:i}=await wr(e,r.dataModel,`${o.aiAssistantServices.url}${o.aiAssistantServices.graphQueryAssistant}`,t);return{toolName:ee,status:"success",summary:`Generated Graph Query:
|
|
128
|
+
${a}
|
|
129
|
+
|
|
130
|
+
Explanation: ${i}`,details:{generatedQuery:a,explanation:i}}}catch(a){let i=k(a);return{toolName:ee,status:"error",errorMessage:`Failed to generate Cypher query. ${i}`,error:a}}},mn=g(Gr,{name:ee,description:"Generates an Open Cypher query based on the user's prompt which represents an inquiry into the data of the knowledge service and its graph database, attempting to filter based on certain conditions and traverse specified relationships. The generated query should be syntactically correct and optimized for performance.",schema:Qr}),Vr=e=>{let t=e.dataModel,r=new Map;for(let n of t.searchIndexes)if(n.supportedCategory!=="esriTypeMetaEntityProvenance")for(let[c,l]of n.searchProperties.entries()){let u=r.get(c)??new Set;l.propertyNames.forEach(p=>u.add(p)),r.set(c,u)}let o=t.entityTypes.filter(n=>r.has(n.name)),a=t.relationshipTypes.filter(n=>r.has(n.name)),i=`Entity Types:
|
|
131
|
+
${o.map(({name:n})=>`${n}: [${Array.from(r.get(n)??[]).join(", ")}]`).join(`
|
|
132
|
+
`)}`,s=`Relationship Types:
|
|
133
|
+
${a.map(({name:n})=>`${n}: [${Array.from(r.get(n)??[]).join(", ")}]`).join(`
|
|
134
|
+
`)}`;return`${i}
|
|
135
|
+
|
|
136
|
+
${s}`};async function Br(e,t,r){let o=await L("arcgis_knowledge_lucene_generation_prompt"),a={inquiry:e,dataModelForSearch:Vr(t)},i=d.enum(["entity","relationship","both"]).describe("The graph element category to search against - entity, relationship, or both"),s=d.number().int().positive().nullable().describe("The maximum number of search results to return. Default to 10 if not specified by the user, or set to null if the user specifically requests no limits or all results."),n=d.array(d.enum(t.dataModel.entityTypes.map(l=>l.name).concat(t.dataModel.relationshipTypes.map(l=>l.name)))).min(1),c=d.object({query:d.string().describe("A lucene syntax query string to be executed against the knowledge graph search API"),typeFilters:n.nullable().describe("Nullable list of entity or relationship types from the graph to limit the search to. If set to null, search will execute against all named types with indexed properties in the graph"),typeCategoryFilter:i,resultLimit:s});return await ce({promptText:o,inputVariables:a,schema:c,config:r})}var te="searchGraphData",Kr=d.object({prompt:d.string().describe("The user's inquiry into the knowledge graph, from which a lucene search query will be generated and executed against the graph to return relevant results.")}),Ur=async({prompt:e},t)=>{let{knowledgeGraph:r}=await z(t);await b({text:"Generating search query for the user inquiry"},t);let o=await Br(e,r,t);await b({text:"Executing graph search with generated search query"},t);let a=await kr({kg:r,searchQuery:o.query,typeCategoryFilter:o.typeCategoryFilter,namedTypesFilter:o.typeFilters,searchResultLimit:o.resultLimit,requestOptions:{signal:G(t),timeout:t?.timeout}});if(a.type!=="success")return{toolName:te,status:"error",errorMessage:a.errorMessage,error:"error"in a?a.error:null};for(let n of a.results)E(n,c=>Ne(c));let i=10,s=a.results.slice(0,i);return{toolName:te,status:"success",summary:`To answer the query, the following lucene query was generated and executed:
|
|
137
|
+
Query: ${o.query}
|
|
138
|
+
Type Category Filter: ${o.typeCategoryFilter}
|
|
139
|
+
Named Type Filters: ${o.typeFilters?o.typeFilters.join(", "):"None"}
|
|
140
|
+
Result Limit: ${o.resultLimit??"No limit"}
|
|
141
|
+
|
|
142
|
+
Search Results: ${a.results.length} result(s) found.
|
|
143
|
+
|
|
144
|
+
${a.results.length>i?`Showing top ${i} results:
|
|
145
|
+
|
|
146
|
+
`:""}${s.map(n=>JSON.stringify(n)).join(`
|
|
147
|
+
`)}`,details:{generatedSearchQuery:o,searchResults:a.results}}},hn=g(Ur,{name:te,description:`
|
|
148
|
+
Search the knowledge graph using one or more search texts, using lucene search syntax, against indexed string properties defined on their entities and relationships. Use this tool when the user asks a question about their knowledge graph data as a whole, that could be answered via lucene text search of properties stored on graph elements, e.g requiring fuzzy matching. Otherwise if the inquiry is looking for connected records (e.g. paths), data aggregations, etc explore the data via the queryGraphData tool.
|
|
149
|
+
Example prompts:
|
|
150
|
+
- "Find 'Bradley'"
|
|
151
|
+
- "find the person john smith"
|
|
152
|
+
- "find all people named smith"
|
|
153
|
+
- "Find all references to 'delayed parts shipment'"
|
|
154
|
+
- "Find all reports authored by someone with the title of 'Researcher'"
|
|
155
|
+
- "Find the first 5 reports where summary mentions flood zoning near Sacramento, and the organization name is the City of Sacramento Utilities, and tags containing stormwater".
|
|
156
|
+
- "Search for all john smiths and show their global ids`,schema:Kr});return{a:O,b:La,c:L,d:ct,e:Qa,f:Ga,g:Va,h:Ba,i:Ka,j:Ua,k:Ha,l:Wa,m:Ja,n:Za,o:Ya,p:Xa,q:en,r:tn,s:pr,t:rn,u:on,v:an,w:nn,x:sn,y:z,z:W,A:ln,B:cn,C:dn,D:un,E:pn,F:mn,G:hn}},"identity/IdentityManager","portal/Portal","request","config","core/reactiveUtils","layers/FeatureLayer","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","WebLinkChart","rest/knowledgeGraph/GraphQueryStreaming","views/LinkChartView","rest/knowledgeGraphService","rest/knowledgeGraph/GraphSearchStreaming","applications/KnowledgeStudio/generalSharedKgUtils",a,c,e,f,h,i)
|
|
@@ -0,0 +1,2 @@
|
|
|
1
|
+
/* COPYRIGHT Esri - https://js.arcgis.com/5.2/LICENSE.txt */
|
|
2
|
+
import a from"./CCC6LBMY.js";import{a as m}from"./ONQ6JSBJ.js";import{Dc as f}from"./AI6DYOKR.js";import{a as o}from"./VXFQANGJ.js";export default $arcgis.t(([{b:c,c:h}])=>{var g=(a,e,i)=>{let t=a.createQuery();return t.outFields=[e],t.where=i||"1=1",t.num=1,t},w=async(a,e,i,t)=>{let r=t.map?.allLayers.find(y=>y.id===a),n=g(r,e,i.where),s=(await r.queryFeatures(n)).features[0],d=s?s.attributes[e]:null,u=c(r,e,d,t.timeZone),l=h(r,e);return{tool:"getAttribute",layerName:r.title??a,summary:`${l} = ${u}`,details:{fieldName:e,fieldAlias:l!==e?l:void 0,value:u,where:i.where}}};async function b({layerId:a,fieldName:e,query:i},t){let{mapView:r}=m(t,["mapView"]),n=await w(a,e,i,r);return JSON.stringify(n,null,2)}var p=o.object({layerId:o.string().describe("The layerId of the layer containing the field from which to get a value."),fieldName:o.string().describe("The name of the field/attribute from which to get a field value."),query:o.object({where:o.string().describe("The SQL-92 where clause representing the feature from which to get an attribute value.")})}),q=f(b,{name:"getAttribute",description:"Returns an attribute value for a given feature.",schema:p});return q},a)
|
|
@@ -1,9 +1,9 @@
|
|
|
1
1
|
/* COPYRIGHT Esri - https://js.arcgis.com/5.2/LICENSE.txt */
|
|
2
|
-
import b from"./
|
|
2
|
+
import b from"./S6OYR4VI.js";import a from"./AT4XVTJR.js";import{a as c,b as k}from"./7VAQUCBU.js";import{Ya as x,a as w,b as d,j as f}from"./EWLXNGKH.js";import{ea as u}from"./AI6DYOKR.js";export default $arcgis.t(([,,,,,,{n:_,p:b},{A:M,B:T,C:E,D:C,E:G,F:N,G:R,a:v,c:m,d:h,e:A,w:y,x:K,y:q,z:S}])=>{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(`
|
|
6
|
-
`)):"ArcGIS Knowledge Agent did not execute any tools or return any results.",arcgisKnowledgeMessages:[...e.arcgisKnowledgeMessages,...s.messages],arcgisKnowledgeToolResult:n}}catch(s){let n=s instanceof Error?s.message:String(s);return await c({text:`ArcGIS Knowledge Agent tool execution failed unexpectedly: ${n}`},a),{...e,outputMessage:`ArcGIS Knowledge Agent tool execution failed unexpectedly: ${n}`,status:"failed",summary:h(`ArcGIS Knowledge Agent tool execution failed unexpectedly: ${n}`),arcgisKnowledgeMessages:[...e.arcgisKnowledgeMessages]}}}var V=(e,a)=>A([],"ArcgisKnowledge Agent")(e,a);async function
|
|
6
|
+
`)):"ArcGIS Knowledge Agent did not execute any tools or return any results.",arcgisKnowledgeMessages:[...e.arcgisKnowledgeMessages,...s.messages],arcgisKnowledgeToolResult:n}}catch(s){let n=s instanceof Error?s.message:String(s);return await c({text:`ArcGIS Knowledge Agent tool execution failed unexpectedly: ${n}`},a),{...e,outputMessage:`ArcGIS Knowledge Agent tool execution failed unexpectedly: ${n}`,status:"failed",summary:h(`ArcGIS Knowledge Agent tool execution failed unexpectedly: ${n}`),arcgisKnowledgeMessages:[...e.arcgisKnowledgeMessages]}}}var V=(e,a)=>A([],"ArcgisKnowledge Agent")(e,a);async function O(e,a){let o=(e.arcgisKnowledgeToolResult??[]).map(l=>({...l,details:void 0})),{knowledgeGraph:s}=await q(a),n=S.getDataModelTypesSummary(s.dataModel),r={assignedTask:e.agentExecutionContext.assignedTask,userRequest:e.agentExecutionContext.userRequest,toolResult:o,dataModelSummary:n},i=await _({promptText:await m("arcgis_knowledge_summarize_result_prompt"),modelTier:"default",inputVariables:r,config:a}),t=typeof i=="string"?i:i.content;return{...e,outputMessage:t,status:"success",summary:h(t),arcgisKnowledgeMessages:[...e.arcgisKnowledgeMessages,new u(t)]}}async function j(e){let a=e.arcgisKnowledgeToolResult?.[0],o=a?.status==="success"?a.summary:"ArcGIS Knowledge Agent tool execution failed.";return{...e,outputMessage:o,status:"success",summary:h(o),arcgisKnowledgeMessages:[...e.arcgisKnowledgeMessages,new u(o)]}}function g(e){return async(a,o)=>o?.signal?.aborted?(await c({text:"Knowledge Agent execution cancelled"},o),new f({goto:d,update:{outputMessage:"Knowledge Agent execution cancelled",summary:"Knowledge Agent execution cancelled",status:"failed"}})):await e(a,o)}var J=()=>new x(y).addNode("requireArcgisKnowledgeServices",V).addNode("agent",g($)).addNode("tools",g(F)).addNode("summarizationLLM",g(O)).addNode("finalizeToolSummary",g(j)).addEdge(w,"requireArcgisKnowledgeServices").addEdge("requireArcgisKnowledgeServices","agent").addConditionalEdges("agent",e=>(e.arcgisKnowledgeMessages[e.arcgisKnowledgeMessages.length-1]?.tool_calls?.length??0)>0?"tools":d).addConditionalEdges("tools",e=>{if(e.status==="failed")return d;let a=e.arcgisKnowledgeToolResult?.[0];return a?.status==="success"&&["applyLayout","changeNonspatialVisibility"].includes(a.toolName)?"finalizeToolSummary":"summarizationLLM"}).addEdge("summarizationLLM",d).addEdge("finalizeToolSummary",d),P=String.raw`The purpose of this agent is to work with Knowledge Graph data, a graph database technology that represents and stores data as interconnected entities (nodes) and relationships (edges).
|
|
7
7
|
This agent has two categories of skills: those that work with an active link chart visualization of a subset of the data in the knowledge graph, and those that work with the knowledge graph data more generally against the entire dataset in the service and database.
|
|
8
8
|
For link charts, the agent 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,
|
|
9
9
|
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
|
|
@@ -1,3 +1,3 @@
|
|
|
1
1
|
/* COPYRIGHT Esri - https://js.arcgis.com/5.2/LICENSE.txt */
|
|
2
|
-
import
|
|
2
|
+
import b from"./L7XTRDFM.js";import{a as E}from"./B6CJG5UH.js";import{a as I}from"./434TAA3J.js";import{a as D}from"./2GH3K5JP.js";import"./OKMZQXBQ.js";import{a as R}from"./3UEKINYC.js";import"./RLEHNAIA.js";import a from"./AT4XVTJR.js";import"./7M6VKBTK.js";import{g as $,h as c,k as C,l as P,n as d,t as _,u as y,v as T,x as k,z as A}from"./6TA5KFAQ.js";import"./R74ZHFA6.js";import"./7VAQUCBU.js";import"./VOKXKU7M.js";import"./EWLXNGKH.js";import"./AI6DYOKR.js";import"./VXFQANGJ.js";import"./MWYBF3F3.js";import"./UZLQALHY.js";export default $arcgis.t(([N,{whenOnce:U,watch:B,when:V},j,,q,,,H,{property:m,subclass:F},,{b:L}])=>{var G=$`:host{display:block;width:var(--arcgis-internal-panel-width, 100%);height:var(--arcgis-internal-expand-max-height, 100%);--calcite-panel-content-bottom-space: 0}.footer-container{display:flex;flex-direction:column;flex:1 1 0;gap:var(--calcite-spacing-md)}.content-container{display:flex;flex-direction:column;flex:1 1 0;min-height:0;position:relative;overflow:auto}.suggested-prompts-container{display:flex;justify-content:center;width:100%;background:var(--calcite-panel-background-color, var(--calcite-color-background))}.suggested-prompts{display:block;padding:var(--calcite-spacing-md);max-width:100%;box-sizing:border-box}.error-notice{padding:var(--calcite-spacing-sm)}.interrupt-waiting-message{font-style:italic;color:var(--calcite-color-text-2)}`;function S(o){return o.trim()?E.lexer(o).filter(t=>t.type!=="space").map(t=>E.parser([t])):[]}var f=class{constructor(){this._stableParts=[],this._stableText="",this._rawText=""}push(t){return this._rawText+=t,this._advanceStableBoundary(),this.getParts()}finalize(){let t=this._rawText.slice(this._stableText.length);return t.trim()&&(this._stableParts.push(...S(t)),this._stableText=this._rawText),this._stableParts}getParts(){let t=this._trimIncompleteTail(this._rawText.slice(this._stableText.length)),s=t.trim()?S(t):[];return[...this._stableParts,...s]}reset(){this._stableParts=[],this._stableText="",this._rawText=""}_advanceStableBoundary(){let t=this._rawText.slice(this._stableText.length),s=this._lastSafeBoundary(t);if(s<=0)return;let i=t.slice(0,s);this._stableParts.push(...S(i)),this._stableText+=i}_lastSafeBoundary(t){let s=t.split(`
|
|
3
3
|
`),i=!1,e=0,n=0;for(let r of s)/^\s*(```|~~~)/u.test(r)&&(i=!i),n+=r.length+1,r.trim()===""&&!i&&(e=n);return e<t.length?e:0}_trimIncompleteTail(t){let s=t.lastIndexOf("<");if(s!==-1&&!t.includes(">",s))return t.slice(0,s);let i=this._earliestUnclosedTag(t);if(i!==-1)return t.slice(0,i);let e=t.lastIndexOf("[");if(e!==-1){let n=t.slice(e);if(!/\[[^\]]*\]\([^)]*\)/u.test(n))return t.slice(0,e)}return t}_earliestUnclosedTag(t){let s=new Set(["br","img","hr","input","meta","link","area","base","col","embed","source","track","wbr"]),i=/<(\/?)([a-zA-Z][\w-]*)\b[^>]*?(\/?)>/gu,e=[];for(let n=i.exec(t);n;n=i.exec(t)){let[,r,a,l]=n,h=a.toLowerCase();if(!(s.has(h)||l==="/"))if(r==="/"){for(let g=e.length-1;g>=0;g--)if(e[g].name===h){e.splice(g);break}}else e.push({name:h,index:n.index})}return e.length?e[0].index:-1}};function W(o){let t=new f;return t.push(o),t.finalize()}var Y=async o=>await new Promise(t=>setTimeout(t,o));async function*Z(o,{chunkSize:t=15,delay:s=50}={}){let i=new f;for(let e=0;e<o.length;e+=t)yield i.push(o.slice(e,e+t)),await Y(s);yield i.finalize()}var J=Object.defineProperty,K=Object.getOwnPropertyDescriptor,u=(o,t,s,i)=>{for(var e=i>1?void 0:i?K(t,s):t,n=o.length-1,r;n>=0;n--)(r=o[n])&&(e=(i?r(t,s,e):r(e))||e);return i&&e&&J(t,s,e),e},O=o=>!o||typeof o!="object"?!1:o.name==="AbortError";async function*z(o,t,s,i,e=!1){if(e){if(i?.aborted){yield{type:"cancelled",log:s,runId:t};return}yield{type:"block-data",blockType:"text",data:{parts:W(o)},runId:t};return}for await(let n of Z(o)){if(i?.aborted){yield{type:"cancelled",log:s,runId:t};return}yield{type:"block-data",blockType:"text",data:{parts:n},runId:t}}}var p=class extends H{constructor(o){super(o),this.view=null,this.streamingDisabled=!1,this.loading=!1,this.processing=!1,this.processingStep=""}async load(){this._set("loading",!0);try{await this._initialize()}finally{this._set("loading",!1)}}destroy(){this.orchestrator?.dispose(),super.destroy()}async _initialize(){this.removeHandles(),await Promise.all([this.portal.load(),this.view?.when()]),this.view&&await U(()=>!this.view.updating),this._set("orchestrator",await L.init({agents:[...this.agents],view:this.view??void 0})),this.addHandles([B(()=>[this.view,this.agents],()=>{this._initialize()})])}clearChatHistory(){this.orchestrator?.newConversation()}async*ask(o,t){if(!this.orchestrator)throw new Error("Orchestrator not initialized yet.");this._set("processing",!0),this._set("processingStep","");let s=[],i,e="pending";try{let n=this.orchestrator.ask(o);for await(let r of n)switch(e=r.runId,r.type){case"trace":{this._set("processingStep",r.data.text),s.push(r.data.text);break}case"completed":{this._set("processing",!1),this._set("processingStep","");let a=r.result,l=!!a.content.length,h=!!i?.length;if(!l&&!h){yield{type:"completed",error:"No response received.",log:s,runId:e};return}let g=a.content;if(yield{type:"block-start",blockType:"text",runId:e},yield*z(g,e,s,t,this.streamingDisabled),yield{type:"block-end",blockType:"text",runId:e},h)for(let v of i){if(t?.aborted){yield{type:"cancelled",log:s,runId:e};return}let{type:b,data:w}=v;if(yield{type:"block-start",blockType:b,runId:e},b==="text"){let M=typeof w?.content=="string"?w.content:"";yield*z(M,e,s,t,this.streamingDisabled)}else yield{type:"block-data",blockType:b,data:w,runId:e};yield{type:"block-end",blockType:b,runId:e}}yield{type:"completed",response:g,blocks:i,log:s,runId:e};return}case"ux-suggestion":{let a=r.suggestion;i=i?[...i,a]:[a];break}case"interrupt":{let{kind:a,message:l,metadata:h}=r.interrupt,g=Array.isArray(h)?h.filter(b=>typeof b=="string"):[],v=(()=>{switch(a){case"booleanChoice":return{type:"boolean-choice",message:l,options:g};case"singleSelection":return{type:"single-select",message:l,options:g};case"multipleSelection":return{type:"multi-select",message:l,options:g};case"textInput":return{type:"text-input",message:l};default:return{type:a,message:l,options:g}}})();this._set("processingStep","Waiting for user input..."),yield{type:"interrupt",payload:v,runId:e};break}case"cancelled":{yield{type:"cancelled",log:s,runId:e};return}case"error":{if(t?.aborted||O(r.error)){yield{type:"cancelled",log:s,runId:e};return}yield{type:"completed",error:r.error.message,log:s,runId:e};return}default:{console.warn("Unknown event type:",r);break}}}catch(n){if(t?.aborted||O(n)){yield{type:"cancelled",log:s,runId:e};return}console.warn("Error during message processing:",n),yield{type:"completed",error:"An error occurred during message processing.",log:s,runId:"error"};return}finally{this._set("processing",!1)}}cancel(){this.orchestrator?.cancel()}};u([m({readOnly:!0})],p.prototype,"orchestrator",2);u([m()],p.prototype,"agents",2);u([m()],p.prototype,"portal",2);u([m()],p.prototype,"view",2);u([m()],p.prototype,"streamingDisabled",2);u([m({readOnly:!0})],p.prototype,"loading",2);u([m({readOnly:!0})],p.prototype,"processing",2);u([m({readOnly:!0})],p.prototype,"processingStep",2);p=u([F("OrchestratorController")],p);var Q="Embeddings resource 'embeddings-v01.json' not found in the webmap portal item.",X="Embeddings not found for this web map.",tt="https://developers.arcgis.com/javascript/latest/agentic-apps/ai-webmap-setup/#embeddings",x=class extends T{constructor(){super(...arguments),this._messages=D({blocking:!0}),this.#t=_(),this.#l=_(),this.#s=_(),this.#e=null,this.#r=new Map,this.#i=j.getDefault(),this.#a=t=>{t.stopPropagation(),this.cancelInterrupt()},this.#n=t=>{t.stopPropagation();let s=t.detail;this.submitInterrupt(s)},this.#c=t=>{t.stopPropagation(),this.keepSuggestedPrompts||(this.suggestedPrompts=[]);let s=t.detail;this._inputValue="",this.arcgisSubmit.emit(s),this.submitMessage(s)},this.#h=t=>{if(this._canceling=!0,t.stopPropagation(),this.arcgisCancel.emit(),this._interrupt){this.orchestrator?.cancelInterrupt(),this._interrupt=null;return}this._orchestratorController?.cancel(),this.#e?.abort(),this.#e=null},this.#g=t=>{t.stopPropagation();let s=t.detail;this.arcgisFeedback.emit(s)},this.#d=t=>{t.stopPropagation();let s=t.detail;this._inputValue=s.prompt,this.arcgisPromptSelect.emit(s)},this.#p=t=>{this.arcgisSlottableRequest.emit(t.detail)},this._orchestratorController=null,this._interrupt=null,this._interruptDetails=[],this._error=null,this._inputValue="",this._isAnswering=!1,this._canceling=!1,this.messages=new N([]),this.referenceElement=null,this.suggestedPrompts=[],this.feedbackEnabled=!1,this.keepSuggestedPrompts=!1,this.streamingDisabled=!1,this.logEnabled=!1,this.copyEnabled=!1,this.voiceInputEnabled=!1,this.readAloudEnabled=!1,this.assistantAvatarEnabled=!1,this.arcgisCancel=d(),this.arcgisError=d(),this.arcgisFeedback=d(),this.arcgisInterrupt=d(),this.arcgisInterruptCancel=d(),this.arcgisInterruptSubmit=d(),this.arcgisPromptSelect=d(),this.arcgisReady=d(),this.arcgisSubmit=d(),this.arcgisSlottableRequest=d({bubbles:!1,composed:!1}),this.arcgisResponse=d()}static{this.properties={_orchestratorController:16,_interrupt:16,_interruptDetails:16,_error:16,_inputValue:16,_isAnswering:16,_signedInUserId:16,_canceling:16,_isSignedIn:16,_user:16,awaitingResponse:32,awaitingResponseStep:32,interrupt:32,messages:0,orchestrator:32,entryMessage:1,heading:1,description:1,referenceElement:1,suggestedPrompts:0,feedbackEnabled:5,keepSuggestedPrompts:5,streamingDisabled:5,logEnabled:5,copyEnabled:5,voiceInputEnabled:5,readAloudEnabled:5,assistantAvatarEnabled:5}}static{this.styles=G}#t;#l;#s;#e;#r;#i;#a;#n;#c;#h;#g;#d;#p;async#o(){try{let t=R(this.el,this.referenceElement);await t?.componentOnReady();let s=[...this.#r.values()];return s.length?(this._orchestratorController?.destroy(),this._orchestratorController=new p({agents:s,portal:this.#i,streamingDisabled:this.streamingDisabled,view:t?.view}),await this._orchestratorController.load(),!0):(this._error="No agents found.",!1)}catch(t){return this._error=t?.message??"Error initializing orchestrator.",P(this)(t),!1}}get _isSignedIn(){return!!this.#i?.user||!!this._signedInUserId}get _user(){return this.#i?.user?.fullName||this.#i?.user?.username}get awaitingResponse(){return this._orchestratorController?.processing??!1}get awaitingResponseStep(){return this._orchestratorController?.processingStep??""}get interrupt(){return this._interrupt}get orchestrator(){return this._orchestratorController?.orchestrator}async clearChatHistory(){this._reset(),this._orchestratorController?.clearChatHistory()}cancelInterrupt(){this.arcgisInterruptCancel.emit(),this.orchestrator?.cancelInterrupt(),this._interrupt=null}register(t){this.#r.set(t.agent.id,t),this._orchestratorController&&this.#o()}unregister(t){this.#r.delete(t),this._orchestratorController&&this.#o()}async submitMessage(t){let s=t.trim();if(!s||(this.messages.push({id:Date.now().toString(),role:"user",content:s}),!this._orchestratorController))return;this.#e=new AbortController,this._orchestratorController.streamingDisabled=this.streamingDisabled;let i=this._orchestratorController.ask(s,this.#e?.signal);for await(let e of i){let n=e.runId,r=this.messages.at(-1);switch(e.type){case"block-start":{this._isAnswering=!0;let a={type:e.blockType,isPending:!0};if(r?.role==="assistant"&&r.id===n){let l=[...r.blocks??[],a];this.messages.splice(-1,1,{...r,blocks:l})}else this.messages.push({role:"assistant",blocks:[a],id:n,isStreaming:!0,interrupts:this._interruptDetails}),this._interruptDetails=[];break}case"block-data":{if(r?.role!=="assistant"||r?.id!==n)break;let a=[...r.blocks??[]],l=a[a.length-1],{blockType:h,data:g}=e;if(l?.type!==h||!l.isPending)break;h==="text"?a[a.length-1]={...l,data:{...l.data,parts:g?.parts}}:a[a.length-1]={...l,data:{...l.data,...g??{}}},this.messages.splice(-1,1,{...r,blocks:a});break}case"block-end":{if(r?.role!=="assistant"||r?.id!==n)break;let a=[...r.blocks??[]],l=a[a.length-1];if(l?.type!==e.blockType||!l.isPending)break;let h=l;a[a.length-1]={...h,data:{...h.data},isPending:!1},this.messages.splice(-1,1,{...r,blocks:a});break}case"completed":e.error?(this.messages.push({role:"assistant",log:e.log,error:e.error,id:n,interrupts:this._interruptDetails}),this._interruptDetails=[]):r?.role==="assistant"&&r.id===n&&this.messages.splice(-1,1,{...r,content:e.response,blocks:r.blocks?.map(a=>({...a,data:{...a.data},isPending:!1}))??[],isStreaming:!1,log:e.log}),this._isAnswering=!1,this.#e=null,this._canceling=!1;break;case"interrupt":this._interrupt={...e.payload,id:n},this.arcgisInterrupt.emit(this._interrupt);break;case"cancelled":r?.role==="assistant"&&r.id===n?this.messages.splice(-1,1,{...r,blocks:r.blocks?.filter(a=>a.type==="text"||!a.isPending)??[],isStreaming:!1,log:e.log,error:"(Stopped by user)"}):(this.messages.push({role:"assistant",log:e.log,error:"(Stopped by user)",id:n,interrupts:this._interruptDetails}),this._interruptDetails=[]),this._isAnswering=!1,this.#e=null,this._canceling=!1;break}}}submitInterrupt(t){this.arcgisInterruptSubmit.emit(t),this._interrupt&&(this._interruptDetails=[...this._interruptDetails,{interrupt:this._interrupt,response:t}]),this.orchestrator?.resumeInterrupt(t),this._interrupt=null}load(){this.manager.onLifecycle(this._reset.bind(this))}loaded(){this.manager.onLifecycle(()=>{this.#t.value?.addEventListener("arcgisPromptSelect",this.#d),this.#t.value?.addEventListener("arcgisSubmit",this.#c),this.#t.value?.addEventListener("arcgisCancel",this.#h),this.#t.value?.addEventListener("arcgisFeedback",this.#g);let t=V(()=>!!this._interrupt&&!!this.#s.value,()=>{let i=this.#s.value;i.removeEventListener("arcgisSubmit",this.#n),i.removeEventListener("arcgisCancel",this.#a),i.addEventListener("arcgisSubmit",this.#n,{once:!0}),i.addEventListener("arcgisCancel",this.#a,{once:!0})}),s=this.messages.on("after-add",i=>{let e=i.item;e.role==="assistant"&&(e.error||e.content)&&this.arcgisResponse.emit(e)});return queueMicrotask(()=>{this.#o().then(i=>{i?this.arcgisReady.emit():this._error&&this.arcgisError.emit(new Error(this._error))})}),()=>{t.remove(),s.remove(),this.#t.value?.removeEventListener("arcgisPromptSelect",this.#d),this.#s.value?.removeEventListener("arcgisSubmit",this.#n),this.#s.value?.removeEventListener("arcgisCancel",this.#a),this.#t.value?.removeEventListener("arcgisSubmit",this.#c),this.#t.value?.removeEventListener("arcgisCancel",this.#h),this.#t.value?.removeEventListener("arcgisFeedback",this.#g),this._orchestratorController?.destroy(),this._orchestratorController=null}})}_reset(){this._orchestratorController?.cancel(),this.#e?.abort(),this._interrupt=null,this.messages.removeAll(),this._error=null,this._inputValue="",this._signedInUserId=void 0}_renderEntryMessage(){return this._isSignedIn?this._error?this._renderErrorNotice():this.entryMessage?this.messages.length>0?null:c`<calcite-notice open kind=brand closable icon width=full><div slot=message>${this.entryMessage}</div></calcite-notice>`:c`<slot name=entry-message></slot>`:this._renderSignInNotice()}_renderSignInNotice(){let t=this.#i;return c`<calcite-notice slot=entry-message open kind=brand icon width=full><div slot=message>You need to sign in to use the assistant chat.</div>${t?c`<calcite-link slot=link @click=${async()=>{try{let s=await q.getCredential(`${t.url}/sharing`);this._signedInUserId=s.userId,this._error=null,this.requestUpdate(),await this.#o()?this.arcgisReady.emit():this._error&&this.arcgisError.emit(new Error(this._error))}catch(s){this._error=s?.message??"Error signing in.",this.arcgisError.emit(new Error(this._error)),C("error",this,"Error signing in:",{detail:{error:s}})}}} target=_blank title="Sign in to ArcGIS Online">Sign in</calcite-link>`:c`<div slot=link>No portal information available</div>`}</calcite-notice>`}_renderErrorNotice(){return this._error?c`<calcite-notice slot=entry-message open kind=brand icon width=full>${this._error===Q?c`<div slot=message>${X}</div><calcite-link slot=link .href=${tt} target=_blank title="Learn about web map embeddings">Read more</calcite-link>`:c`<div slot=message>${this._error}</div>`}</calcite-notice>`:null}render(){return c`<calcite-panel .loading=${!this._orchestratorController&&!this._error||this._orchestratorController?.loading} .heading=${this.heading??this._messages.assistantLabel} .description=${this.description} ${y(this.#t)}><slot name=header-actions-start slot=header-actions-start></slot><slot name=header-actions-end slot=header-actions-end></slot><div class="content-container"><arcgis-assistant-chat .loading=${this.awaitingResponse} .messages=${this.messages} .interrupt=${this._interrupt}><slot name=message-starter slot=message-starter></slot><slot name=messages slot=messages>${this.messages.map(t=>t.role==="assistant"?c`<arcgis-assistant-message .message=${t} .feedbackEnabled=${this.feedbackEnabled} .logEnabled=${this.logEnabled} .copyEnabled=${this.copyEnabled} .readAloudEnabled=${this.readAloudEnabled} @arcgisSlottableRequest=${this.#p} .assistantAvatarEnabled=${this.assistantAvatarEnabled}>${t.blocks?.map((s,i)=>c`<slot name=${I(t.id,i)??k} slot=${I(t.id,i)??k}><arcgis-assistant-message-block .block=${s}></arcgis-assistant-message-block></slot>`)}</arcgis-assistant-message>`:c`<arcgis-assistant-user-message .message=${t} .user=${this._user}></arcgis-assistant-user-message>`)}</slot>${this._interrupt?c`<div slot=message-loading><div class="interrupt-waiting-message">waiting for user input...</div></div>`:c`<slot name=message-loading slot=message-loading><arcgis-assistant-message-loading .loading=${this.awaitingResponse} .loadingMessage=${this.awaitingResponseStep} .assistantAvatarEnabled=${this.assistantAvatarEnabled} .interrupts=${this._interruptDetails}></arcgis-assistant-message-loading></slot>`}</arcgis-assistant-chat></div>${this._interrupt?c`<slot name=interrupt><arcgis-assistant-interrupt slot=content-bottom .type=${this._interrupt.type} .message=${this._interrupt.message} .options=${this._interrupt.options} ${y(this.#s)}></arcgis-assistant-interrupt></slot>`:this.suggestedPrompts?.length?c`<div class="suggested-prompts-container" slot=content-bottom><arcgis-assistant-suggested-prompts class="suggested-prompts" .prompts=${this.suggestedPrompts}></arcgis-assistant-suggested-prompts></div>`:null}<div class="footer-container" slot=footer>${this._renderEntryMessage()}<slot name=chat-entry><arcgis-assistant-chat-entry .awaitingResponse=${this.awaitingResponse||this._isAnswering} .inputValue=${this._inputValue} .messages=${this.messages} .voiceInputEnabled=${this.voiceInputEnabled} .disabled=${this._canceling||!this._isSignedIn||!!this._interrupt} ${y(this.#l)}><slot name=entry-actions-start slot=entry-actions-start></slot><slot name=entry-actions-end slot=entry-actions-end><calcite-button .iconStart=${this.awaitingResponse||this._isAnswering?"circle-stop":"send"} @click=${()=>{this.#l.value?.submitMessage()}} round>${this.awaitingResponse||this._isAnswering?this._messages.stopButtonLabel:this._messages.askButtonLabel}</calcite-button></slot></arcgis-assistant-chat-entry></slot><slot name=footer-content></slot></div></calcite-panel>`}};A("arcgis-assistant",x);return x},"core/Collection","core/reactiveUtils","portal/Portal","request","identity/IdentityManager","config","layers/FeatureLayer","core/Accessor","core/accessorSupport/decorators",a,b)
|
|
@@ -0,0 +1,2 @@
|
|
|
1
|
+
/* COPYRIGHT Esri - https://js.arcgis.com/5.2/LICENSE.txt */
|
|
2
|
+
import{a as s}from"./ONQ6JSBJ.js";import{Dc as o}from"./AI6DYOKR.js";import{a as i}from"./VXFQANGJ.js";var n=async t=>{t.map?.allLayers.filter(e=>e.type==="feature")?.forEach(e=>{let r=e;r.featureEffect&&(r.featureEffect=null)});let a=t.map.initialViewProperties?.viewpoint?.targetGeometry;return a?(await t.goTo(a),"Cleared all filters and returned to home extent."):"Cleared all filters. Could not determine home extent."},l=async(t,a)=>{let{mapView:e}=s(a,["mapView"]);return await n(e)},c=o(l,{name:"resetMap",description:"Clears all feature effects/filters from the map AND zooms to the home extent (initial map view). Use when user says 'reset map', 'reset the map', 'start over', or wants to both clear filters and return to the initial view.",schema:i.object({})});export{c as a};
|
|
@@ -0,0 +1,2 @@
|
|
|
1
|
+
/* COPYRIGHT Esri - https://js.arcgis.com/5.2/LICENSE.txt */
|
|
2
|
+
import q from"./323DHVYA.js";import p from"./ONMNQBPO.js";import n from"./S6OYR4VI.js";import l from"./LCFIADOZ.js";import"./QVOMX3R6.js";import k from"./T2GJLEYV.js";import j from"./Q4IQUEZN.js";import h from"./WS3T73IY.js";import g from"./4MFEKBKL.js";import f from"./CCC6LBMY.js";import"./34O57OGV.js";import{a as o,c as m}from"./V6HOUZPZ.js";import"./77QFSIWW.js";import"./FDOMMK2M.js";import e from"./4YXYLX4H.js";import"./5PJXNTLZ.js";import"./EAEQONP7.js";import d from"./RU2T7GUX.js";import"./DYASSC7Z.js";import"./DY36ATOA.js";import"./CGXQAB3A.js";import"./3UEKINYC.js";import"./RLEHNAIA.js";import c from"./AT4XVTJR.js";import"./7M6VKBTK.js";import"./BS2PFNU4.js";import"./UIXX3XEN.js";import b from"./KA3FF3ZO.js";import a from"./QNNGPA3Q.js";import"./ONQ6JSBJ.js";import{v as i,z as r}from"./6TA5KFAQ.js";import"./R74ZHFA6.js";import"./7VAQUCBU.js";import"./VOKXKU7M.js";import"./EWLXNGKH.js";import"./AI6DYOKR.js";import"./VXFQANGJ.js";import"./MWYBF3F3.js";import"./UZLQALHY.js";export default $arcgis.t(([,,,,,,,,,,,,,,,,,,,,,,,,p])=>{var t=class extends i{constructor(){super(...arguments),this.agent=p}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=o(this,"arcgis-assistant-layer-styling-agent"),this.#i=m(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,e,f,g,h,j,k,l,n,p,q)
|
|
@@ -1,2 +1,2 @@
|
|
|
1
1
|
/* COPYRIGHT Esri - https://js.arcgis.com/5.2/LICENSE.txt */
|
|
2
|
-
import{c as i,e as c}from"./
|
|
2
|
+
import{c as i,e as c}from"./ZLWWWTH4.js";export default $arcgis.t(([m,{subclass:p}])=>{function a(t){return t?Object.keys(t.shape??{}):[]}function d(t){let e={};for(let n of t)for(let s of a(n))e[s]=void 0;return e}function g(t,e){return Object.fromEntries(e.filter(n=>Object.hasOwn(t,n)).map(n=>[n,t[n]]))}function l(t,e){return`${t.id}_${e}`}function h(t,e){let n=e.inputSchema;return n?{...g(t,a(n)),agentExecutionContext:t.agentExecutionContext,outputMessage:t.outputMessage,status:void 0,summary:""}:{...t,status:void 0,summary:""}}function x(t,e){return t.outputSchema?g(e,a(t.outputSchema)):{}}function y(t){let e={outputMessage:t.outputMessage,status:t.status,summary:t.summary};return t.agentExecutionContext&&(e.agentExecutionContext=t.agentExecutionContext),e}function v(t,e){return async(n,s)=>{let o=await t.run(h(n,t),s),r=x(t,o);return e||o.status==="failed"?{...r,...y(o)}:{...r,outputMessage:o.outputMessage}}}var w=Object.getOwnPropertyDescriptor,E=(t,e,n,s)=>{for(var o=s>1?void 0:s?w(e,n):e,r=t.length-1,u;r>=0;r--)(u=t[r])&&(o=u(o)||o);return o},f=class extends m{generate(){let t=this.getAgents();this.validateAgents(t);for(let r of t)r.generate();let e=d(t.flatMap(r=>r.getSchemas())),n=i(e),s=this.buildNodes(t),o=this.buildEdges(t);return{workspace:n,createGraph:()=>c(s,o,n,{entryNode:this.getEntryNode(t)})}}buildNodes(t){let e={};for(let[n,s]of t.entries())e[l(s,n)]=v(s,this.isTerminalAgent(t,n));return e}validateAgents(t){if(!t.length)throw new Error("Workflow requires at least one agent.")}};f=E([p("BaseWorkflow")],f);return{a:a,b:d,c:l,d:f}},"core/Accessor","core/accessorSupport/decorators")
|