@arcgis/ai-components 5.2.0-next.3 → 5.2.0-next.30

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (207) hide show
  1. package/dist/agent-utils/FunctionAgent.d.ts +2 -2
  2. package/dist/agent-utils/LLMAgent.d.ts +2 -2
  3. package/dist/agent-utils/LLMAgent.js +23 -22
  4. package/dist/agent-utils/WorkflowAgent.d.ts +2 -2
  5. package/dist/agent-utils/index.d.ts +177 -0
  6. package/dist/agent-utils/index.js +167 -0
  7. package/dist/agent-utils/middlewares/trace.d.ts +2 -0
  8. package/dist/agent-utils/middlewares/trace.js +25 -33
  9. package/dist/agent-utils/tools/FunctionTool.d.ts +2 -2
  10. package/dist/agent-utils/types.d.ts +36 -7
  11. package/dist/agent-utils/workflows/ConditionalWorkflow.d.ts +2 -2
  12. package/dist/agent-utils/workflows/LoopWorkflow.d.ts +2 -2
  13. package/dist/agent-utils/workflows/ParallelWorkflow.d.ts +2 -2
  14. package/dist/agent-utils/workflows/RouterWorkflow.d.ts +2 -2
  15. package/dist/agent-utils/workflows/SequentialWorkflow.d.ts +2 -2
  16. package/dist/agent-utils/workflows/SwitchWorkflow.d.ts +2 -2
  17. package/dist/cdn/27NEUQN3.js +2 -0
  18. package/dist/cdn/2NMR43NW.js +2 -0
  19. package/dist/cdn/3AXQTBIA.js +134 -0
  20. package/dist/cdn/434TAA3J.js +2 -0
  21. package/dist/cdn/4I4MCV7V.js +71 -0
  22. package/dist/cdn/4RZPOYZ7.js +9 -0
  23. package/dist/cdn/5SBLS4NW.js +2 -0
  24. package/dist/cdn/{AMP6IALT.js → 5W7S2RS4.js} +1 -1
  25. package/dist/cdn/6LZ6GOHF.js +56 -0
  26. package/dist/cdn/7IFCBXV7.js +2 -0
  27. package/dist/cdn/ADYIXCSG.js +2 -0
  28. package/dist/cdn/AFLQZIKS.js +180 -0
  29. package/dist/cdn/AMVOJNWN.js +2 -0
  30. package/dist/cdn/C7E7MJSR.js +2 -0
  31. package/dist/cdn/CAECQD75.js +2 -0
  32. package/dist/cdn/CIW3QMKV.js +2 -0
  33. package/dist/cdn/CJIV4KJZ.js +179 -0
  34. package/dist/cdn/CVHJMR5X.js +2 -0
  35. package/dist/cdn/DEAYZ3MK.js +2 -0
  36. package/dist/cdn/{H7422XUG.js → E2HENO3T.js} +1 -1
  37. package/dist/cdn/E7TMP4YV.js +3 -0
  38. package/dist/cdn/EBRNMPPO.js +48 -0
  39. package/dist/cdn/FWU6DFIB.js +2 -0
  40. package/dist/cdn/HBYZSLEZ.js +22 -0
  41. package/dist/cdn/HOCTVCHH.js +2 -0
  42. package/dist/cdn/{4HU7735A.js → HXOSLGWU.js} +6 -4
  43. package/dist/cdn/I64KIZG3.js +2 -0
  44. package/dist/cdn/IB4WTK74.js +2 -0
  45. package/dist/cdn/IC5P5NYY.js +2 -0
  46. package/dist/cdn/IGZWQJW7.js +3 -0
  47. package/dist/cdn/IKEF7ZHH.js +181 -0
  48. package/dist/cdn/IXAKT6L3.js +2 -0
  49. package/dist/cdn/JEIMRNYM.js +2 -0
  50. package/dist/cdn/JN744CAW.js +2 -0
  51. package/dist/cdn/KRE4U7V7.js +2 -0
  52. package/dist/cdn/{NE7E52YR.js → KTK4HNL2.js} +8 -2
  53. package/dist/cdn/L77BTGXY.js +2 -0
  54. package/dist/cdn/LEPJUN3X.js +22 -0
  55. package/dist/cdn/LODKJRS4.js +2 -0
  56. package/dist/cdn/M3SWPT3M.js +2 -0
  57. package/dist/cdn/MAV3DW27.js +4 -0
  58. package/dist/cdn/NOJYPREL.js +3 -0
  59. package/dist/cdn/NXKKG5TK.js +2 -0
  60. package/dist/cdn/O3F47IO5.js +2 -0
  61. package/dist/cdn/O7TGCM5P.js +6 -0
  62. package/dist/cdn/PBTINZTK.js +65 -0
  63. package/dist/cdn/PKHQW7QU.js +18 -0
  64. package/dist/cdn/PSWI3MFB.js +2 -0
  65. package/dist/cdn/Q73PK7Q7.js +2 -0
  66. package/dist/cdn/Q7TL5Q5N.js +2 -0
  67. package/dist/cdn/QSA4T3BU.js +2 -0
  68. package/dist/cdn/RMLXVQZ5.js +2 -0
  69. package/dist/cdn/RX45PCYB.js +9 -0
  70. package/dist/cdn/S27EJSLC.js +14 -0
  71. package/dist/cdn/SMADRJ67.js +2 -0
  72. package/dist/cdn/{ZLXN7NMF.js → T537PKP4.js} +9 -7
  73. package/dist/cdn/{X2ZDYHCG.js → TNMXWUXU.js} +9 -4
  74. package/dist/cdn/TSEQVE2H.js +36 -0
  75. package/dist/cdn/VKU4WAQV.js +2 -0
  76. package/dist/cdn/W2IHPJ54.js +34 -0
  77. package/dist/cdn/W2JAKE2M.js +2 -0
  78. package/dist/cdn/WAVKMZA6.js +2 -0
  79. package/dist/cdn/WDE3HN7K.js +2 -0
  80. package/dist/cdn/WH6QQK6N.js +2 -0
  81. package/dist/cdn/WNS5ZUF5.js +2 -0
  82. package/dist/cdn/{FL4W4VYN.js → X7GE26KU.js} +16 -0
  83. package/dist/cdn/XVQJBUMY.js +2 -0
  84. package/dist/cdn/YJ3QQXF6.js +2 -0
  85. package/dist/cdn/YRBANNQ5.js +2 -0
  86. package/dist/cdn/YYY7HKYX.js +2 -0
  87. package/dist/cdn/ZEYIBYSF.js +66 -0
  88. package/dist/cdn/ZMSJQB65.js +99 -0
  89. package/dist/cdn/ZOSUDIJH.js +2 -0
  90. package/dist/cdn/ZPLFFLPF.js +2 -0
  91. package/dist/cdn/agent-utils/index.js +2 -0
  92. package/dist/cdn/agent-utils/middlewares/humanInTheLoop.js +3 -0
  93. package/dist/cdn/agent-utils/middlewares/middleware.js +2 -0
  94. package/dist/cdn/agent-utils/middlewares/trace.js +2 -0
  95. package/dist/cdn/index.js +1 -1
  96. package/dist/cdn/main.css +1 -1
  97. package/dist/chunks/adapter.js +1794 -1597
  98. package/dist/chunks/arcgisKnowledgeGraph.js +126 -71
  99. package/dist/chunks/arcgis_knowledge_current_lc_context.js +19 -2
  100. package/dist/chunks/arcgis_knowledge_current_map_context.js +31 -2
  101. package/dist/chunks/arcgis_knowledge_cypher_query_prompt.js +102 -0
  102. package/dist/chunks/arcgis_knowledge_summarize_result_prompt.js +116 -27
  103. package/dist/chunks/converterUtils.js +39 -32
  104. package/dist/chunks/dataExplorationGraph.js +139 -113
  105. package/dist/chunks/data_explore_query_prompt.js +9 -4
  106. package/dist/chunks/generateLayerDescriptions.js +231 -191
  107. package/dist/chunks/helpGraph.js +17 -13
  108. package/dist/chunks/help_prompt.js +34 -17
  109. package/dist/chunks/index.js +11 -0
  110. package/dist/chunks/intent_prompt.js +16 -0
  111. package/dist/chunks/layerStylingGraph.js +24 -20
  112. package/dist/chunks/navigationGraph.js +33 -28
  113. package/dist/chunks/navigation_intent_prompt.js +8 -2
  114. package/dist/chunks/orchestrator.js +267 -226
  115. package/dist/chunks/slottableRequestUtils.js +3 -7
  116. package/dist/chunks/state.js +1 -1
  117. package/dist/chunks/summarize_query_response_prompt.js +9 -7
  118. package/dist/chunks/toolCallResponse.js +12 -9
  119. package/dist/chunks/utils2.js +8 -8
  120. package/dist/components/arcgis-assistant/customElement.d.ts +27 -0
  121. package/dist/components/arcgis-assistant/customElement.js +385 -152
  122. package/dist/components/arcgis-assistant/index.js +2 -3
  123. package/dist/components/arcgis-assistant/types.d.ts +14 -1
  124. package/dist/components/arcgis-assistant-agent/customElement.js +5 -1
  125. package/dist/components/arcgis-assistant-chat/customElement.d.ts +8 -2
  126. package/dist/components/arcgis-assistant-chat/customElement.js +23 -18
  127. package/dist/components/arcgis-assistant-chat-entry/customElement.d.ts +4 -1
  128. package/dist/components/arcgis-assistant-chat-entry/customElement.js +25 -18
  129. package/dist/components/arcgis-assistant-data-exploration-agent/customElement.js +11 -5
  130. package/dist/components/arcgis-assistant-help-agent/customElement.js +8 -2
  131. package/dist/components/arcgis-assistant-interrupt/customElement.d.ts +4 -1
  132. package/dist/components/arcgis-assistant-interrupt/customElement.js +12 -8
  133. package/dist/components/arcgis-assistant-interrupt-preview/customElement.js +20 -0
  134. package/dist/components/arcgis-assistant-interrupt-preview/index.js +2 -0
  135. package/dist/components/arcgis-assistant-knowledge-agent/customElement.d.ts +7 -7
  136. package/dist/components/arcgis-assistant-knowledge-agent/customElement.js +17 -11
  137. package/dist/components/arcgis-assistant-layer-styling-agent/customElement.js +10 -4
  138. package/dist/components/arcgis-assistant-message/customElement.d.ts +23 -0
  139. package/dist/components/arcgis-assistant-message/customElement.js +28 -26
  140. package/dist/components/arcgis-assistant-message/index.d.ts +1 -0
  141. package/dist/components/arcgis-assistant-message/index.js +2 -0
  142. package/dist/components/arcgis-assistant-message-block/customElement.d.ts +1 -1
  143. package/dist/components/arcgis-assistant-message-block/customElement.js +18 -11
  144. package/dist/components/arcgis-assistant-message-block/index.js +1 -0
  145. package/dist/components/arcgis-assistant-message-feedback/customElement.d.ts +4 -1
  146. package/dist/components/arcgis-assistant-message-footer/customElement.d.ts +4 -1
  147. package/dist/components/arcgis-assistant-message-loading/customElement.d.ts +8 -1
  148. package/dist/components/arcgis-assistant-message-loading/customElement.js +8 -8
  149. package/dist/components/arcgis-assistant-message-loading/index.js +1 -0
  150. package/dist/components/arcgis-assistant-message-log/customElement.d.ts +4 -1
  151. package/dist/components/arcgis-assistant-message-read-aloud/customElement.d.ts +4 -1
  152. package/dist/components/arcgis-assistant-message-text/customElement.d.ts +5 -1
  153. package/dist/components/arcgis-assistant-message-text/customElement.js +12 -12
  154. package/dist/components/arcgis-assistant-navigation-agent/customElement.js +11 -5
  155. package/dist/components/arcgis-assistant-speech-input/customElement.d.ts +6 -1
  156. package/dist/components/arcgis-assistant-suggested-prompts/customElement.d.ts +4 -1
  157. package/dist/components/arcgis-assistant-suggested-prompts/customElement.js +8 -8
  158. package/dist/components/arcgis-assistant-user-message/customElement.d.ts +4 -1
  159. package/dist/components/arcgis-assistant-user-message/customElement.js +10 -8
  160. package/dist/docs/api.json +1 -1
  161. package/dist/docs/docs.json +1 -1
  162. package/dist/docs/vscode.html-custom-data.json +1 -1
  163. package/dist/docs/web-types.json +1 -1
  164. package/dist/index.d.ts +4 -0
  165. package/dist/loader.js +7 -6
  166. package/dist/types/lumina.d.ts +11 -5
  167. package/dist/types/preact.d.ts +12 -5
  168. package/dist/types/react.d.ts +13 -5
  169. package/dist/types/stencil.d.ts +11 -5
  170. package/dist/utils/index.d.ts +85 -42
  171. package/dist/utils/index.js +54 -49
  172. package/package.json +8 -7
  173. package/dist/cdn/2AXF774U.js +0 -2
  174. package/dist/cdn/3PKJWIC3.js +0 -2
  175. package/dist/cdn/462JBSEV.js +0 -422
  176. package/dist/cdn/5QAHYX7Y.js +0 -5
  177. package/dist/cdn/7BCR6TUO.js +0 -2
  178. package/dist/cdn/7GH7VSB2.js +0 -2
  179. package/dist/cdn/7PLV4QH6.js +0 -2
  180. package/dist/cdn/AO7BQHKC.js +0 -2
  181. package/dist/cdn/AXDZBBNL.js +0 -45
  182. package/dist/cdn/DDLZOMUY.js +0 -2
  183. package/dist/cdn/DHOVCT6R.js +0 -2
  184. package/dist/cdn/F2AHA4GB.js +0 -54
  185. package/dist/cdn/FHVXO2WG.js +0 -166
  186. package/dist/cdn/FX5JFRDL.js +0 -2
  187. package/dist/cdn/GSEPHN3A.js +0 -106
  188. package/dist/cdn/HB5A5R2E.js +0 -2
  189. package/dist/cdn/JY6LLOUJ.js +0 -22
  190. package/dist/cdn/KMQ3SP4I.js +0 -5
  191. package/dist/cdn/MDVYQQUG.js +0 -14
  192. package/dist/cdn/MH5RPXHM.js +0 -2
  193. package/dist/cdn/NAUXSHIE.js +0 -72
  194. package/dist/cdn/NVI3I46B.js +0 -2
  195. package/dist/cdn/OAVEHGB6.js +0 -2
  196. package/dist/cdn/OH64RMOR.js +0 -4
  197. package/dist/cdn/ON2V5XI2.js +0 -3
  198. package/dist/cdn/P6OPJQMC.js +0 -3
  199. package/dist/cdn/QR54T33D.js +0 -2
  200. package/dist/cdn/RVOAPUBN.js +0 -2
  201. package/dist/cdn/S6W6HV4T.js +0 -36
  202. package/dist/cdn/SXDLXCIM.js +0 -2
  203. package/dist/cdn/USMDJUFS.js +0 -2
  204. package/dist/cdn/V2P4AIGG.js +0 -2
  205. package/dist/cdn/V5YEZSRY.js +0 -16
  206. package/dist/cdn/Y333DGV6.js +0 -2
  207. package/dist/cdn/YY2SBO3V.js +0 -2
@@ -1,18 +1,21 @@
1
1
  /* COPYRIGHT Esri - https://js.arcgis.com/5.2/LICENSE.txt */
2
2
  import { StateGraph as d, START as g, END as i } from "@langchain/langgraph/web";
3
- import { l as h, g as x, f as p, r as f, t as y, H as u } from "./adapter.js";
3
+ import { l as h, g as f, f as p, r as x, t as y, H as u } from "./adapter.js";
4
4
  import "@arcgis/core/identity/IdentityManager.js";
5
5
  import "@arcgis/core/portal/Portal.js";
6
- import { j as S, s as c } from "./generateLayerDescriptions.js";
6
+ import "@arcgis/toolkit/string";
7
+ import { h as S } from "./generateLayerDescriptions.js";
7
8
  import "@langchain/core/messages";
8
9
  import "@langchain/core/callbacks/dispatch/web";
9
10
  import "@langchain/openai";
11
+ import "@arcgis/core/config.js";
10
12
  import "@arcgis/core/core/reactiveUtils.js";
11
13
  import "@arcgis/core/layers/FeatureLayer.js";
12
14
  import "@arcgis/core/request.js";
13
15
  import { ToolNode as E } from "@langchain/langgraph/prebuilt";
16
+ import { s as m } from "./index.js";
14
17
  import "@langchain/core/prompts";
15
- const m = [h], v = (e) => {
18
+ const c = [h], v = (e) => {
16
19
  if (!e || e.size === 0)
17
20
  return "No layers available in this map.";
18
21
  const t = Array.from(e.values()).map(({ layerItem: r, fieldRegistry: s }, l) => {
@@ -31,12 +34,13 @@ ${t}`;
31
34
  `) : "No agents currently available.";
32
35
  };
33
36
  async function _(e, t) {
34
- const r = await x("help_prompt"), s = p(t, "layersAndFieldsRegistry"), l = p(t, "agentRegistry");
37
+ const r = await f("help_prompt"), s = p(t, "layersAndFieldsRegistry"), l = p(t, "agentRegistry");
35
38
  try {
36
39
  const a = await S({
37
40
  promptText: r,
38
41
  modelTier: "fast",
39
- tools: m,
42
+ config: t,
43
+ tools: c,
40
44
  inputVariables: {
41
45
  layerSummary: v(s),
42
46
  agents: T(l),
@@ -65,16 +69,16 @@ async function _(e, t) {
65
69
  };
66
70
  }
67
71
  }
68
- const C = (e, t) => f(["agentRegistry"], "Help Agent")(e, t);
72
+ const C = (e, t) => x(["agentRegistry"], "Help Agent")(e, t);
69
73
  async function H(e, t) {
70
- const r = new E(m);
74
+ const r = new E(c, { handleToolErrors: !1 });
71
75
  try {
72
76
  const s = e.helpInternalState.toolCallMessage;
73
77
  if (!s)
74
78
  throw new Error("helpToolCalling: missing helpInternalState.toolCallMessage");
75
79
  const a = (await r.invoke({ messages: [s] }, t)).messages.map((o) => o.text).join(`
76
80
  `);
77
- return await c({ text: `Finished executing help tool: ${a}` }, t), {
81
+ return await m({ text: `Finished executing help tool: ${a}` }, t), {
78
82
  ...e,
79
83
  outputMessage: a,
80
84
  status: "success",
@@ -86,7 +90,7 @@ async function H(e, t) {
86
90
  };
87
91
  } catch (s) {
88
92
  const l = s instanceof Error ? s.message : String(s);
89
- return await c({ text: `Help tool execution failed: ${l}` }, t), {
93
+ return await m({ text: `Help tool execution failed: ${l}` }, t), {
90
94
  ...e,
91
95
  outputMessage: `Help tool execution failed: ${l}`,
92
96
  status: "failed",
@@ -107,11 +111,11 @@ const b = () => new d(u).addNode("requireHelpServices", C).addNode("agent", _).a
107
111
  _Example: “What can you do?”_
108
112
  _Example: “What can I ask”_
109
113
 
110
- Even if the user asks unrelated queries like "What are the vowels in English alphabet" or "How to cook", call this agent.
114
+ If the user asks unrelated queries like "What are the vowels in English alphabet" or "How to cook", call this agent so it can politely refuse and redirect to map-related questions.
111
115
 
112
- IF the user asks map related queries, but those that are not performed by any of the agents, call this agent so we can respond accordingly.
116
+ IF the user asks map related queries, but those that are not performed by any of the agents, call this agent so we can respond that the requested action is not supported.
113
117
  _Example: "Create a chart"_
114
- _Example: "Create a table"_`, D = {
118
+ _Example: "Create a table"_`, V = {
115
119
  id: "help",
116
120
  name: "Help Agent",
117
121
  description: M,
@@ -119,5 +123,5 @@ const b = () => new d(u).addNode("requireHelpServices", C).addNode("agent", _).a
119
123
  workspace: u
120
124
  };
121
125
  export {
122
- D as H
126
+ V as H
123
127
  };
@@ -1,7 +1,28 @@
1
1
  /* COPYRIGHT Esri - https://js.arcgis.com/5.2/LICENSE.txt */
2
- const e = `## Map Query Gate
2
+ const n = `## Who you are
3
3
 
4
- ### Input
4
+ You are a map assistant embedded inside a GIS application. You have no knowledge of history, science, people, events, cooking, or anything outside of this map and its data. You only know what is described in the Map Context below.
5
+
6
+ If asked anything outside of that context, you simply don't have that information — respond naturally and redirect to something you _can_ help with, using specific layer and field names from the map context.
7
+
8
+ Example of how to handle unknown topics:
9
+ "I don't have information on that — I only know about this map. You could ask me to list all layers in the map, or capabilities of this assistant."
10
+
11
+ ---
12
+
13
+ ## Your capabilities
14
+
15
+ You can help users with:
16
+
17
+ - Listing the layers in this map
18
+ - Listing the fields in a specific layer (use the tool)
19
+ - Suggesting specific queries using actual layer and field names
20
+ - Summarizing what this map contains and what users can do with it
21
+ - Letting users know when a map-related action isn't supported (e.g. charts, tables), and that it may be added in the future
22
+
23
+ ---
24
+
25
+ ## Input
5
26
 
6
27
  Assigned task:
7
28
  {assignedTask}
@@ -12,11 +33,13 @@ Latest user request:
12
33
  Prior steps:
13
34
  {priorSteps}
14
35
 
15
- Use the assigned task as the primary instruction for the current query. The question will **not** be restated again here.
16
- Use the latest user request as supporting context when needed.
17
- Use prior steps only when needed to explain a previous result, failure, or likely next action.
36
+ Use the assigned task as the primary instruction. The question will **not** be restated again here.
37
+ Use the latest user request as supporting context.
38
+ Use prior steps only to explain a previous result, failure, or likely next action.
39
+
40
+ ---
18
41
 
19
- ### Map Context
42
+ ## Map Context
20
43
 
21
44
  {layerSummary}
22
45
 
@@ -24,15 +47,6 @@ Use prior steps only when needed to explain a previous result, failure, or likel
24
47
 
25
48
  {agents}
26
49
 
27
- ### Rules
28
-
29
- - "What layers are in this map?" → List the layer names
30
- - "What fields are in this layer?" → Call the tool to list the field names for that layer
31
- - "What can you do?" / "What can I ask?" → Suggest specific queries using EXACT layer and field names from the context above
32
- - "Tell me about this map" → Summarize layers and capabilities
33
- - "Create a chart of all wells ans their depth" → If a question is map related but not supported by available capabilities, say so. Add that support for this might be added in the future.
34
- - Questions completely unrelated to maps/GIS → Politely explain you only help with the map |
35
-
36
50
  ### Response Guidelines
37
51
 
38
52
  When suggesting what users can ask, be SPECIFIC using actual layer names:
@@ -46,12 +60,15 @@ For "what can I ask" responses, provide 3-5 specific example queries using field
46
60
  For off-topic questions:
47
61
  "I can only help with this map. Try asking me to filter [LayerName] by [FieldName], or zoom to a location."
48
62
 
49
- Rules:
63
+ ---
64
+
65
+ ## Format
50
66
 
51
67
  - Keep responses concise
52
68
  - Use bullet points for lists
53
69
  - Use new lines (\\n) and appropriate formatting in your response
70
+ - Use actual layer and field names from the map context in any suggestions
54
71
  `;
55
72
  export {
56
- e as default
73
+ n as default
57
74
  };
@@ -0,0 +1,11 @@
1
+ /* COPYRIGHT Esri - https://js.arcgis.com/5.2/LICENSE.txt */
2
+ import { dispatchCustomEvent as e } from "@langchain/core/callbacks/dispatch/web";
3
+ const n = async (s, a) => {
4
+ await e("trace_message", s, a);
5
+ }, o = async (s, a) => {
6
+ await e("graph_ux_suggestion", s, a);
7
+ };
8
+ export {
9
+ o as a,
10
+ n as s
11
+ };
@@ -97,6 +97,20 @@ Do not reinterpret the request into a different form.
97
97
 
98
98
  ---
99
99
 
100
+ ## Follow-up Reference Resolution
101
+
102
+ If the latest user request refers to prior results or prior context using a referential phrase such as "these", "those", "them", "that set", "the previous results", "this", "it", "that one", "this parcel", "this location", or "that feature", then the request depends on earlier context.
103
+
104
+ This also applies to equivalent referential wording in other languages.
105
+
106
+ Resolve the reference using the most recent relevant chat history or successful prior step.
107
+
108
+ In this case, the \`assignedTask\` should be standalone and should preserve the referenced prior constraints while adding only the new constraint or question from the latest user request.
109
+
110
+ Do not leave ambiguous references like "these", "those", "them", "this", or "it" in \`assignedTask\` when they can be resolved from context.
111
+
112
+ ---
113
+
100
114
  ## Assigned Task Guidelines (IMPORTANT)
101
115
 
102
116
  - The \`assignedTask\` must match the user’s request exactly in meaning
@@ -106,6 +120,8 @@ Do not reinterpret the request into a different form.
106
120
 
107
121
  - Keep the task short, specific, and directly executable
108
122
  - Keep wording close to the user’s request with minimal transformation
123
+ - When resolving follow-up references, only replace the ambiguous reference with the resolved prior context; keep the rest of the user’s wording as close as possible.
124
+
109
125
  - Use only information explicitly present in the user request or provided context
110
126
 
111
127
  - The \`assignedTask\` may represent only part of the user’s request when multiple steps are necessary
@@ -1,28 +1,31 @@
1
1
  /* COPYRIGHT Esri - https://js.arcgis.com/5.2/LICENSE.txt */
2
- import { NodeInterrupt as L, StateGraph as w, START as E, END as m } from "@langchain/langgraph/web";
2
+ import { NodeInterrupt as E, StateGraph as L, START as w, END as m } from "@langchain/langgraph/web";
3
3
  import "@arcgis/core/identity/IdentityManager.js";
4
4
  import "@arcgis/core/portal/Portal.js";
5
- import { s as i, j as I } from "./generateLayerDescriptions.js";
5
+ import "@arcgis/toolkit/string";
6
+ import { h as I } from "./generateLayerDescriptions.js";
6
7
  import "@langchain/core/messages";
8
+ import { s as i } from "./index.js";
7
9
  import "@langchain/openai";
10
+ import "@arcgis/core/config.js";
8
11
  import "@arcgis/core/core/reactiveUtils.js";
9
12
  import "@arcgis/core/layers/FeatureLayer.js";
10
13
  import "@arcgis/core/request.js";
11
14
  import "@langchain/core/prompts";
12
- import { f as p, z as v, A as R, B as T, C as F, D as C, E as A, F as $, I as N, J as b, K as q, L as M, g as _, r as j, M as S } from "./adapter.js";
13
- import { h as k } from "./toolCallResponse.js";
14
- import { ToolNode as V } from "@langchain/langgraph/prebuilt";
15
+ import { f as g, z as v, A as T, B as R, C as F, D as C, E as A, F as $, I as N, J as b, K as q, L as M, g as _, r as k, M as S } from "./adapter.js";
16
+ import { h as V } from "./toolCallResponse.js";
17
+ import { ToolNode as j } from "@langchain/langgraph/prebuilt";
15
18
  const h = 0.7, z = 10, D = async (t, e) => {
16
19
  try {
17
20
  await i({ text: "Similarity search to find fields" }, e);
18
- const r = p(e, "fieldSearch"), a = p(e, "layersAndFieldsRegistry"), o = p(e, "embeddingCache"), n = await r.searchFields({
21
+ const r = g(e, "fieldSearch"), a = g(e, "layersAndFieldsRegistry"), o = g(e, "embeddingCache"), n = await r.searchFields({
19
22
  text: t.agentExecutionContext.assignedTask,
20
23
  layerIds: t.vectorSearchLayerIds,
21
24
  minScore: h,
22
25
  topResults: z,
23
26
  embeddingCache: o
24
- }), c = n.map(({ layerId: d, results: g }) => {
25
- const y = g.map((s) => ` - ${s.name} (${s.score.toFixed(2)})`).join(`
27
+ }), c = n.map(({ layerId: d, results: p }) => {
28
+ const y = p.map((s) => ` - ${s.name} (${s.score.toFixed(2)})`).join(`
26
29
  `);
27
30
  return `${a.get(d)?.layerItem.name ?? d}:
28
31
  ${y}`;
@@ -46,10 +49,10 @@ ${c}` : l = `No vector search results found for score over ${h}.`, await i({ tex
46
49
  { text: `Similarity search to find layers: ${t.agentExecutionContext.assignedTask}` },
47
50
  e
48
51
  );
49
- const r = p(e, "layerSearch"), a = p(e, "layersAndFieldsRegistry"), o = await r.searchLayers({
52
+ const r = g(e, "layerSearch"), a = g(e, "layersAndFieldsRegistry"), o = await r.searchLayers({
50
53
  text: t.agentExecutionContext.assignedTask,
51
54
  minScore: P
52
- }), n = o.map((d) => d.id), c = o.map(({ id: d, score: g }) => `${a.get(d)?.layerItem.name ?? d} (${g.toFixed(2)})`).join(`
55
+ }), n = o.map((d) => d.id), c = o.map(({ id: d, score: p }) => `${a.get(d)?.layerItem.name ?? d} (${p.toFixed(2)})`).join(`
53
56
  `);
54
57
  let l;
55
58
  return n.length > 0 ? l = `Vector search completed. Matching layers with scores:
@@ -65,8 +68,8 @@ ${c}` : l = "Vector search completed. No matching layers found.", await i({ text
65
68
  }
66
69
  }, f = [
67
70
  v,
68
- R,
69
71
  T,
72
+ R,
70
73
  F,
71
74
  C,
72
75
  A,
@@ -91,11 +94,12 @@ ${c}` : l = "Vector search completed. No matching layers found.", await i({ text
91
94
  }, o = await I({
92
95
  promptText: r,
93
96
  modelTier: "advanced",
97
+ config: e,
94
98
  messages: x(t.agentExecutionContext.messages),
95
99
  inputVariables: a,
96
100
  tools: f
97
101
  });
98
- return await k(o, e), {
102
+ return await V(o, e), {
99
103
  ...t,
100
104
  agentExecutionContext: {
101
105
  ...t.agentExecutionContext,
@@ -104,7 +108,7 @@ ${c}` : l = "Vector search completed. No matching layers found.", await i({ text
104
108
  };
105
109
  };
106
110
  async function B(t, e) {
107
- const a = await new V(f).invoke(
111
+ const a = await new j(f, { handleToolErrors: !1 }).invoke(
108
112
  {
109
113
  messages: x(t.agentExecutionContext.messages)
110
114
  },
@@ -129,18 +133,18 @@ const U = async (t, e) => (await i({ text: "Exiting Layer Styling agent" }, e),
129
133
  s.description && `Description: ${s.description}`
130
134
  ].filter(Boolean).join(" | ") : y;
131
135
  };
132
- const { layerId: n, results: c } = a, l = p(e, "layersAndFieldsRegistry"), d = l.get(n)?.fieldRegistry;
136
+ const { layerId: n, results: c } = a, l = g(e, "layersAndFieldsRegistry"), d = l.get(n)?.fieldRegistry;
133
137
  if (!d)
134
138
  continue;
135
- let g = r.find((y) => y.layerId === n);
136
- g || (g = {
139
+ let p = r.find((y) => y.layerId === n);
140
+ p || (p = {
137
141
  layerId: n,
138
142
  layerSummary: o(n),
139
143
  fieldInfos: []
140
- }, r.push(g));
144
+ }, r.push(p));
141
145
  for (const y of c) {
142
146
  const s = d.get(y.name);
143
- s && g.fieldInfos.push(s);
147
+ s && p.fieldInfos.push(s);
144
148
  }
145
149
  }
146
150
  return await i({ text: "Populated layerFieldInfo" }, e), { ...t, layerFieldInfo: r };
@@ -160,14 +164,14 @@ const U = async (t, e) => (await i({ text: "Exiting Layer Styling agent" }, e),
160
164
  message: "Choose a layer to apply the styles.",
161
165
  metadata: [...r]
162
166
  };
163
- throw new L(n);
167
+ throw new E(n);
164
168
  }
165
169
  let o = null;
166
170
  return Array.isArray(a.payload) && a.payload.length > 0 && (o = a.payload[0]), {
167
171
  ...t,
168
172
  selectedLayerId: o ?? t.vectorSearchLayerIds[0]
169
173
  };
170
- }, O = (t, e) => j(["layerSearch", "fieldSearch", "layersAndFieldsRegistry"], "Layer Styling Agent")(t, e), Q = () => new w(S).addNode("requireLayerStylingServices", O).addNode("vectorSearchLayers", H).addNode("layerSelectionHITL", K).addNode("vectorSearchFields", D).addNode("populateLayerFieldInfo", J).addNode("agent", G).addNode("tools", B).addNode("earlyExit", U).addEdge(E, "requireLayerStylingServices").addEdge("requireLayerStylingServices", "vectorSearchLayers").addConditionalEdges(
174
+ }, O = (t, e) => k(["layerSearch", "fieldSearch", "layersAndFieldsRegistry"], "Layer Styling Agent")(t, e), Q = () => new L(S).addNode("requireLayerStylingServices", O).addNode("vectorSearchLayers", H).addNode("layerSelectionHITL", K).addNode("vectorSearchFields", D).addNode("populateLayerFieldInfo", J).addNode("agent", G).addNode("tools", B).addNode("earlyExit", U).addEdge(w, "requireLayerStylingServices").addEdge("requireLayerStylingServices", "vectorSearchLayers").addConditionalEdges(
171
175
  "layerSelectionHITL",
172
176
  (e) => e.vectorSearchLayerIds.length ? "vectorSearchFields" : "earlyExit"
173
177
  ).addConditionalEdges(
@@ -3,13 +3,16 @@ import { StateGraph as E, START as $, END as C } from "@langchain/langgraph/web"
3
3
  import { k as F, m as R, n as L, o as M, p as A, u as _, v as I, w as q, x as Z, g as T, y as k, t as j, f as u, r as P, N as w } from "./adapter.js";
4
4
  import "@arcgis/core/identity/IdentityManager.js";
5
5
  import "@arcgis/core/portal/Portal.js";
6
- import { j as V, s as h, i as z } from "./generateLayerDescriptions.js";
6
+ import "@arcgis/toolkit/string";
7
+ import { h as V, i as z } from "./generateLayerDescriptions.js";
7
8
  import "@langchain/core/messages";
8
9
  import "@langchain/core/callbacks/dispatch/web";
9
10
  import "@langchain/openai";
11
+ import "@arcgis/core/config.js";
10
12
  import "@arcgis/core/core/reactiveUtils.js";
11
13
  import "@arcgis/core/layers/FeatureLayer.js";
12
14
  import "@arcgis/core/request.js";
15
+ import { s as h } from "./index.js";
13
16
  import "@langchain/core/prompts";
14
17
  import { ToolNode as G } from "@langchain/langgraph/prebuilt";
15
18
  import x from "zod";
@@ -25,14 +28,14 @@ const S = [
25
28
  Z
26
29
  ];
27
30
  async function O(e, t) {
28
- const o = await T("navigation_tool_prompt"), { mapView: s } = k(t), i = s.map.bookmarks?.map((p) => p.name).filter(Boolean) ?? [], c = e.vectorSearchLayerResults?.length > 0 ? e.vectorSearchLayerResults.map(
31
+ const o = await T("navigation_tool_prompt"), { mapView: s } = k(t), i = s.map.bookmarks?.map((p) => p.name).filter(Boolean) ?? [], l = e.vectorSearchLayerResults?.length > 0 ? e.vectorSearchLayerResults.map(
29
32
  (p, b) => `${b + 1}. layerId=${p.id} | title=${p.title ?? ""} | name=${p.name ?? ""} | score=${p.score.toFixed(2)}`
30
33
  ).join(`
31
- `) : "", l = e.vectorSearchFieldResults?.length > 0 ? JSON.stringify(e.vectorSearchFieldResults, null, 2) : "", a = e.intent === "goToBookmark" && i.length ? `Available bookmarks:
34
+ `) : "", c = e.vectorSearchFieldResults?.length > 0 ? JSON.stringify(e.vectorSearchFieldResults, null, 2) : "", a = e.intent === "goToBookmark" && i.length ? `Available bookmarks:
32
35
  ${i.map((p) => `- ${p}`).join(`
33
36
  `)}` : "", r = (e.intent === "goToLayer" || e.intent === "goToFeatures") && e.vectorSearchLayerResults?.length ? `Candidate layers:
34
- ${c}` : "", d = e.intent === "goToFeatures" && e.vectorSearchFieldResults?.length ? `Candidate fields:
35
- ${l}` : "", y = {
37
+ ${l}` : "", d = e.intent === "goToFeatures" && e.vectorSearchFieldResults?.length ? `Candidate fields:
38
+ ${c}` : "", y = {
36
39
  intent: e.intent,
37
40
  bookmarksSection: a,
38
41
  layersSection: r,
@@ -44,6 +47,7 @@ ${l}` : "", y = {
44
47
  }, n = await V({
45
48
  promptText: o,
46
49
  modelTier: "fast",
50
+ config: t,
47
51
  inputVariables: y,
48
52
  tools: S
49
53
  }), m = (n.tool_calls?.length ?? 0) > 0, v = typeof n.text == "string" ? n.text.trim() : "", N = v.length > 0;
@@ -70,7 +74,7 @@ const B = (e) => {
70
74
  return { text: t };
71
75
  };
72
76
  async function D(e, t) {
73
- const o = new G(S);
77
+ const o = new G(S, { handleToolErrors: !1 });
74
78
  try {
75
79
  const s = e.navigationInternalState.toolCallMessage;
76
80
  if (!s)
@@ -81,19 +85,19 @@ async function D(e, t) {
81
85
  },
82
86
  t
83
87
  );
84
- let i = "", c;
85
- for (const l of g) {
86
- const a = B(l.content);
88
+ let i = "", l;
89
+ for (const c of g) {
90
+ const a = B(c.content);
87
91
  a.text && (i += `${a.text}
88
- `), a.sharedStatePatch && (c = {
89
- ...c,
92
+ `), a.sharedStatePatch && (l = {
93
+ ...l,
90
94
  ...a.sharedStatePatch
91
95
  });
92
96
  }
93
97
  return await h({ text: `Finished executing navigation tool: ${i}` }, t), {
94
98
  ...e,
95
99
  outputMessage: i,
96
- sharedStatePatch: c,
100
+ sharedStatePatch: l,
97
101
  status: "success",
98
102
  summary: i ? j(i) : "Navigation executed.",
99
103
  navigationInternalState: {
@@ -120,12 +124,12 @@ async function J(e, t) {
120
124
  name: n.name,
121
125
  description: n.description,
122
126
  schema: n.schema
123
- })), c = s.map.bookmarks?.map((n) => n.name).filter(Boolean) ?? [], l = c.length ? `Available bookmarks:
124
- ${c.map((n) => `- ${n}`).join(`
125
- `)}` : "", a = {
127
+ })), l = s.map.bookmarks?.map((n) => n.name).filter(Boolean) ?? [], c = l.length ? `Available bookmarks:
128
+ ${l.map((n) => `- ${n}`).join(`
129
+ `)}` : "No bookmarks are available in this map.", a = {
126
130
  tools: g.map(({ name: n, description: m, schema: v }) => `${n}: ${m}, ${JSON.stringify(v)}`).join(`
127
131
  `),
128
- bookmarks: l,
132
+ bookmarks: c,
129
133
  assignedTask: e.agentExecutionContext.assignedTask,
130
134
  userRequest: e.agentExecutionContext.userRequest,
131
135
  priorSteps: e.agentExecutionContext.priorSteps
@@ -133,6 +137,7 @@ ${c.map((n) => `- ${n}`).join(`
133
137
  intent: x.string()
134
138
  }), d = await z({
135
139
  promptText: o,
140
+ config: t,
136
141
  inputVariables: a,
137
142
  schema: r,
138
143
  modelTier: "fast"
@@ -145,7 +150,7 @@ const H = 0.7, U = async (e, t) => {
145
150
  { text: `Similarity search to find layers: ${e.agentExecutionContext.assignedTask}` },
146
151
  t
147
152
  );
148
- const o = u(t, "layerSearch"), s = u(t, "layersAndFieldsRegistry"), g = u(t, "embeddingCache"), c = (await o.searchLayers({
153
+ const o = u(t, "layerSearch"), s = u(t, "layersAndFieldsRegistry"), g = u(t, "embeddingCache"), l = (await o.searchLayers({
149
154
  text: e.agentExecutionContext.assignedTask,
150
155
  minScore: H,
151
156
  embeddingCache: g
@@ -158,12 +163,12 @@ const H = 0.7, U = async (e, t) => {
158
163
  score: r
159
164
  };
160
165
  });
161
- let l;
162
- return c.length > 0 ? l = `Vector search completed. Matching layers:
163
- ${c.map((a) => `- layerId=${a.id} | title=${a.title ?? ""} | name=${a.name ?? ""} | score=${a.score.toFixed(2)}`).join(`
164
- `)}` : l = "Vector search completed. No matching layers found.", await h({ text: l }, t), {
166
+ let c;
167
+ return l.length > 0 ? c = `Vector search completed. Matching layers:
168
+ ${l.map((a) => `- layerId=${a.id} | title=${a.title ?? ""} | name=${a.name ?? ""} | score=${a.score.toFixed(2)}`).join(`
169
+ `)}` : c = "Vector search completed. No matching layers found.", await h({ text: c }, t), {
165
170
  ...e,
166
- vectorSearchLayerResults: c
171
+ vectorSearchLayerResults: l
167
172
  };
168
173
  } catch (o) {
169
174
  throw await h(
@@ -180,7 +185,7 @@ ${c.map((a) => `- layerId=${a.id} | title=${a.title ?? ""} | name=${a.name ?? ""
180
185
  const o = u(t, "fieldSearch"), s = u(t, "layersAndFieldsRegistry"), g = u(t, "embeddingCache"), i = e.vectorSearchLayerResults?.map((r) => r.id) ?? [];
181
186
  if (i.length === 0)
182
187
  return await h({ text: "No candidate layers for field search" }, t), e;
183
- const l = (await o.searchFields({
188
+ const c = (await o.searchFields({
184
189
  text: e.agentExecutionContext.assignedTask,
185
190
  layerIds: i,
186
191
  minScore: f,
@@ -205,15 +210,15 @@ ${c.map((a) => `- layerId=${a.id} | title=${a.title ?? ""} | name=${a.name ?? ""
205
210
  };
206
211
  });
207
212
  let a;
208
- return l.length > 0 ? a = `Vector search completed. Matching layers and fields:
209
- ${l.map(
213
+ return c.length > 0 ? a = `Vector search completed. Matching layers and fields:
214
+ ${c.map(
210
215
  (r) => `${r.layerName ?? r.layerId}:
211
216
  ${r.results.map((d) => ` - ${d.name} (${d.score.toFixed(2)})`).join(`
212
217
  `)}`
213
218
  ).join(`
214
219
  `)}` : a = `No vector search field results found for score over ${f}.`, await h({ text: a }, t), {
215
220
  ...e,
216
- vectorSearchFieldResults: l
221
+ vectorSearchFieldResults: c
217
222
  };
218
223
  } catch (o) {
219
224
  throw await h(
@@ -254,7 +259,7 @@ ${r.results.map((d) => ` - ${d.name} (${d.score.toFixed(2)})`).join(`
254
259
  _Example: “Center the map on San Francisco at scale 50000”_
255
260
  _Example: “Zoom to the features in the schools layer where city = 'Austin'”_
256
261
  _Example: “Go to the Downtown bookmark”_
257
- _Example: “Where is Mount Rainier?”_`, pe = {
262
+ _Example: “Where is Mount Rainier?”_`, ve = {
258
263
  id: "navigation",
259
264
  name: "Navigation Agent",
260
265
  description: Y,
@@ -262,5 +267,5 @@ ${r.results.map((d) => ` - ${d.name} (${d.score.toFixed(2)})`).join(`
262
267
  workspace: w
263
268
  };
264
269
  export {
265
- pe as N
270
+ ve as N
266
271
  };
@@ -36,8 +36,14 @@ This is the order of preference in case of overlap:
36
36
 
37
37
  For example, "Where is Yosemite National Park". This is an address, but:
38
38
  A map that contains a bookmark with Yosemite National Park should prefer the bookmark.
39
- A map that has the National Parks layer, for example, should prefer the feature.
40
- If these do not exist, geocode and go to that address.
39
+ If bookmark does not exist, a map that has the National Parks layer, for example, should prefer the feature.
40
+ If both of these do not exist, geocode and go to that address.
41
+
42
+ Additional mapping guidance:
43
+
44
+ - "zoom/go to [layer]" with no filter → prefer \`goToLayer\`.
45
+ - "zoom/go to [features] where/with ..." (has a condition/filter) → prefer \`goToFeatures\`.
46
+ - Explicit numeric zoom/scale/viewpoint requests → prefer the matching zoom/scale/viewpoint tool.
41
47
 
42
48
  Return the name of the tool as a string.
43
49
  `;