@arcgis/ai-components 5.2.0-next.9 → 5.2.0-next.91

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 (315) hide show
  1. package/LICENSE.md +4 -2
  2. package/README.md +2 -2
  3. package/dist/agent-utils/FunctionAgent.d.ts +2 -2
  4. package/dist/agent-utils/LLMAgent.d.ts +7 -4
  5. package/dist/agent-utils/LLMAgent.js +4 -2
  6. package/dist/agent-utils/WorkflowAgent.d.ts +2 -2
  7. package/dist/agent-utils/WorkflowAgent.js +14 -15
  8. package/dist/agent-utils/index.d.ts +177 -0
  9. package/dist/agent-utils/index.js +167 -0
  10. package/dist/agent-utils/middlewares/trace.d.ts +2 -0
  11. package/dist/agent-utils/middlewares/trace.js +25 -33
  12. package/dist/agent-utils/tools/FunctionTool.d.ts +2 -2
  13. package/dist/agent-utils/types.d.ts +37 -8
  14. package/dist/agent-utils/workflows/ConditionalWorkflow.d.ts +2 -2
  15. package/dist/agent-utils/workflows/LoopWorkflow.d.ts +2 -2
  16. package/dist/agent-utils/workflows/ParallelWorkflow.d.ts +2 -2
  17. package/dist/agent-utils/workflows/RouterWorkflow.d.ts +2 -2
  18. package/dist/agent-utils/workflows/SequentialWorkflow.d.ts +2 -2
  19. package/dist/agent-utils/workflows/SwitchWorkflow.d.ts +2 -2
  20. package/dist/agentic-workflow/AgenticWorkflowRuntime.d.ts +24 -0
  21. package/dist/agentic-workflow/Edge.d.ts +16 -0
  22. package/dist/agentic-workflow/WebAgent.d.ts +39 -0
  23. package/dist/agentic-workflow/jsonTypes.d.ts +189 -0
  24. package/dist/agentic-workflow/nodes/AgentNode.d.ts +28 -0
  25. package/dist/agentic-workflow/nodes/BaseNode.d.ts +35 -0
  26. package/dist/agentic-workflow/nodes/EndMessageNode.d.ts +25 -0
  27. package/dist/agentic-workflow/nodes/StartNode.d.ts +21 -0
  28. package/dist/agentic-workflow/nodes/tools/ArcgisTool.d.ts +21 -0
  29. package/dist/agentic-workflow/types.d.ts +29 -0
  30. package/dist/agents/tools/filter/clearFilters/adapter.d.ts +8 -0
  31. package/dist/agents/tools/filter/clearFilters/adapter.js +22 -0
  32. package/dist/agents/tools/filter/resetMap/adapter.d.ts +8 -0
  33. package/dist/agents/tools/filter/resetMap/adapter.js +22 -0
  34. package/dist/agents/tools/filter/setFeatureEffect/adapter.d.ts +8 -0
  35. package/dist/agents/tools/filter/setFeatureEffect/adapter.js +109 -0
  36. package/dist/agents/tools/help/listFields/adapter.d.ts +11 -0
  37. package/dist/agents/tools/help/listFields/adapter.js +30 -0
  38. package/dist/agents/tools/navigation/goToAddress/adapter.d.ts +10 -0
  39. package/dist/agents/tools/navigation/goToAddress/adapter.js +52 -0
  40. package/dist/agents/tools/navigation/goToBookmark/adapter.d.ts +8 -0
  41. package/dist/agents/tools/navigation/goToBookmark/adapter.js +30 -0
  42. package/dist/agents/tools/navigation/goToFeatures/adapter.d.ts +8 -0
  43. package/dist/agents/tools/navigation/goToFeatures/adapter.js +50 -0
  44. package/dist/agents/tools/navigation/goToFullExtent/adapter.d.ts +8 -0
  45. package/dist/agents/tools/navigation/goToFullExtent/adapter.js +27 -0
  46. package/dist/agents/tools/navigation/goToHomeExtent/adapter.d.ts +8 -0
  47. package/dist/agents/tools/navigation/goToHomeExtent/adapter.js +24 -0
  48. package/dist/agents/tools/navigation/goToLayer/adapter.d.ts +8 -0
  49. package/dist/agents/tools/navigation/goToLayer/adapter.js +26 -0
  50. package/dist/agents/tools/navigation/goToScale/adapter.d.ts +8 -0
  51. package/dist/agents/tools/navigation/goToScale/adapter.js +21 -0
  52. package/dist/agents/tools/navigation/goToViewpoint/adapter.d.ts +8 -0
  53. package/dist/agents/tools/navigation/goToViewpoint/adapter.js +42 -0
  54. package/dist/agents/tools/navigation/goToZoom/adapter.d.ts +8 -0
  55. package/dist/agents/tools/navigation/goToZoom/adapter.js +21 -0
  56. package/dist/agents/tools/query/getAttribute/adapter.d.ts +8 -0
  57. package/dist/agents/tools/query/getAttribute/adapter.js +40 -0
  58. package/dist/agents/tools/query/getStatistics/adapter.d.ts +8 -0
  59. package/dist/agents/tools/query/getStatistics/adapter.js +154 -0
  60. package/dist/agents/tools/query/getTopFeatures/adapter.d.ts +8 -0
  61. package/dist/agents/tools/query/getTopFeatures/adapter.js +141 -0
  62. package/dist/agents/tools/query/queryFeatures/adapter.d.ts +8 -0
  63. package/dist/agents/tools/query/queryFeatures/adapter.js +127 -0
  64. package/dist/agents/tools/search/findRelevantFields/adapter.d.ts +8 -0
  65. package/dist/agents/tools/search/findRelevantFields/adapter.js +57 -0
  66. package/dist/agents/tools/search/findRelevantLayers/adapter.d.ts +8 -0
  67. package/dist/agents/tools/search/findRelevantLayers/adapter.js +38 -0
  68. package/dist/cdn/2EY3BQQX.js +2 -0
  69. package/dist/cdn/2PTPBAIN.js +2 -0
  70. package/dist/cdn/34O57OGV.js +2 -0
  71. package/dist/cdn/{AMP6IALT.js → 3UEKINYC.js} +1 -1
  72. package/dist/cdn/434TAA3J.js +2 -0
  73. package/dist/cdn/4EBLRHYE.js +2 -0
  74. package/dist/cdn/4HDDRBIY.js +2 -0
  75. package/dist/cdn/4KOV2NEI.js +9 -0
  76. package/dist/cdn/4NJ2FF7H.js +2 -0
  77. package/dist/cdn/4OGR5QKS.js +2 -0
  78. package/dist/cdn/4WIDLQUH.js +2 -0
  79. package/dist/cdn/5FL5BTTX.js +66 -0
  80. package/dist/cdn/5WYRJMBW.js +2 -0
  81. package/dist/cdn/5X7EG7D2.js +2 -0
  82. package/dist/cdn/5ZFUGNRN.js +2 -0
  83. package/dist/cdn/6HF36IKA.js +2 -0
  84. package/dist/cdn/6KFMRBAA.js +2 -0
  85. package/dist/cdn/6VJXUIXY.js +3 -0
  86. package/dist/cdn/7BCQMK6D.js +2 -0
  87. package/dist/cdn/7DFXYMEA.js +2 -0
  88. package/dist/cdn/7M6VKBTK.js +6 -0
  89. package/dist/cdn/7SRLZQVC.js +5 -0
  90. package/dist/cdn/7V6OSTFC.js +2 -0
  91. package/dist/cdn/7VAQUCBU.js +9 -0
  92. package/dist/cdn/7ZFAFKJT.js +2 -0
  93. package/dist/cdn/ACJTJLZN.js +2 -0
  94. package/dist/cdn/AI6DYOKR.js +181 -0
  95. package/dist/cdn/{ZS2TZ6BF.js → AOVJ34QE.js} +1 -1
  96. package/dist/cdn/APFZY4PI.js +2 -0
  97. package/dist/cdn/AT4XVTJR.js +44 -0
  98. package/dist/cdn/AZCIDPML.js +2 -0
  99. package/dist/cdn/{FL4W4VYN.js → BL273EGZ.js} +17 -1
  100. package/dist/cdn/C5ZL5Z52.js +18 -0
  101. package/dist/cdn/CCC6LBMY.js +2 -0
  102. package/dist/cdn/{5ZZGKP7N.js → CEKOEHB3.js} +1 -1
  103. package/dist/cdn/CJMUJXPL.js +2 -0
  104. package/dist/cdn/COL6QYGQ.js +2 -0
  105. package/dist/cdn/CP5BVGJU.js +2 -0
  106. package/dist/cdn/CZM4URK7.js +2 -0
  107. package/dist/cdn/DP6O6PMH.js +2 -0
  108. package/dist/cdn/{V2P4AIGG.js → EKB7CAMM.js} +1 -1
  109. package/dist/cdn/EWLXNGKH.js +208 -0
  110. package/dist/cdn/EYNEYD34.js +2 -0
  111. package/dist/cdn/FDDQ67BG.js +2 -0
  112. package/dist/cdn/FDOMMK2M.js +2 -0
  113. package/dist/cdn/FQH3HOFH.js +2 -0
  114. package/dist/cdn/{GGSZM7KV.js → FUZ77UGP.js} +6 -4
  115. package/dist/cdn/{ZLXN7NMF.js → FYZATVB3.js} +10 -8
  116. package/dist/cdn/GFEOVHJK.js +2 -0
  117. package/dist/cdn/HHFNQR6Z.js +2 -0
  118. package/dist/cdn/HIPQ3VRW.js +2 -0
  119. package/dist/cdn/HKSFWTWK.js +14 -0
  120. package/dist/cdn/HMUWQCXU.js +2 -0
  121. package/dist/cdn/IBZ2NEAO.js +2 -0
  122. package/dist/cdn/{FX7UOGHP.js → ICBIUFK7.js} +1 -1
  123. package/dist/cdn/IHP25JWI.js +99 -0
  124. package/dist/cdn/J6A4AS7E.js +22 -0
  125. package/dist/cdn/J6SZIQJA.js +2 -0
  126. package/dist/cdn/{NE7E52YR.js → JEBRN3EU.js} +9 -3
  127. package/dist/cdn/JJJZ7FOM.js +2 -0
  128. package/dist/cdn/JKIESH74.js +2 -0
  129. package/dist/cdn/JO5ETMPS.js +2 -0
  130. package/dist/cdn/K2R6XVK3.js +2 -0
  131. package/dist/cdn/KCU4FWF7.js +2 -0
  132. package/dist/cdn/KITIP6J2.js +2 -0
  133. package/dist/cdn/KWD2ECTM.js +2 -0
  134. package/dist/cdn/{7RCQFLPP.js → LK7ZIQW6.js} +1 -1
  135. package/dist/cdn/LLUGJKAQ.js +2 -0
  136. package/dist/cdn/LPR72QZF.js +36 -0
  137. package/dist/cdn/{DHOVCT6R.js → MKOQJXQQ.js} +1 -1
  138. package/dist/cdn/MWYBF3F3.js +66 -0
  139. package/dist/cdn/NEV6OZN3.js +71 -0
  140. package/dist/cdn/OAKRPM7D.js +2 -0
  141. package/dist/cdn/{23EQTPO3.js → OKVLGJAG.js} +1 -1
  142. package/dist/cdn/OL5656NI.js +2 -0
  143. package/dist/cdn/ONQ6JSBJ.js +2 -0
  144. package/dist/cdn/OWTGH34K.js +2 -0
  145. package/dist/cdn/OYSPNIJI.js +156 -0
  146. package/dist/cdn/PEYYWXFE.js +2 -0
  147. package/dist/cdn/PKUDO2RC.js +3 -0
  148. package/dist/cdn/{LQ6R5YRN.js → PQ2DPOFM.js} +1 -1
  149. package/dist/cdn/PSYRZMX2.js +2 -0
  150. package/dist/cdn/PUHRBGKB.js +2 -0
  151. package/dist/cdn/Q57QWN5W.js +2 -0
  152. package/dist/cdn/QCFICJ7U.js +3 -0
  153. package/dist/cdn/QNNGPA3Q.js +2 -0
  154. package/dist/cdn/R74ZHFA6.js +2 -0
  155. package/dist/cdn/RBE55SWR.js +2 -0
  156. package/dist/cdn/RHYNE5OE.js +2 -0
  157. package/dist/cdn/RLEHNAIA.js +2 -0
  158. package/dist/cdn/RSNGZQCQ.js +2 -0
  159. package/dist/cdn/{X2ZDYHCG.js → SDWWUWAF.js} +10 -5
  160. package/dist/cdn/SHD6YFSR.js +2 -0
  161. package/dist/cdn/SUYWKYWI.js +22 -0
  162. package/dist/cdn/SZ2QSSB3.js +2 -0
  163. package/dist/cdn/T4RIGOXB.js +2 -0
  164. package/dist/cdn/{3PKJWIC3.js → TMZ6DF22.js} +1 -1
  165. package/dist/cdn/TPULIO6I.js +34 -0
  166. package/dist/cdn/U2D53TAX.js +14 -0
  167. package/dist/cdn/{6YMR4QSD.js → UHEYPSOR.js} +1 -1
  168. package/dist/cdn/UHZG7SKO.js +2 -0
  169. package/dist/cdn/UZLQALHY.js +2 -0
  170. package/dist/cdn/V52XWEGV.js +11 -0
  171. package/dist/cdn/V6F3HEK7.js +2 -0
  172. package/dist/cdn/V6HOUZPZ.js +2 -0
  173. package/dist/cdn/VAXH6RUQ.js +134 -0
  174. package/dist/cdn/VLLZ2FFU.js +2 -0
  175. package/dist/cdn/VNJMTA6O.js +2 -0
  176. package/dist/cdn/VOKXKU7M.js +56 -0
  177. package/dist/cdn/VXFQANGJ.js +2 -0
  178. package/dist/cdn/W5JPJWMM.js +2 -0
  179. package/dist/cdn/WKTQVBFJ.js +2 -0
  180. package/dist/cdn/WNNMKCKS.js +2 -0
  181. package/dist/cdn/WP7ORLSB.js +6 -0
  182. package/dist/cdn/WR2SQX3J.js +2 -0
  183. package/dist/cdn/X3COUAXY.js +4 -0
  184. package/dist/cdn/Y7XD7ZRD.js +2 -0
  185. package/dist/cdn/YEZ3AMNX.js +2 -0
  186. package/dist/cdn/YLVJA4ZE.js +2 -0
  187. package/dist/cdn/YQSU6IUO.js +2 -0
  188. package/dist/cdn/Z5W4V7RC.js +2 -0
  189. package/dist/cdn/ZLWWWTH4.js +2 -0
  190. package/dist/cdn/ZOEMBHRF.js +2 -0
  191. package/dist/cdn/ZQMBJ6MI.js +2 -0
  192. package/dist/cdn/{ZTBA5PM7.js → ZU2FHVNK.js} +1 -1
  193. package/dist/cdn/ZVGUAOXE.js +2 -0
  194. package/dist/cdn/agent-utils/index.js +2 -0
  195. package/dist/cdn/agent-utils/middlewares/humanInTheLoop.js +3 -0
  196. package/dist/cdn/agent-utils/middlewares/middleware.js +2 -0
  197. package/dist/cdn/agent-utils/middlewares/trace.js +2 -0
  198. package/dist/cdn/assets/assistant/t9n/messages.en.json +1 -1
  199. package/dist/cdn/assets/assistant-interrupt/t9n/messages.en.json +1 -1
  200. package/dist/cdn/assets/assistant-interrupt-preview/t9n/messages.en.json +1 -0
  201. package/dist/cdn/assets/assistant-message/t9n/messages.en.json +1 -0
  202. package/dist/cdn/assets/assistant-message-loading/t9n/messages.en.json +1 -0
  203. package/dist/cdn/index.js +1 -1
  204. package/dist/chunks/adapter.js +1299 -2113
  205. package/dist/chunks/arcgisKnowledgeGraph.js +128 -72
  206. package/dist/chunks/arcgis_knowledge_current_lc_context.js +19 -2
  207. package/dist/chunks/arcgis_knowledge_current_map_context.js +31 -2
  208. package/dist/chunks/arcgis_knowledge_cypher_query_prompt.js +102 -0
  209. package/dist/chunks/arcgis_knowledge_summarize_result_prompt.js +116 -27
  210. package/dist/chunks/baseAgentState.js +56 -0
  211. package/dist/chunks/converterUtils.js +66 -41
  212. package/dist/chunks/dataExplorationGraph.js +133 -177
  213. package/dist/chunks/data_explore_query_prompt.js +9 -4
  214. package/dist/chunks/fetchAgentContext.js +13 -0
  215. package/dist/chunks/fetchService.js +10 -0
  216. package/dist/chunks/fieldStatistics.js +79 -0
  217. package/dist/chunks/formatFeatureAttributes.js +132 -0
  218. package/dist/chunks/generateLayerDescriptions.js +259 -282
  219. package/dist/chunks/helpGraph.js +35 -25
  220. package/dist/chunks/help_prompt.js +34 -17
  221. package/dist/chunks/index.js +11 -0
  222. package/dist/chunks/intent_prompt.js +16 -0
  223. package/dist/chunks/layerStylingGraph.js +37 -31
  224. package/dist/chunks/mergeWhereClauses.js +15 -0
  225. package/dist/chunks/navigationGraph.js +124 -103
  226. package/dist/chunks/navigation_intent_prompt.js +8 -2
  227. package/dist/chunks/orchestrator.js +298 -139
  228. package/dist/chunks/slottableRequestUtils.js +3 -7
  229. package/dist/chunks/state.js +21 -27
  230. package/dist/chunks/summarize_query_response_prompt.js +9 -7
  231. package/dist/chunks/toolCallResponse.js +14 -10
  232. package/dist/chunks/types.js +59 -0
  233. package/dist/chunks/utils2.js +11 -11
  234. package/dist/components/arcgis-assistant/customElement.d.ts +72 -0
  235. package/dist/components/arcgis-assistant/customElement.js +416 -172
  236. package/dist/components/arcgis-assistant/index.js +2 -3
  237. package/dist/components/arcgis-assistant/types.d.ts +14 -1
  238. package/dist/components/arcgis-assistant-agent/customElement.d.ts +13 -1
  239. package/dist/components/arcgis-assistant-agent/customElement.js +614 -10
  240. package/dist/components/arcgis-assistant-chat/customElement.d.ts +2 -1
  241. package/dist/components/arcgis-assistant-chat/customElement.js +23 -18
  242. package/dist/components/arcgis-assistant-chat-entry/customElement.d.ts +2 -0
  243. package/dist/components/arcgis-assistant-chat-entry/customElement.js +25 -18
  244. package/dist/components/arcgis-assistant-data-exploration-agent/customElement.js +20 -4
  245. package/dist/components/arcgis-assistant-help-agent/customElement.js +29 -7
  246. package/dist/components/arcgis-assistant-interrupt/customElement.d.ts +4 -0
  247. package/dist/components/arcgis-assistant-interrupt/customElement.js +17 -14
  248. package/dist/components/arcgis-assistant-interrupt-preview/customElement.js +24 -0
  249. package/dist/components/arcgis-assistant-interrupt-preview/index.js +2 -0
  250. package/dist/components/arcgis-assistant-knowledge-agent/customElement.d.ts +7 -7
  251. package/dist/components/arcgis-assistant-knowledge-agent/customElement.js +40 -16
  252. package/dist/components/arcgis-assistant-layer-styling-agent/customElement.js +30 -7
  253. package/dist/components/arcgis-assistant-message/customElement.d.ts +5 -0
  254. package/dist/components/arcgis-assistant-message/customElement.js +29 -26
  255. package/dist/components/arcgis-assistant-message/index.js +2 -0
  256. package/dist/components/arcgis-assistant-message-block/customElement.js +18 -11
  257. package/dist/components/arcgis-assistant-message-block/index.js +1 -0
  258. package/dist/components/arcgis-assistant-message-loading/customElement.d.ts +7 -0
  259. package/dist/components/arcgis-assistant-message-loading/customElement.js +8 -7
  260. package/dist/components/arcgis-assistant-message-loading/index.js +1 -0
  261. package/dist/components/arcgis-assistant-message-text/customElement.d.ts +1 -0
  262. package/dist/components/arcgis-assistant-message-text/customElement.js +12 -12
  263. package/dist/components/arcgis-assistant-navigation-agent/customElement.js +18 -4
  264. package/dist/components/arcgis-assistant-speech-input/customElement.js +34 -52
  265. package/dist/components/arcgis-assistant-suggested-prompts/customElement.js +8 -8
  266. package/dist/components/arcgis-assistant-user-message/customElement.d.ts +2 -0
  267. package/dist/components/arcgis-assistant-user-message/customElement.js +15 -10
  268. package/dist/docs/api.json +1 -1
  269. package/dist/docs/docs.json +1 -1
  270. package/dist/docs/vscode.html-custom-data.json +1 -1
  271. package/dist/docs/web-types.json +1 -1
  272. package/dist/loader.js +9 -8
  273. package/dist/oauth-callback.html +1 -1
  274. package/dist/orchestrator/orchestrator/orchestratorEvents.d.ts +78 -0
  275. package/dist/types/lumina.d.ts +10 -8
  276. package/dist/types/preact.d.ts +10 -8
  277. package/dist/types/react.d.ts +10 -8
  278. package/dist/types/stencil.d.ts +12 -10
  279. package/dist/utils/index.d.ts +8 -8
  280. package/dist/utils/index.js +56 -55
  281. package/package.json +32 -12
  282. package/dist/cdn/2AXF774U.js +0 -2
  283. package/dist/cdn/462JBSEV.js +0 -422
  284. package/dist/cdn/53ZCUPKK.js +0 -22
  285. package/dist/cdn/5QAHYX7Y.js +0 -5
  286. package/dist/cdn/5XRDJL7R.js +0 -14
  287. package/dist/cdn/7BCR6TUO.js +0 -2
  288. package/dist/cdn/7GH7VSB2.js +0 -2
  289. package/dist/cdn/7PLV4QH6.js +0 -2
  290. package/dist/cdn/AXDZBBNL.js +0 -45
  291. package/dist/cdn/DDLZOMUY.js +0 -2
  292. package/dist/cdn/EECZLT6C.js +0 -166
  293. package/dist/cdn/ETRWZ3MS.js +0 -108
  294. package/dist/cdn/F2AHA4GB.js +0 -54
  295. package/dist/cdn/FX5JFRDL.js +0 -2
  296. package/dist/cdn/H7422XUG.js +0 -2
  297. package/dist/cdn/HB5A5R2E.js +0 -2
  298. package/dist/cdn/I6HNBTWY.js +0 -2
  299. package/dist/cdn/I7SRZPVS.js +0 -72
  300. package/dist/cdn/IG6YKZH3.js +0 -3
  301. package/dist/cdn/JVIKKZND.js +0 -3
  302. package/dist/cdn/KMQ3SP4I.js +0 -5
  303. package/dist/cdn/MH5RPXHM.js +0 -2
  304. package/dist/cdn/NVI3I46B.js +0 -2
  305. package/dist/cdn/OAVEHGB6.js +0 -2
  306. package/dist/cdn/OH64RMOR.js +0 -4
  307. package/dist/cdn/P26NON3Z.js +0 -16
  308. package/dist/cdn/QR54T33D.js +0 -2
  309. package/dist/cdn/RVOAPUBN.js +0 -2
  310. package/dist/cdn/S3VPZFWQ.js +0 -36
  311. package/dist/cdn/SXDLXCIM.js +0 -2
  312. package/dist/cdn/TR7RL3IK.js +0 -2
  313. package/dist/cdn/USMDJUFS.js +0 -2
  314. package/dist/cdn/Y333DGV6.js +0 -2
  315. package/dist/cdn/YIMNOUTF.js +0 -2
@@ -0,0 +1,22 @@
1
+ /* COPYRIGHT Esri - https://js.arcgis.com/5.2/LICENSE.txt */
2
+ import d from"./SZ2QSSB3.js";import b from"./OYSPNIJI.js";import{a as h}from"./7SRLZQVC.js";import{a as m}from"./FDOMMK2M.js";import a from"./AT4XVTJR.js";import{a as p}from"./7VAQUCBU.js";import{Ya as c,a as u,b as n}from"./EWLXNGKH.js";export default $arcgis.t(([,,,,,,{p:g},{a:f,c:y,d:x,e:E,v:d},S])=>{var _=[h],v=e=>{if(!e||e.size===0)return"No layers available in this map.";let t=Array.from(e.values()).map(({layerItem:r,fieldRegistry:s},o)=>{let a=Array.from(s.values()).map(i=>i.name).slice(0,10).join(", "),l=s.size>10?` (and ${s.size-10} more)`:"";return`${o+1}. "${r.title}". Description: ${r.description}
3
+ Fields: ${a}${l}`}).join(`
4
+
5
+ `);return`This map contains ${e.size} layer(s):
6
+
7
+ ${t}`},w=e=>{let t=e?.list()??[];return t.length?t.map(r=>`- ${r.agent.name}: ${r.agent.description}`).join(`
8
+ `):"No agents currently available."};async function $(e,t){let r=await y("help_prompt"),s=m(t,"layersAndFieldsRegistry"),o=m(t,"agentRegistry");try{let a=await g({promptText:r,modelTier:"default",config:t,tools:_,inputVariables:{layerSummary:v(s),agents:w(o),assignedTask:e.agentExecutionContext.assignedTask,userRequest:e.agentExecutionContext.userRequest,priorSteps:e.agentExecutionContext.priorSteps}});await S(a,t);let l=(a.tool_calls?.length??0)>0,i=typeof a.text=="string"?a.text.trim():"";return{...e,helpInternalState:{...e.helpInternalState,toolCallMessage:l?a:void 0},outputMessage:l?e.outputMessage:i,summary:l?"Prepared help tool call from assigned task.":"Provided map-related help based on the assigned task.",status:l?e.status:"success"}}catch(a){let l=a instanceof Error?a.message:String(a);return{...e,outputMessage:`Error invoking help agent: ${l}`,summary:"Help agent execution failed.",status:"failed"}}}var b=(e,t)=>E(["agentRegistry"],"Help Agent")(e,t);async function k(e,t){let r=new f(_,{handleToolErrors:!1});try{let s=e.helpInternalState.toolCallMessage;if(!s)throw new Error("helpToolCalling: missing helpInternalState.toolCallMessage");let o=(await r.invoke({messages:[s]},t)).messages.map(a=>a.text).join(`
9
+ `);return await p({text:`Finished executing help tool: ${o}`},t),{...e,outputMessage:o,status:"success",summary:o?x(o):"Help executed.",helpInternalState:{...e.helpInternalState,toolCallMessage:void 0}}}catch(s){let o=s instanceof Error?s.message:String(s);return await p({text:`Help tool execution failed: ${o}`},t),{...e,outputMessage:`Help tool execution failed: ${o}`,status:"failed",summary:`Help tool execution failed: ${o}`,helpInternalState:{...e.helpInternalState,toolCallMessage:void 0}}}}var C=()=>new c(d).addNode("requireHelpServices",b).addNode("agent",$).addNode("tools",k).addEdge(u,"requireHelpServices").addEdge("requireHelpServices","agent").addConditionalEdges("agent",e=>e.helpInternalState.toolCallMessage?"tools":n).addEdge("tools",n),H=String.raw`- **help** — Enables users to ask questions about the map, layers, fields, and it's capabilities.
10
+
11
+ _Example: “Tell me about this map”_
12
+ _Example: “List all layers in this map”_
13
+ _Example: “List fields in protected areas layer”_
14
+ _Example: “What agents are available to me?”_
15
+ _Example: “What can you do?”_
16
+ _Example: “What can I ask”_
17
+
18
+ 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.
19
+
20
+ 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.
21
+ _Example: "Create a chart"_
22
+ _Example: "Create a table"_`,K={id:"help",name:"Help Agent",description:H,createGraph:C,workspace:d};return K},"identity/IdentityManager","portal/Portal","request","config","core/reactiveUtils","layers/FeatureLayer",a,b,d)
@@ -0,0 +1,2 @@
1
+ /* COPYRIGHT Esri - https://js.arcgis.com/5.2/LICENSE.txt */
2
+ import{a as t}from"./7VAQUCBU.js";export default $arcgis.t(([])=>{var d=async(o,i)=>{let r=o.tool_calls??[];if(r.length===0){await t({text:`LLM did not request any tool calls: ${String(o?.content)}`},i);return}await Promise.all(r.map(async a=>await t({text:`LLM invoked ${a.name} tool with arguments: ${JSON.stringify(a.args,null,2)}`},i)))};return d},"identity/IdentityManager","portal/Portal","request","config","core/reactiveUtils","layers/FeatureLayer")
@@ -0,0 +1,2 @@
1
+ /* COPYRIGHT Esri - https://js.arcgis.com/5.2/LICENSE.txt */
2
+ import{a}from"./YEZ3AMNX.js";import"./ONQ6JSBJ.js";import"./AI6DYOKR.js";import"./VXFQANGJ.js";import"./MWYBF3F3.js";import"./UZLQALHY.js";export{a as resetMapTool};
@@ -1,2 +1,2 @@
1
1
  /* COPYRIGHT Esri - https://js.arcgis.com/5.2/LICENSE.txt */
2
- import{a as l}from"./H7422XUG.js";import"./MH5RPXHM.js";import"./OAVEHGB6.js";import{g as a,h as e,k as o,t as i,u as n,v as r,y as c}from"./OH64RMOR.js";import"./YIMNOUTF.js";export default $arcgis.t(([{watch:d}])=>{var g=a`.container{display:flex;align-items:center;width:100%;justify-content:space-between;gap:var(--calcite-spacing-xs)}.start,.end{display:flex;align-items:center;gap:var(--calcite-spacing-xs)}`,t=class extends r{constructor(){super(...arguments),this._messages=l({blocking:!0}),this._endRef=i(),this._showLog=!1,this.feedbackEnabled=!1,this.logEnabled=!1,this.copyEnabled=!1,this.readAloudEnabled=!1}static{this.properties={_showLog:16,feedbackEnabled:5,logEnabled:5,copyEnabled:5,readAloudEnabled:5,message:0}}static{this.styles=g}loaded(){this.manager.onLifecycle(()=>[d(()=>this._showLog,()=>this._scrollToEnd())])}_scrollToEnd(){requestAnimationFrame(()=>{this._endRef.value?.scrollIntoView({behavior:"smooth",block:"end"})})}_renderCopyButton(){return!this.message?.error&&this.copyEnabled?e`<calcite-action id=action-copy icon=copy-to-clipboard scale=s @click=${async()=>{try{let s=this.message?.content?.trim();s&&await navigator.clipboard.writeText(s)}catch(s){o("warn","assistant-message-footer","Failed to copy text to clipboard",{once:!0,detail:{error:s}})}}} text></calcite-action><calcite-tooltip reference-element=action-copy overlay-positioning=fixed placement=bottom><span>${this._messages.copyButtonLabel}</span></calcite-tooltip>`:null}_renderLogButton(){return this.message?.log?.length&&this.logEnabled?e`<calcite-action id=action-log icon=access-string-results scale=s @click=${()=>this._showLog=!this._showLog} .text=${this._messages.logButtonLabel} .active=${this._showLog}></calcite-action><calcite-tooltip reference-element=action-log overlay-positioning=fixed placement=bottom><span>${this._messages.logButtonLabel}</span></calcite-tooltip>`:null}_renderReadAloudButton(){return e`<arcgis-assistant-message-read-aloud .message=${this.message} .readAloudEnabled=${this.readAloudEnabled}></arcgis-assistant-message-read-aloud>`}_renderLog(){return e`<arcgis-assistant-message-log .log=${this.message?.log} .showLog=${this._showLog} .logEnabled=${this.logEnabled}></arcgis-assistant-message-log>`}_renderFeedback(){return e`<arcgis-assistant-message-feedback .message=${this.message} .feedbackEnabled=${this.feedbackEnabled}></arcgis-assistant-message-feedback>`}render(){return e`${this._renderLog()}<div class="container"><div class="start">${this._renderCopyButton()}${this._renderLogButton()}${this._renderReadAloudButton()}<slot name=footer-actions-start></slot></div><div class="end"><slot name=footer-actions-end></slot>${this._renderFeedback()}</div></div><div ${n(this._endRef)}></div>`}};c("arcgis-assistant-message-footer",t);return t},"core/reactiveUtils")
2
+ import{b as l}from"./V6F3HEK7.js";import"./RLEHNAIA.js";import{g as a,h as e,k as o,t as i,u as n,v as r,z as c}from"./X3COUAXY.js";import"./R74ZHFA6.js";import"./UZLQALHY.js";export default $arcgis.t(([{watch:d}])=>{var g=a`.container{display:flex;align-items:center;width:100%;justify-content:space-between;gap:var(--calcite-spacing-xs)}.start,.end{display:flex;align-items:center;gap:var(--calcite-spacing-xs)}`,t=class extends r{constructor(){super(...arguments),this._messages=l({blocking:!0}),this._endRef=i(),this._showLog=!1,this.feedbackEnabled=!1,this.logEnabled=!1,this.copyEnabled=!1,this.readAloudEnabled=!1}static{this.properties={_showLog:16,feedbackEnabled:5,logEnabled:5,copyEnabled:5,readAloudEnabled:5,message:0}}static{this.styles=g}loaded(){this.manager.onLifecycle(()=>[d(()=>this._showLog,()=>this._scrollToEnd())])}_scrollToEnd(){requestAnimationFrame(()=>{this._endRef.value?.scrollIntoView({behavior:"smooth",block:"end"})})}_renderCopyButton(){return!this.message?.error&&this.copyEnabled?e`<calcite-action id=action-copy icon=copy-to-clipboard scale=s @click=${async()=>{try{let s=this.message?.content?.trim();s&&await navigator.clipboard.writeText(s)}catch(s){o("warn","assistant-message-footer","Failed to copy text to clipboard",{once:!0,detail:{error:s}})}}} text></calcite-action><calcite-tooltip reference-element=action-copy overlay-positioning=fixed placement=bottom><span>${this._messages.copyButtonLabel}</span></calcite-tooltip>`:null}_renderLogButton(){return this.message?.log?.length&&this.logEnabled?e`<calcite-action id=action-log icon=access-string-results scale=s @click=${()=>this._showLog=!this._showLog} .text=${this._messages.logButtonLabel} .active=${this._showLog}></calcite-action><calcite-tooltip reference-element=action-log overlay-positioning=fixed placement=bottom><span>${this._messages.logButtonLabel}</span></calcite-tooltip>`:null}_renderReadAloudButton(){return e`<arcgis-assistant-message-read-aloud .message=${this.message} .readAloudEnabled=${this.readAloudEnabled}></arcgis-assistant-message-read-aloud>`}_renderLog(){return e`<arcgis-assistant-message-log .log=${this.message?.log} .showLog=${this._showLog} .logEnabled=${this.logEnabled}></arcgis-assistant-message-log>`}_renderFeedback(){return e`<arcgis-assistant-message-feedback .message=${this.message} .feedbackEnabled=${this.feedbackEnabled}></arcgis-assistant-message-feedback>`}render(){return e`${this._renderLog()}<div class="container"><div class="start">${this._renderCopyButton()}${this._renderLogButton()}${this._renderReadAloudButton()}<slot name=footer-actions-start></slot></div><div class="end"><slot name=footer-actions-end></slot>${this._renderFeedback()}</div></div><div ${n(this._endRef)}></div>`}};c("arcgis-assistant-message-footer",t);return t},"core/reactiveUtils")
@@ -0,0 +1,34 @@
1
+ /* COPYRIGHT Esri - https://js.arcgis.com/5.2/LICENSE.txt */
2
+ import"./UZLQALHY.js";var e=`## Membership Bind Parameters
3
+
4
+ The current map contains a subset of entities and relationships from the database. Their membership is available to Cypher queries as lists of string identifiers through these bind parameters:
5
+
6
+ - $entityIds
7
+ - $relationshipIds
8
+
9
+ Included Types:
10
+ {nonDynamicTypes}
11
+
12
+ Filtering rules:
13
+
14
+ - Apply membership filtering only when BOTH are true:
15
+ - The user is asking for data to be limited by the records already on 'the current map', 'my map', 'the knowledge graph layer' or similar.
16
+ - The variable in the cypher query is a type in Included Types above.
17
+ - IMPORTANT: In all other cases, DO NOT apply membership filtering. DO NOT include membership filters for any type not listed in Included Types above.
18
+
19
+ ### START EXAMPLES
20
+
21
+ User request: 'Add all records that are connected to people on this map to the map'
22
+ Context: 'Person' entity in data model and included in the bind parameter types above.
23
+ Expected Result: MATCH (n:Person)-[r]->(m) WHERE id(n) IN $entityIds return r, m
24
+
25
+ User request: 'Add all the suppliers to the map'
26
+ Context: 'Supplier' entity in the data model.
27
+ Expected Result: MATCH (s:Supplier) RETURN s
28
+
29
+ User request: 'Add all suppliers connected to plants on my map'
30
+ Context: 'Plant' entity in data model but not included in the bind parameter types above.
31
+ Expected Result: MATCH (p:Plant)-[r]->(s:Supplier) return r, s
32
+
33
+ ### END EXAMPLES
34
+ `;export{e as default};
@@ -0,0 +1,14 @@
1
+ /* COPYRIGHT Esri - https://js.arcgis.com/5.2/LICENSE.txt */
2
+ import{a as q,b as T}from"./34O57OGV.js";import{a as N}from"./FDOMMK2M.js";import a from"./QNNGPA3Q.js";import{a as S}from"./ONQ6JSBJ.js";import{Dc as I}from"./AI6DYOKR.js";import{a as e}from"./VXFQANGJ.js";export default $arcgis.t(([V,j,A,{a:F,b:b,c:L,d:v}])=>{var W=async p=>{let{targetLayer:r,fieldName:n,statisticType:l,mapView:a,layersAndFieldsRegistry:h,geometryFilter:t}=p,s=a.map?.allLayers.find(i=>i.id===r.layerId);if(!s)throw new Error(`Layer '${r.layerId}' not found.`);let O=await a.whenLayerView(s),o=h.get(r.layerId)?.fieldRegistry.get(n),E=o?.alias;if(!o)throw new Error(`Field '${n}' not found.`);let w,u;if(t){let i=await L(t,a);if("error"in i)throw new Error(i.error);if(!i.geometry)throw b(t)?new Error(`No features found matching: ${t.where}`):new Error("Failed to create geometry");if(b(t)){let g=a.map?.allLayers.find(f=>f.id===t.layerId);w={geometryLayerName:g?.title??g?.id,geometryLayerId:t.layerId,geometryWhere:t.where,distance:t.distance,units:t.units,applied:!0}}else F(t)&&(w={point:t.point,distance:t.distance,units:t.units,applied:!0});u=new A({geometry:i.geometry,distance:t.distance,units:t.units,spatialRelationship:"intersects"})}let y=q(O,[n],!1),c=null,m=null,x=10;if(o.type!=="geometry"&&o.type!=="oid"&&o.type!=="global-id")try{let i={layer:s,useFeaturesInView:y,view:y?a:void 0,field:n,sqlWhere:T(s.definitionExpression,r.where),...u&&{filter:u},outStatisticTypes:{include:[l]}};c=await V(i);let g=["string","small-integer","integer"],f=o.domain?.type==="coded-value"?o.domain:null;(g.includes(o.type)||f)&&(m=(await j({layer:s,useFeaturesInView:y,view:y?a:void 0,field:n,sqlWhere:T(s.definitionExpression,r.where),...u&&{filter:u}})).uniqueValueInfos.sort((d,R)=>R.count-d.count).slice(0,x)),m&&o.domain?.type==="coded-value"&&(m=m.map(d=>({...d,value:f?f.getName(d.value)??d.value:d.value})))}catch(i){console.error("Statistics error:",i)}return{tool:"getStatistics",layerName:s.title??r.layerId,summary:`${l} = ${typeof c?.[l]=="number"?c[l]:"N/A"}`,details:{fieldName:n,fieldAlias:E,statisticType:l,statistic:c?.[l]??null,summaryStatistics:c,uniqueValues:m,where:r.where,spatialFilterInfo:w}}};async function D({targetLayer:p,fieldName:r,statisticType:n,geometryFilter:l},a){let h=N(a,"layersAndFieldsRegistry"),{mapView:t}=S(a,["mapView"]),s=await W({targetLayer:p,fieldName:r,statisticType:n,mapView:t,layersAndFieldsRegistry:h,geometryFilter:l});return JSON.stringify(s,null,2)}var U=e.object({layerId:e.string().describe("The layerId of the layer containing the geometry by which to filter."),where:e.string().describe("The SQL-92 where clause representing the features from which to filter."),distance:e.number().optional().describe("The buffer distance around the geometry."),units:v.optional().describe("The units for the distance buffer.")}),C=e.object({point:e.object({x:e.number().describe("X coordinate (longitude) from navigation result"),y:e.number().describe("Y coordinate (latitude) from navigation result"),spatialReference:e.object({wkid:e.number().describe("Spatial reference WKID (e.g., 4326 for WGS84)")}).optional().describe("Spatial reference. Defaults to map's spatial reference if not provided.")}).describe("Point coordinates from a previous navigation/geocoding result"),distance:e.number().optional().describe("Optional buffer distance around the point."),units:v.optional().describe("The units for the distance buffer.")}),$=e.object({targetLayer:e.object({layerId:e.string().describe("The layerId of the layer containing the field from which to get a value."),where:e.string().describe("The SQL-92 where clause representing the feature from which to get an attribute value.")}),geometryFilter:e.union([U,C]).optional().describe("Geometry filter for spatial queries. Use 'point' option with x/y coordinates from navigation results to find features at that location (point-in-polygon). Use 'layerId/where' option to filter by features from another layer."),fieldName:e.string().describe("The name of the field for which to get statistics. STRICTLY DO NOT use OBJECTID. Use any other field"),statisticType:e.enum(["avg","max","median","min","stddev","sum","variance","nullcount","count"]).describe("The statistic type to calculate.")}),K=I(D,{name:"getStatistics",description:`Computes a single aggregate statistic (max, min, avg, sum, median, stddev, variance) for a numeric field across matching features. Also returns frequency analysis for categorical fields.
3
+
4
+ USE THIS TOOL FOR:
5
+ - "What is the average/maximum/minimum/total [field]?" \u2014 aggregate computations
6
+ - "Most common/frequent value of [field]?" \u2014 frequency analysis
7
+ - Questions requiring a mathematical aggregation across many features
8
+
9
+ DO NOT USE FOR:
10
+ - "How many features match X?" \u2014 use queryFeatures instead (it returns totalCount)
11
+ - "Show / list / find features" \u2014 use queryFeatures instead
12
+ - Simple counts of features matching a condition \u2014 use queryFeatures instead
13
+
14
+ Only call this tool when the answer requires computing an aggregate (avg, max, min, sum, median, stddev) over a field's values, not just counting or listing features.`,schema:$});return K},"smartMapping/statistics/summaryStatistics","smartMapping/statistics/uniqueValues","layers/support/FeatureFilter",a)
@@ -1,5 +1,5 @@
1
1
  /* COPYRIGHT Esri - https://js.arcgis.com/5.2/LICENSE.txt */
2
- import"./YIMNOUTF.js";var e=`# Navigation Tool Instructions
2
+ import"./UZLQALHY.js";var e=`# Navigation Tool Instructions
3
3
 
4
4
  CRITICAL: You are FORBIDDEN from making multiple tool calls. You MUST make exactly ONE tool call.
5
5
 
@@ -0,0 +1,2 @@
1
+ /* COPYRIGHT Esri - https://js.arcgis.com/5.2/LICENSE.txt */
2
+ import b from"./JKIESH74.js";import a from"./QNNGPA3Q.js";import"./ONQ6JSBJ.js";import"./AI6DYOKR.js";import"./VXFQANGJ.js";import"./MWYBF3F3.js";import"./UZLQALHY.js";export default $arcgis.t(([,a])=>{return a},a,b)
@@ -0,0 +1,2 @@
1
+ /* COPYRIGHT Esri - https://js.arcgis.com/5.2/LICENSE.txt */
2
+ var g=Object.create;var e=Object.defineProperty;var h=Object.getOwnPropertyDescriptor;var i=Object.getOwnPropertyNames;var j=Object.getPrototypeOf,k=Object.prototype.hasOwnProperty;var m=(b,a)=>()=>{try{return a||b((a={exports:{}}).exports,a),a.exports}catch(c){throw a=0,c}},n=(b,a)=>{for(var c in a)e(b,c,{get:a[c],enumerable:!0})},l=(b,a,c,f)=>{if(a&&typeof a=="object"||typeof a=="function")for(let d of i(a))!k.call(b,d)&&d!==c&&e(b,d,{get:()=>a[d],enumerable:!(f=h(a,d))||f.enumerable});return b};var o=(b,a,c)=>(c=b!=null?g(j(b)):{},l(a||!b||!b.__esModule?e(c,"default",{value:b,enumerable:!0}):c,b));export{m as a,n as b,o as c};
@@ -0,0 +1,11 @@
1
+ /* COPYRIGHT Esri - https://js.arcgis.com/5.2/LICENSE.txt */
2
+ import b from"./CCC6LBMY.js";import{a as N,b as O}from"./34O57OGV.js";import a from"./QNNGPA3Q.js";import{a as S}from"./ONQ6JSBJ.js";import{Dc as L}from"./AI6DYOKR.js";import{a as e}from"./VXFQANGJ.js";export default $arcgis.t(([{a:p,b:g,c:v,d:b},{d:j}])=>{var w=25,C=i=>i.flatMap(r=>r.split(",")).map(r=>r.trim()).map(r=>r.split(/\s+/u)[0]?.replace(/^"|"$/gu,"")).filter(r=>!!r),R=async(i,r,t,f)=>{let s=r.map?.allLayers.find(u=>u.id===i.layerId),l=await r.whenLayerView(s),h=s.title??i.layerId,c;if(t){let u=await v(t,r);if("error"in u){let o={error:u.error};if(g(t)){let d=r.map?.allLayers.find(m=>m.id===t.layerId);o.geometryLayerName=d?.title??d?.id,o.geometryLayerId=t.layerId,o.geometryWhere=t.where}else p(t)&&(o.point=t.point);return{tool:"queryFeatures",layerName:h,summary:"Geometry lookup failed",details:o}}if(!u.geometry){let o={};if(g(t)){let d=r.map?.allLayers.find(m=>m.id===t.layerId);o.error=`No features found matching: ${t.where}`,o.geometryLayerName=d?.title??d?.id,o.geometryLayerId=t.layerId,o.geometryWhere=t.where}else p(t)&&(o.error="Failed to create point geometry",o.point=t.point);return{tool:"queryFeatures",layerName:h,summary:"No features found for geometry filter",details:o}}c=u.geometry}else f&&(c=r.extent.clone());let x=[...new Set([...i.outFields,...C(i.orderByFields)])],F=N(l,x,f??!1),I=s.objectIdField,a=s.createQuery();a.where=O(s.definitionExpression,i.where||"1=1"),a.outFields=i.outFields.includes("*")?["*"]:[...new Set([...i.outFields,I])],a.orderByFields=i.orderByFields,c&&(a.geometry=c,a.spatialRelationship="intersects"),t?.distance&&(a.distance=t.distance),t?.units&&(a.units=t.units),a.outSpatialReference=r.spatialReference;let n,y;try{n=F?await l.queryFeatureCount(a):await s.queryFeatureCount(a),n>0&&n<=w&&(y=F?await l.queryFeatures(a):await s.queryFeatures(a))}catch(u){console.warn("Client-side query failed, falling back to server:",u),n=await s.queryFeatureCount(a),n>0&&n<=w&&(y=await s.queryFeatures(a))}let{objectIds:q,attributes:T}=y?j(s,y,r.timeZone):{objectIds:void 0,attributes:void 0};return{tool:"queryFeatures",layerName:h,summary:`${n} features found`,details:{totalCount:n,where:i.where,orderByFields:i.orderByFields,outFields:i.outFields,...q&&{objectIds:q,objectIdField:I},...T&&{attributes:T},...n>w&&{note:`${n} features found.`}}}};async function k({targetLayer:i,geometryFilter:r,useCurrentExtent:t},f){let{mapView:s}=S(f,["mapView"]),l=await R(i,s,r,t);return JSON.stringify(l,null,2)}var W=e.object({layerId:e.string().describe("The layerId of the layer containing the geometry by which to filter."),where:e.string().describe("The SQL-92 where clause representing the features from which to filter."),distance:e.number().optional().describe("The buffer distance around the geometry."),units:b.optional().describe("The units for the distance buffer.")}),B=e.object({point:e.object({x:e.number().describe("X coordinate (longitude) from navigation result"),y:e.number().describe("Y coordinate (latitude) from navigation result"),spatialReference:e.object({wkid:e.number().describe("Spatial reference WKID (e.g., 4326 for WGS84)")}).optional().describe("Spatial reference. Defaults to map's spatial reference if not provided.")}).describe("Point coordinates from a previous navigation/geocoding result"),distance:e.number().optional().describe("Optional buffer distance around the point."),units:b.optional().describe("The units for the distance buffer.")}),E=e.object({targetLayer:e.object({layerId:e.string().describe("The layerId of the layer containing the field from which to get a value."),where:e.string().describe("SQL-92 where clause. IMPORTANT: When using geometryFilter.point for point-in-polygon queries, set this to '1=1' to return all features that intersect the point. Only add attribute filters if the user specifically requests them in addition to the spatial query."),orderByFields:e.array(e.string().describe("The field(s) and order for which to sort the resulting features.")),outFields:e.array(e.string().describe('The fields to include in the output that will be presented to the user. This should include identifying information about the resulting features, like a name or id, along with the values desired in the output. If unsure, choose all fields ("*").').default("*"))}),geometryFilter:e.union([W,B]).optional().describe("Geometry filter for spatial queries. Use 'point' option with x/y coordinates from navigation results to find features at that location (point-in-polygon). Use 'layerId/where' option to filter by features from another layer."),useCurrentExtent:e.boolean().optional().describe("Set to true ONLY when user explicitly asks about features 'in my view', 'on my map', 'I am looking at', OR when the user refers back to features previously identified using the current extent (e.g. 'these', 'those', 'them', 'the same ones'). Default is false (queries entire layer).")}),P=L(k,{name:"queryFeatures",description:`Queries features from a layer. Returns the total count of matching features, plus individual feature attributes if \u226425 features match.
3
+
4
+ USE THIS TOOL FOR:
5
+ - "Show / display / list features where..." \u2014 finding and listing features
6
+ - "How many X are Y?" \u2014 counting features that match a condition
7
+ - "Which features..." / "Find features..." \u2014 identifying specific features
8
+ - Spatial queries \u2014 finding features near/within/intersecting other features
9
+ - Any question where the user wants to SEE or COUNT matching features
10
+
11
+ This is the DEFAULT tool for most queries. When in doubt, use this tool.`,schema:E});return P},a,b)
@@ -0,0 +1,2 @@
1
+ /* COPYRIGHT Esri - https://js.arcgis.com/5.2/LICENSE.txt */
2
+ import{b as A,d as N}from"./RLEHNAIA.js";import{A as $,a as x,b as C,c as f,d as m,e as L,f as P,k as g,m as v,n as O,o as w}from"./X3COUAXY.js";var _=t=>(...s)=>{let e=m(),o=new t(...s),r=o.exports;f(e.at(-1));let n=o.component.manager;n.W(o,r),o.watchExports(n.W.bind(n,o)),L(o);let a=[o.component,...e].reverse();return v(a,i=>i===void 0?void 0:F(o,i,r),r)},F=(t,{host:s,key:e,isReactive:o},r)=>{let n=s,a=n[e]!==t.exports,i=n[e]!==r,l=r!==t.exports;if(a&&!i&&l&&(n[e]=t.exports),s===t.component){if(o){let p=t.component.manager;i&&p.W(t,n[e]),t.onUpdate(u=>{if(u.has(e)){let y=n[e];y!==t.exports&&p.W(t,y)}})}t.O=o?void 0:e}let c=t.component.constructor.elementProperties.get(e)?.readOnly;t.watchExports(()=>{n[e]!==t.exports&&(c?P(()=>{n[e]=t.exports}):n[e]=t.exports)})};var b=t=>{let s=N(t,"lang",globalThis.navigator?.language||h);return{lang:s,t9nLocale:V(s)}},D=(t,s,e,o)=>{let r,n=()=>W(t,s(),o).then(a=>{(r?.lang!==a.lang||r.t9nLocale!==a.t9nLocale||r.t9nStrings!==a.t9nStrings)&&e(a),r=a}).catch(a=>{g("error","intl","Error updating component locale state",{detail:{error:a}})});return queueMicrotask(n),A(t,["lang"],n)},W=async(t,s,e=t.localName.split("-").slice(1).join("-"))=>{let{lang:o,t9nLocale:r}=b(t),n=`${s}/${e}/t9n`,i=e===null?{}:await I(r,n,"messages.");return{lang:o,t9nLocale:r,t9nStrings:i}};var K="ar,bg,bs,ca,cs,da,de,el,en,es,et,fi,fr,he,hr,hu,id,it,ja,ko,lt,lv,nl,nb,no,pl,pt-BR,pt-PT,ro,ru,sk,sl,sr,sv,th,tr,uk,vi,zh-CN,zh-HK,zh-TW".split(","),q=new Set(K),h="en",R={pt:"pt-BR",nb:"no",nn:"no",zh:"zh-CN"},I=async(t,s,e="")=>{let o=`${s}/${e}`,r=`${o}${t}.json`;return j[r]??=k(t,o),await j[r]},j={},k=async(t,s)=>{let e=`${s}${t}.json`;try{let o=await fetch(e);if(o.ok)return await o.json()}catch(o){return g("error","intl",`An unknown error occurred while fetching localization strings at ${e}`,{detail:{error:o}}),{}}return t===h?{}:await k(h,s)},V=t=>{let[s,e]=t.split("-"),o=s.toLowerCase(),r=o;return e&&(r=`${o}-${e.toUpperCase()}`),r=R[r]??r,q.has(r)?r:e?V(o):h};var z=t=>B(void 0,t);var E=class extends w{constructor(s,e){super(s);let o=this.exports;try{C(this.component);let r=e(this.component,this),n=this.exports!==o;if(x(r)){n||this.setProvisionalExports(r);let a=r.then(i=>{this.exports=i,super.catchUpLifecycle()}).catch(i=>{this.P.reject(i)});this.onLoad(async()=>await a)}else(!n||r!==void 0)&&(this.exports=r),queueMicrotask(()=>super.catchUpLifecycle())}catch(r){this.P.reject(r)}}catchUpLifecycle(){}},B=_(E);var it=(t,s,e)=>z((o,r)=>{let n=s,a=O({bubbles:!1,composed:!1});return r.onUpdated(i=>{if(!n.some(c=>i.has(c)))return;let l=e(T(t,n,i)),d=e(T(t,n));l.forEach((c,p)=>{d.has(p)||a.emit({...c,data:void 0})}),d.forEach((c,p)=>{let u=l.get(p);(!u||!M(u,c))&&a.emit(c)})}),a});function T(t,s,e){let o={};return s.forEach(r=>{o[r]=e?.has(r)?e.get(r):t[r]}),o}function M(t,s){if(t===s)return!0;if(!t||!s||typeof t!="object"||typeof s!="object"||Array.isArray(t)||Array.isArray(s))return!1;let e=Object.entries(t),o=Object.entries(s);return e.length!==o.length?!1:e.every(([r,n])=>M(n,s[r]))}var S=t=>(s={})=>z((e,o)=>{let r=b(e.el),n={_lang:r.lang,_t9nLocale:r.t9nLocale,_loading:!0},a=e;o.onLifecycle(()=>D(e.el,()=>t("./assets"),({t9nLocale:l,t9nStrings:d,lang:c})=>{let p={...d,_lang:c,_t9nLocale:l,_loading:!1};o.exports=p;let u=d.componentLabel;typeof u=="string"&&"label"in e&&e.label==null&&(e.label??=u),i(a.messageOverrides)},s.name));let i=l=>{let d=o.exports,c=d._original??d,p=U(c,l);l&&(p._original=c),o.exports=p};return"messageOverrides"in a&&o.onUpdate(l=>{l.has("messageOverrides")&&i(a.messageOverrides)}),s.blocking?(o.setProvisionalExports(n,!1),o.ready):n}),U=(t,s)=>{if(!s)return t;let e={...t};return Object.entries(s).forEach(([o,r])=>{t[o]!==void 0&&(typeof r=="object"?e[o]=U(t[o],r):e[o]=r??t[o])}),e};var dt=S($);export{it as a,dt as b};
@@ -0,0 +1,2 @@
1
+ /* COPYRIGHT Esri - https://js.arcgis.com/5.2/LICENSE.txt */
2
+ import{a as s,b as i}from"./3UEKINYC.js";import{c as r}from"./RLEHNAIA.js";function c(e,n){let t=s(e.el,e.referenceElement);if(t)return t;let o=r(e.el,"arcgis-assistant"),a=s(e.el,o?.referenceElement);if(a)return a;throw new Error(`${n}: Reference element not found`)}function g(e,n){let t=c(e,n).view;if(!t)throw new Error(`${n}: Reference element does not have a view`);return t}function m(e){return typeof e=="function"}function w(e){let n=r(e.el,"arcgis-assistant");if(n===void 0)throw new Error("arcgis-assistant-agent must be used within an arcgis-assistant element");return n.register({agent:e.agent,getContext:async()=>await e.getContext?.()??e.context??{}}),n}function f(e){let n=i(e.el,e.referenceElement);if(n)return n;let t=r(e.el,"arcgis-assistant");return s(e.el,t?.referenceElement)||null}function E(e){let n=f(e);return n?n.view:null}export{g as a,m as b,w as c,E as d};
@@ -0,0 +1,134 @@
1
+ /* COPYRIGHT Esri - https://js.arcgis.com/5.2/LICENSE.txt */
2
+ import"./UZLQALHY.js";var e=`# ArcGIS Knowledge Agent \u2014 Action Summary
3
+
4
+ You are a Knowledge Graph assistant that has executed tool calls to answer a user request.
5
+
6
+ ## Context
7
+
8
+ **Data model**
9
+ {dataModelSummary}
10
+
11
+ **Assigned task**
12
+ {assignedTask}
13
+
14
+ **User request**
15
+ {userRequest}
16
+
17
+ **Tool result**
18
+ {toolResult}
19
+
20
+ ---
21
+
22
+ ## Goal
23
+
24
+ Generate a concise, complete Markdown response using the tool results.
25
+
26
+ ---
27
+
28
+ ## Priority Rules (Strict Order)
29
+
30
+ ### 1. User Formatting Override (Highest Priority)
31
+
32
+ - If the user specifies a format (table, list, bullets, etc.):
33
+ - Use that format exactly
34
+ - Ignore ALL default formatting rules below
35
+ - Do NOT add summaries or extra sections unless requested
36
+
37
+ ---
38
+
39
+ ### 2. Default Output (When no override)
40
+
41
+ Produce:
42
+
43
+ - **Summary**: 1\u20132 sentences (no header, no bullets)
44
+ - **Results**: Minimal, well-formatted data
45
+ - **Note (optional)**:
46
+ - 1\u20132 italicized sentences describing tool limitations
47
+
48
+ #### Limits
49
+
50
+ - maxPreviewItems: 5
51
+
52
+ ---
53
+
54
+ ### 3. Output Constraints (Non-Negotiable)
55
+
56
+ - Output **valid Markdown only** (no JSON)
57
+ - Do NOT hallucinate data (entities, fields, counts, relationships)
58
+ - Do NOT include:
59
+ - reasoning
60
+ - classification labels
61
+ - follow-up questions
62
+ - next steps
63
+ - intro phrases (\u201CHere are\u2026\u201D)
64
+ - restating the question
65
+ - End immediately after the response
66
+
67
+ ---
68
+
69
+ ### 4. Data Handling Rules
70
+
71
+ - If results are empty \u2192 clearly state no results returned
72
+ - If insufficient data \u2192 state limitation, do NOT speculate
73
+ - Do NOT output:
74
+ - raw nested objects
75
+ - large arrays
76
+ - geometry
77
+ - Summarize complex structures
78
+ - Truncate long values with \`\u2026\`
79
+ - Show entities/relationships only once
80
+ - Use:
81
+ - \u201Centity\u201D (not node)
82
+ - \u201Crelationship\u201D (not edge)
83
+ - Hide \`globalid\` and \`objectid\` unless explicitly requested
84
+
85
+ ---
86
+
87
+ ### 5. Formatting Rules (Default Mode Only)
88
+
89
+ - No headers; use _italic labels_ if needed
90
+ - Use:
91
+ - bullets \u2192 single item summaries
92
+ - tables \u2192 multiple results (limit to 5 rows)
93
+ - Reduce columns to key fields only
94
+ - Format:
95
+ - dates \u2192 \u201Cday month year\u201D
96
+ - time separate from date
97
+
98
+ ---
99
+
100
+ ### 6. Result-Type Formatting
101
+
102
+ **SEARCH_HITS**
103
+
104
+ - Highlight top match (bullets)
105
+ - Table for remaining results
106
+
107
+ **ENTITIES**
108
+
109
+ - Group by type (if multiple)
110
+ - Show key properties only
111
+
112
+ **RELATIONSHIPS**
113
+
114
+ - Format: \`(entity) \u2014[relationship]\u2192 (entity)\`
115
+
116
+ **PATHS**
117
+
118
+ - Summary + 1-3 examples
119
+
120
+ ---
121
+
122
+ ## Internal Processing (Do NOT output)
123
+
124
+ Classify results into:
125
+
126
+ - SEARCH_HITS, ENTITIES, RELATIONSHIPS, PATHS
127
+
128
+ ## Failure Handling
129
+
130
+ - If data is insufficient \u2192 clearly state limitation
131
+ - Never infer or fabricate missing information
132
+
133
+ ---
134
+ `;export{e as default};
@@ -0,0 +1,2 @@
1
+ /* COPYRIGHT Esri - https://js.arcgis.com/5.2/LICENSE.txt */
2
+ import{a as u}from"./ONQ6JSBJ.js";import{Dc as d}from"./AI6DYOKR.js";import{Dd as s}from"./MWYBF3F3.js";async function f(o,a,n){let e=n.map?.allLayers.find(r=>r.id===o);if(!e)return{text:`Error: Layer with id ${o} not found`};let t=a?.trim()?a:"1=1",l=e.createQuery();l.where=t;try{let{extent:r,count:i}=await e.queryExtent(l);if(i===0)return{text:`No features found in ${e.title} matching: ${t}`,where:t};if(r)await n.goTo(r);else return{text:`Error: Unable to determine extent for ${e.title}`,where:t};let c={layerId:o,layerTitle:e.title??o,where:t,count:i};return{text:`Successfully zoomed to ${i} feature(s) in ${e.title} matching: ${t}`,where:t,sharedStatePatch:{lastNavigatedFeatures:{value:c}}}}catch(r){return console.error("Error in goToFeatures:",r),{text:`Error: ${r instanceof Error?r.message:"Unknown error"}`,where:t}}}async function h({layerId:o,where:a},n){let{mapView:e}=u(n,["mapView"]);return await f(o,a,e)}var m=s.object({layerId:s.string().describe("The layerId of the layer to zoom to."),where:s.string().describe("ArcGIS SQL-92 WHERE expression used for `query.where` on the selected layer. Start with a fresh filter for the current request unless the task explicitly refers to prior results. Use only field name values from the selected layer, not aliases. Use field metadata only to interpret intent: prefer LIKE '%value%' for string fields, and use =, <, >, BETWEEN, IN, IS NULL, AND/OR/NOT as appropriate for number/date fields. For coded-value domain fields, use the domain code already provided in layerInfo.domain.codedValues, never the display label. Respect range-domain bounds when they are provided. Do NOT include subqueries, nested SELECT, JOIN, GROUP BY, HAVING, ORDER BY, or semicolons.")}),E=d(h,{name:"goToFeatures",description:"Go to the features that match the given filter for the given layerId. Use coded-value domain codes from layer field metadata when building the WHERE clause.",schema:m});export{E as a};
@@ -0,0 +1,2 @@
1
+ /* COPYRIGHT Esri - https://js.arcgis.com/5.2/LICENSE.txt */
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")
@@ -0,0 +1,56 @@
1
+ /* COPYRIGHT Esri - https://js.arcgis.com/5.2/LICENSE.txt */
2
+ import{$ as It,J as ot,Na as oe,Oa as at,Qa as W,Ra as Ot,S as Et,U as rt,Ua as Le,Wa as be,Xa as De,Ya as Nt,_ as At,a as ft,aa as Rt,b as R,f as $,j as L,k as H,ta as je,wa as Pt,x as Ke,y as pt}from"./EWLXNGKH.js";import{$ as wt,Ab as Ct,Ac as st,Ba as yt,Bb as te,Cb as _t,K as Ze,Kb as F,Lb as de,Nb as xt,Qb as Pe,Sb as St,Vb as i,W as M,Wa as qe,Xb as tt,Za as B,Zb as Oe,_a as ce,ab as Ae,bb as Mt,bc as Te,c as ht,cc as Y,db as et,ea as T,fb as Tt,fc as ue,ha as Xe,hc as Ne,p as Ye,qa as Q,qb as Me,rb as Ie,ua as Qe,ub as Re,uc as nt,v as gt,va as z,wc as kt,yb as vt}from"./AI6DYOKR.js";import{Dd as U,s as bt}from"./MWYBF3F3.js";var $e=Symbol.for("AgentMiddleware");function E(e){return{[$e]:!0,name:e.name,stateSchema:e.stateSchema,contextSchema:e.contextSchema,wrapToolCall:e.wrapToolCall,wrapModelCall:e.wrapModelCall,beforeAgent:e.beforeAgent,beforeModel:e.beforeModel,afterModel:e.afterModel,afterAgent:e.afterAgent,tools:e.tools,streamTransformers:e.streamTransformers}}var ve=class extends Error{constructor(){super("The provided LLM already has bound tools. Please provide an LLM without bound tools to createAgent. The agent will bind the tools provided in the 'tools' parameter.")}},Ce=class extends Error{toolNames;constructor(e){super(`The model has called multiple tools: ${e.join(", ")} to return a structured output. This is not supported. Please provide a single structured output.`),this.toolNames=e}},me=class extends Error{toolName;errors;constructor(e,t){super(`Failed to parse structured output for tool '${e}':${t.map(o=>`
3
+ - ${o}`).join("")}.`),this.toolName=e,this.errors=t}},fe=class extends Error{"~brand"="ToolInvocationError";toolCall;toolError;constructor(e,t){let o=e instanceof Error?e:new Error(String(e)),n=JSON.stringify(t.args);super(`Error invoking tool '${t.name}' with kwargs ${n} with error: ${o.stack}
4
+ Please fix the error and try again.`),this.toolCall=t,this.toolError=o}static isInstance(e){return e instanceof Error&&"~brand"in e&&e["~brand"]==="ToolInvocationError"}static[Symbol.hasInstance](e){return this.isInstance(e)}},ne=class jt extends Error{"~brand"="MiddlewareError";constructor(t,o){let n=t instanceof Error?t.message:String(t);super(n),this.name=t instanceof Error?t.name:`${o[0].toUpperCase()+o.slice(1)}Error`,t instanceof Error&&(this.cause=t)}static wrap(t,o){return Ke(t)?t:new jt(t,o)}static isInstance(t){return t instanceof Error&&"~brand"in t&&t["~brand"]==="MiddlewareError"}static[Symbol.hasInstance](t){return this.isInstance(t)}};function _e(e){return"invoke"in e&&typeof e.invoke=="function"&&"_streamResponseChunks"in e}function pe(e){return typeof e=="object"&&e!=null&&"_queuedMethodOperations"in e&&"_getModelInstance"in e&&typeof e._getModelInstance=="function"}var Lt=!0,vo=0,G=class it{schema;tool;options;constructor(t,o,n){this.schema=t,this.tool=o,this.options=n}get name(){return this.tool.function.name}static fromSchema(t,o){function n(a){return a??`extract-${++vo}`}if(Me(t)||Re(t)){let a=Oe(t),l={type:"function",function:{name:n(a.title),strict:!1,description:a.description??"Tool for extracting structured output from the model's response.",parameters:a}};return new it(a,l,o)}let r;typeof t.name=="string"&&typeof t.parameters=="object"&&t.parameters!=null?r=t:r={name:n(t.title),description:t.description??"",parameters:t.schema||t};let s=Oe(t);return new it(s,{type:"function",function:r},o)}parse(t){let o=new tt(this.schema).validate(t);if(!o.valid)throw new me(this.name,o.errors.map(n=>n.error));return t}},q=class Dt{_schemaType;schema;strict;constructor(t,o){if("schema"in t&&typeof t.schema=="object"&&t.schema!==null&&!("type"in t)){let n=t;this.schema=n.schema,this.strict=n.strict??Lt}else this.schema=t,this.strict=o??Lt}static fromSchema(t,o){let n=Oe(t);return new Dt(n,o)}parse(t){let o;if(typeof t.content=="string")o=t.content;else if(Array.isArray(t.content)){for(let n of t.content)if(typeof n=="object"&&n!==null&&"type"in n&&n.type==="text"&&"text"in n&&typeof n.text=="string"){o=n.text;break}}if(!(!o||o===""))try{let n=JSON.parse(o);return new tt(this.schema).validate(n).valid?n:void 0}catch{}}};function $t(e,t,o){if(!e)return[];if(typeof e=="object"&&e!==null&&"__responseFormatUndefined"in e)return[];if(Array.isArray(e)){if(e.every(r=>r instanceof G||r instanceof q))return e;if(e.every(r=>Me(r)))return e.map(r=>G.fromSchema(r,t));if(e.every(r=>F(r)))return e.map(r=>G.fromSchema(r,t));if(e.every(r=>typeof r=="object"&&r!==null&&!F(r)&&!Me(r)))return e.map(r=>G.fromSchema(r,t));throw new Error(`Invalid response format: list contains mixed types.
5
+ All items must be either InteropZodObject, Standard Schema, or plain JSON schema objects.`)}if(e instanceof G||e instanceof q)return[e];let n=Co(o);if(Me(e))return n?[q.fromSchema(e)]:[G.fromSchema(e,t)];if(F(e))return n?[q.fromSchema(e)]:[G.fromSchema(e,t)];if(typeof e=="object"&&e!==null&&"properties"in e)return n?[q.fromSchema(e)]:[G.fromSchema(e,t)];throw new Error(`Invalid response format: ${String(e)}`)}function Co(e){return!e||!_e(e)||!("profile"in e)||typeof e.profile!="object"||!e.profile?!1:"structuredOutput"in e.profile&&e.profile.structuredOutput===!0}function _o(e,t){if(e.length<t.length||e.length>t.length+1)return!1;for(let o=0;o<t.length;o+=1)if(e[o]!==t[o])return!1;return!0}function xo(e){let t;try{t=JSON.parse(e)}catch{return!1}return!Array.isArray(t)||t.length===0?!1:t.every(o=>{if(o==null||typeof o!="object")return!1;let n=o;return typeof n.id=="string"&&"value"in n})}function So(e){if(e==null||typeof e!="object")return!1;let t=e;return t.type!=="constructor"||!Array.isArray(t.id)?!1:t.id[t.id.length-1]==="ToolMessage"}function ko(e){return M.isInstance(e)?e.content:So(e)?e.kwargs?.content:e}function ae(e){return()=>{let t=je.local(),o=new Map;function n(r,s,a){if(o.has(r))return;let l=typeof a=="string"?JSON.parse(a):a,u,m,c,h,d=new Promise((x,y)=>{u=x,m=y}),f=new Promise(x=>{c=x}),g=new Promise(x=>{h=x});o.set(r,{resolveOutput:u,rejectOutput:m,resolveStatus:c,resolveError:h}),t.push({name:s,callId:r,input:l,output:d,status:f,error:g})}return{__native:!0,init:()=>({toolCalls:t}),process(r){if(!_o(r.params.namespace,e))return!0;if(r.method==="messages"){let s=r.params.data;if(s.event==="content-block-finish"){let a=s.contentBlock??s.content_block;a?.type==="tool_call"&&n(String(a.id??""),String(a.name??""),a.args??a.input)}}if(r.method==="tools"){let s=r.params.data,a=s.tool_call_id;s.event==="tool-started"&&n(a,s.tool_name??"unknown",s.input);let l=a?o.get(a):void 0;if(l){if(s.event==="tool-finished")l.resolveOutput(ko(s.output)),l.resolveStatus("finished"),l.resolveError(void 0),o.delete(a);else if(s.event==="tool-error"){let u=s.message??"unknown error";if(xo(u))return!0;l.rejectOutput(new Error(u)),l.resolveStatus("error"),l.resolveError(u),o.delete(a)}}}return!0},finalize(){for(let r of o.values())r.resolveStatus("finished"),r.resolveError(void 0),r.resolveOutput(void 0);o.clear(),t.close()},fail(r){for(let s of o.values())s.resolveStatus("error"),s.resolveError(r instanceof Error?r.message:String(r)),s.rejectOutput(r);o.clear(),t.fail(r)}}}}function Z(e){return typeof e=="object"&&e!==null&&!Array.isArray(e)}function xe(e){return e.join("\0")}function Bt(e,t){if(t.length>e.length)return!1;for(let o=0;o<t.length;o+=1)if(e[o]!==t[o])return!1;return!0}function he(e=[]){return()=>{let t=je.local(),o=new Map,n=new Map,r=new Map,s=new Map,a=e.length;function l(d,f){let g=xe(d);if(o.has(g))return;let x=(Z(f)&&Z(f.metadata)?f.metadata:void 0)?.lc_agent_name;o.set(g,typeof x=="string"?x:void 0)}function u(d){if(!Z(d))return;let f=d.id;if(typeof f!="string")return;let g=d.input,x;if(Z(g)&&Z(g.tool_call)){let y=g.tool_call.id;typeof y=="string"&&(x=y)}else if(Array.isArray(g)){for(let y of g)if(Z(y)&&typeof y.id=="string"){x=y.id;break}}x!=null&&n.set(f,x)}function m(d){let f=r.get(xe(d));if(typeof f=="string"&&f.length>0)return{type:"toolCall",tool_call_id:f};let g=d[d.length-1],x=g.indexOf(":");if(x===-1)return;let y=g.slice(x+1);if(y.length===0)return;let w=n.get(y);if(!(typeof w!="string"||w.length===0))return{type:"toolCall",tool_call_id:w}}function c(d){if(d.length!==a+1||!Bt(d,e))return;let f=xe(d);if(s.has(f))return;let g=o.get(f);if(typeof g!="string"||g.length===0)return;let x=Pt(d),y=x.init(),w=ae(d)(),O=w.init(),A=he(d)(),N=A.init(),K,j,b=new Promise((J,le)=>{K=J,j=le});s.set(f,{key:f,path:d,name:g,messages:x,toolCall:w,nested:A,resolveOutput:K,rejectOutput:j,latestValues:void 0,done:!1}),t.push({name:g,cause:m(d),output:b,messages:y.messages,toolCalls:O.toolCalls,subagents:N.subagents})}function h(d,f){d.done||(d.done=!0,f.type==="resolve"?d.resolveOutput(d.latestValues):d.rejectOutput(f.error),d.messages.finalize?.(),d.toolCall.finalize?.(),d.nested.finalize?.())}return{__native:!0,init:()=>({subagents:t}),process(d){let f=d.params.namespace,g=d.params.data,x=d.method==="tasks"&&Z(g)&&"result"in g;d.method==="tools"&&Z(g)&&g.event==="tool-started"&&typeof g.tool_call_id=="string"&&g.tool_call_id.length>0&&r.set(xe(f),g.tool_call_id),d.method==="tasks"&&!x&&(l(f,g),u(g),c(f));for(let y of s.values())if(!y.done&&Bt(f,y.path)&&(y.messages.process(d),y.toolCall.process(d),y.nested.process(d),xe(f)===y.key)){if(d.method==="values"&&Z(g))y.latestValues=g;else if(d.method==="lifecycle"&&Z(g)){let w=g.event;w==="completed"||w==="interrupted"?h(y,{type:"resolve"}):w==="failed"&&h(y,{type:"reject",error:new Error(`Subagent ${y.name} failed`)})}}return!0},finalize(){for(let d of s.values())h(d,{type:"resolve"});t.close()},fail(d){for(let f of s.values())h(f,{type:"reject",error:d});t.fail(d)}}}}var lt=Symbol.for("langgraph-zod");lt in globalThis||(globalThis[lt]=new WeakSet);function Ut(e){let t=globalThis[lt];t.has(e)||(Object.defineProperty(e,"langgraph",{get(){let o=this;return{metadata(n){return De(o,{jsonSchemaExtra:n})},reducer(n,r){return De(o,{default:Pe(o),reducer:{schema:r,fn:n}})}}}}),t.add(e))}try{Ut(i.ZodType.prototype),Ut(U.ZodType.prototype)}catch(e){throw new Error("Failed to extend Zod with LangGraph-related methods. This is most likely a bug, consider opening an issue and/or using `withLangGraph` to augment your Zod schema.",{cause:e})}var zt=class extends bt{constructor(e){super(),this.parent=e,this._map=this.parent._map}add(e,...t){let o=t[0];if(o&&!o?.default){let n=Pe(e);n!=null&&(o.default=n)}return super.add(e,...t)}},Eo=new zt(be);function Ft(e=!0,t,o=[]){let n={jumpTo:new at},r={},s={},a=l=>{if(W.isInstance(l)){for(let[m,c]of Object.entries(l.fields))if(!(m in n)){if(n[m]=c,m.startsWith("_"))continue;oe.isInstance(c)?(r[m]=c.inputSchema||c.valueSchema,s[m]=c.valueSchema):(r[m]=c,s[m]=c)}return}let u=de(l);for(let[m,c]of Object.entries(u)){let h=m.startsWith("_");if(!(m in n)){if(Ie(c)){let d=be.get(c);if(d?.reducer){d.reducer.schema?(n[m]=new oe(c,{inputSchema:d.reducer.schema,reducer:d.reducer.fn}),h||(r[m]=d.reducer.schema,s[m]=c)):(n[m]=new oe(c,{reducer:d.reducer.fn}),h||(r[m]=c,s[m]=c));continue}}n[m]=c,h||(r[m]=c,s[m]=c)}}};t&&(W.isInstance(t)||F(t))&&a(t);for(let l of o)l.stateSchema&&(W.isInstance(l.stateSchema)||F(l.stateSchema))&&a(l.stateSchema);return e&&(s.structuredResponse=new at),{state:new W({messages:Le,...n}),input:new W({messages:Le,...r}),output:new W({messages:Le,...s})}}var ct=/<name>(.*?)<\/name>/s,dt=/<content>(.*?)<\/content>/s;function Ao(e,t){if(W.isInstance(e)){let o={};for(let n of Object.keys(e.fields))n in t&&(o[n]=t[n]);return o}if(Re(e))return te(e,t);throw new Error(`Invalid state schema type: ${typeof e}`)}function Ht(e){if(!T.isInstance(e)||Xe.isInstance(e)||!e.name)return e;let{name:t}=e;if(typeof e.content=="string")return new T({...e.lc_kwargs,content:`<name>${t}</name><content>${e.content}</content>`,name:void 0});let o=[],n=0;for(let r of e.content)typeof r=="string"?(n+=1,o.push(`<name>${t}</name><content>${r}</content>`)):typeof r=="object"&&"type"in r&&r.type==="text"?(n+=1,o.push({...r,text:`<name>${t}</name><content>${r.text}</content>`})):o.push(r);return n||o.unshift({type:"text",text:`<name>${t}</name><content></content>`}),new T({...e.lc_kwargs,content:o,name:void 0})}function Gt(e){if(!T.isInstance(e)||!e.content)return e;let t=[],o;if(Array.isArray(e.content))t=e.content.filter(n=>{if(n.type==="text"&&typeof n.text=="string"){let r=n.text.match(ct),s=n.text.match(dt);return r&&(!s||s[1]==="")?(o=r[1],!1):!0}return!0}).map(n=>{if(n.type==="text"&&typeof n.text=="string"){let r=n.text.match(ct),s=n.text.match(dt);return!r||!s?n:(o=r[1],{...n,text:s[1]})}return n});else{let n=e.content,r=n.match(ct),s=n.match(dt);if(!r||!s)return e;o=r[1],t=s[1]}return new T({...Object.keys(e.lc_kwargs??{}).length>0?e.lc_kwargs:e,content:t,name:o})}function ie(e){return Te.isRunnable(e)}function Wt(e){return _e(e)?"bindTools"in e&&typeof e.bindTools=="function":!1}var ut=(e,t,o={})=>{if(Wt(e))return e.bindTools(t,o);if(Y.isRunnableBinding(e)&&Wt(e.bound)){let n=e.bound.bindTools(t,o);return Y.isRunnableBinding(n)?new Y({bound:n.bound,config:{...e.config,...n.config},kwargs:{...e.kwargs,...n.kwargs},configFactories:n.configFactories??e.configFactories}):new Y({bound:n,config:e.config,kwargs:e.kwargs,configFactories:e.configFactories})}return null};function Be(e){if(typeof e=="function")return;let t=e;if(ue.isRunnableSequence(t)&&(t=t.steps.find(o=>Y.isRunnableBinding(o))||t),!pe(t)){if(Y.isRunnableBinding(t)){let o=t.kwargs!=null&&typeof t.kwargs=="object"&&"tools"in t.kwargs&&Array.isArray(t.kwargs.tools)&&t.kwargs.tools.length>0,n=t.config!=null&&typeof t.config=="object"&&"tools"in t.config&&Array.isArray(t.config.tools)&&t.config.tools.length>0;if(o||n)throw new ve}if("tools"in t&&t.tools!==void 0&&Array.isArray(t.tools)&&t.tools.length>0)throw new ve}}function ge(e){return!!(T.isInstance(e)&&e.tool_calls&&e.tool_calls.length>0)}function Jt(e){if(e==null)return new z("");if(z.isInstance(e))return e;if(typeof e=="string")return new z({content:[{type:"text",text:e}]});throw new Error(`Invalid systemPrompt type: expected string or SystemMessage, got ${typeof e}`)}async function Vt(e,t,o={}){let n=ut(e,t,o);if(n)return n;if(pe(e)){let r=ut(await e._getModelInstance(),t,o);if(r)return r}if(ue.isRunnableSequence(e)){let r=e.steps.findIndex(s=>Y.isRunnableBinding(s)||_e(s)||pe(s));if(r>=0){let s=ut(e.steps[r],t,o);if(s){let a=e.steps.slice();return a.splice(r,1,s),ue.from(a)}}}throw new Error(`llm ${e} must define bindTools method.`)}function Io(e){if(e.length===0)return;if(e.length===1)return e[0];function t(n,r){return async(s,a)=>n(s,async u=>r(u,a))}let o=e[e.length-1];for(let n=e.length-2;n>=0;n--)o=t(e[n],o);return o}function Kt(e){let t=e.filter(o=>o.wrapToolCall);if(t.length!==0)return Io(t.map(o=>{let n=o.wrapToolCall;return async(s,a)=>{let l=s.state,u=new Set,m=async c=>{let h={...l,...c.state};try{return await a({...c,state:h})}catch(d){throw u.add(d),d}};try{let c=await n({...s,state:{messages:l.messages,...o.stateSchema?Ao(o.stateSchema,{...l}):{}}},m);if(!M.isInstance(c)&&!H(c))throw new Error(`Invalid response from "wrapToolCall" in middleware "${o.name}": expected ToolMessage or Command, got ${typeof c}`);return c}catch(c){throw u.has(c)?c:ne.wrap(c,o.name)}}}))}var Ro=["tags","metadata","runName","maxConcurrency","recursionLimit","configurable"];function Yt(e){let t={};for(let o of Ro){let n=e[o];n!==void 0&&(t[o]=n)}return t}async function Zt(e,t){let o={};for(let n of e){if(!n.stateSchema)continue;let r;if(W.isInstance(n.stateSchema)){let l={};for(let[u,m]of Object.entries(n.stateSchema.fields))oe.isInstance(m)?l[u]=m.inputSchema||m.valueSchema:l[u]=m;r=U.object(l)}else if(F(n.stateSchema))r=n.stateSchema;else continue;let s=await vt(St(r,l=>l.startsWith("_")),t);if(s.success){Object.assign(o,s.data);continue}let a=s.error.issues.filter(l=>l.code==="invalid_type").map(l=>` - ${l.path.join(".")}: Required`).join(`
6
+ `);throw new Error(`Middleware "${n.name}" has required state fields that must be initialized:
7
+ ${a}
8
+
9
+ To fix this, either:
10
+ 1. Provide default values in your middleware's state schema using .default():
11
+ stateSchema: z.object({
12
+ myField: z.string().default("default value")
13
+ })
14
+
15
+ 2. Or make the fields optional using .optional():
16
+ stateSchema: z.object({
17
+ myField: z.string().optional()
18
+ })
19
+
20
+ 3. Or ensure you pass these values when invoking the agent:
21
+ agent.invoke({
22
+ messages: [...],
23
+ ${s.error.issues[0]?.path.join(".")}: "value"
24
+ })`)}return o}function Xt(e){let t={messages:U.custom(()=>[]),structuredResponse:U.any().optional()};if(!e)return U.object(t);let o;if(W.isInstance(e)){o={};for(let[r,s]of Object.entries(e.fields))oe.isInstance(s)?o[r]=s.inputSchema||s.valueSchema:o[r]=s}else if(F(e))o=de(e);else return U.object(t);let n={...t};for(let[r,s]of Object.entries(o))r.startsWith("_")?n[r]=s.optional():n[r]=s;return U.object(n)}function Qt(e){if(F(e))return xt(e);if(W.isInstance(e)){let t={};for(let[o,n]of Object.entries(e.fields)){let r;oe.isInstance(n)?r=n.inputSchema||n.valueSchema:r=n,t[o]=Ie(r)?r.optional():U.any().optional()}return U.object(t)}return U.object({})}function V(e){if(e){if(["model_request","tools",R].includes(e))return e;if(e==="model")return"model_request";if(e==="tools")return"tools";if(e==="end")return R;throw new Error(`Invalid jump target: ${e}, must be "model", "tools" or "end".`)}}function Ue(...e){return AbortSignal.any(e.filter(t=>t!=null&&typeof t=="object"&&"aborted"in t&&typeof t.aborted=="boolean"))}function Oo({apiKey:e,configuration:t={}}){let o=Rt({baseURL:t.baseURL,providerPath:"v1"});return{apiKey:e??t.apiKey??o.apiKey??(Ye("LANGSMITH_GATEWAY_API_KEY")||Ye("LANGSMITH_API_KEY")),configuration:{...t,baseURL:o.baseURL??`${It}/v1`},useResponsesApi:!0}}var Fe={openai:{package:"@langchain/openai",className:"ChatOpenAI"},anthropic:{package:"@langchain/anthropic",className:"ChatAnthropic"},azure_openai:{package:"@langchain/openai",className:"AzureChatOpenAI"},langsmith:{package:"@langchain/openai",className:"ChatOpenAI"},cohere:{package:"@langchain/cohere",className:"ChatCohere"},google:{package:"@langchain/google",className:"ChatGoogle"},"google-vertexai":{package:"@langchain/google-vertexai",className:"ChatVertexAI"},"google-vertexai-web":{package:"@langchain/google-vertexai-web",className:"ChatVertexAI"},"google-genai":{package:"@langchain/google-genai",className:"ChatGoogleGenerativeAI"},ollama:{package:"@langchain/ollama",className:"ChatOllama"},mistralai:{package:"@langchain/mistralai",className:"ChatMistralAI"},mistral:{package:"@langchain/mistralai",className:"ChatMistralAI"},groq:{package:"@langchain/groq",className:"ChatGroq"},bedrock:{package:"@langchain/aws",className:"ChatBedrockConverse"},aws:{package:"@langchain/aws",className:"ChatBedrockConverse"},deepseek:{package:"@langchain/deepseek",className:"ChatDeepSeek"},xai:{package:"@langchain/xai",className:"ChatXAI"},cerebras:{package:"@langchain/cerebras",className:"ChatCerebras"},fireworks:{package:"@langchain/fireworks",className:"ChatFireworks"},together:{package:"@langchain/together-ai",className:"ChatTogetherAI",hasCircularDependency:!0},perplexity:{package:"@langchain/perplexity",className:"ChatPerplexity"}},eo=Object.keys(Fe);async function No(e,t){let o;if(t)o=Fe[t];else{let n=Object.entries(Fe).find(([,r])=>r.className===e);o=n?n[1]:void 0}if(o)try{return(await import(o.package))[o.className]}catch(n){let r=n;if("code"in r&&r.code?.toString().includes("ERR_MODULE_NOT_FOUND")&&"message"in r&&typeof r.message=="string"){let s=(r.message.startsWith("Error: ")?r.message.slice(7):r.message).split("Cannot find package '")[1].split("'")[0];throw new Error(`Unable to import ${s}. Please install with \`npm install ${s}\` or \`pnpm install ${s}\``)}throw n}}async function jo(e,t,o={}){let n=t||Lo(e);if(!n)throw new Error(`Unable to infer model provider for { model: ${e} }, please specify modelProvider directly.`);let r=Fe[n];if(!r){let l=eo.join(", ");throw new Error(`Unsupported { modelProvider: ${n} }.
25
+
26
+ Supported model providers are: ${l}`)}let{modelProvider:s,...a}=o;return new(await No(r.className,n))({model:e,...a,...n==="langsmith"?Oo(a):{}})}function Lo(e){return e.startsWith("gpt-3")||e.startsWith("gpt-4")||e.startsWith("gpt-5")||e.startsWith("o1")||e.startsWith("o3")||e.startsWith("o4")?"openai":e.startsWith("claude")?"anthropic":e.startsWith("command")?"cohere":e.startsWith("accounts/fireworks")?"fireworks":e.startsWith("gemini")?"google-vertexai":e.startsWith("amazon.")?"bedrock":e.startsWith("mistral")?"mistralai":e.startsWith("sonar")||e.startsWith("pplx")?"perplexity":void 0}var qt=class ze extends rt{_llmType(){return"chat_model"}lc_namespace=["langchain","chat_models"];_defaultConfig={};_configurableFields="any";_configPrefix;_queuedMethodOperations={};_modelInstanceCache=new Map;_profile;constructor(t){super(t),this._defaultConfig=t.defaultConfig??{},t.configurableFields==="any"?this._configurableFields="any":this._configurableFields=t.configurableFields??["model","modelProvider"],t.configPrefix?this._configPrefix=t.configPrefix.endsWith("_")?t.configPrefix:`${t.configPrefix}_`:this._configPrefix="",this._queuedMethodOperations=t.queuedMethodOperations??this._queuedMethodOperations,this._profile=t.profile??void 0,this.metadata={...this.metadata,ls_integration:"langchain_init_chat_model"}}async _getModelInstance(t){let o=this._getCacheKey(t),n=this._modelInstanceCache.get(o);if(n)return n;let r={...this._defaultConfig,...this._modelParams(t)},s=await jo(r.model,r.modelProvider,r);for(let[a,l]of Object.entries(this._queuedMethodOperations))a in s&&typeof s[a]=="function"&&(s=await s[a](...l));return this._modelInstanceCache.set(o,s),s}async _generate(t,o,n){return(await this._getModelInstance(o))._generate(t,o??{},n)}bindTools(t,o){let n={...this._queuedMethodOperations};return n.bindTools=[t,o],new ze({defaultConfig:this._defaultConfig,configurableFields:this._configurableFields,configPrefix:this._configPrefix,queuedMethodOperations:n})}withStructuredOutput=(t,...o)=>{let n={...this._queuedMethodOperations};return n.withStructuredOutput=[t,...o],new ze({defaultConfig:this._defaultConfig,configurableFields:this._configurableFields,configPrefix:this._configPrefix,queuedMethodOperations:n})};_modelParams(t){let o=t?.configurable??{},n={};for(let[r,s]of Object.entries(o))if(r.startsWith(this._configPrefix)){let a=this._removePrefix(r,this._configPrefix);n[a]=s}return this._configurableFields!=="any"&&(n=Object.fromEntries(Object.entries(n).filter(([r])=>this._configurableFields.includes(r)))),n}_removePrefix(t,o){return t.startsWith(o)?t.slice(o.length):t}withConfig(t){let o={...t||{}},n=this._modelParams(o),r=Object.fromEntries(Object.entries(o).filter(([s])=>s!=="configurable"));return r.configurable=Object.fromEntries(Object.entries(o.configurable||{}).filter(([s])=>this._configPrefix&&!Object.keys(n).includes(this._removePrefix(s,this._configPrefix)))),new Y({config:o,bound:new ze({defaultConfig:{...this._defaultConfig,...n},configurableFields:Array.isArray(this._configurableFields)?[...this._configurableFields]:this._configurableFields,configPrefix:this._configPrefix,queuedMethodOperations:this._queuedMethodOperations})})}async invoke(t,o){let n=await this._getModelInstance(o),r=ce(o);return n.invoke(t,r)}async stream(t,o){let n=new Tt({generator:await(await this._getModelInstance(o)).stream(t,o),config:o});return await n.setup,et.fromAsyncGenerator(n)}async batch(t,o,n){return super.batch(t,o,n)}async*transform(t,o){let n=await this._getModelInstance(o),r=ce(o);yield*n.transform(t,r)}async*streamLog(t,o,n){let r=await this._getModelInstance(o),s=ce(o);yield*r.streamLog(t,s,{...n,_schemaFormat:"original",includeNames:n?.includeNames,includeTypes:n?.includeTypes,includeTags:n?.includeTags,excludeNames:n?.excludeNames,excludeTypes:n?.excludeTypes,excludeTags:n?.excludeTags})}streamEvents(t,o,n){if(o?.version==="v1"||o?.version==="v2"){let a=this,l=o;async function*u(){let m=await a._getModelInstance(l),c={...ce(l),version:l.version,...l.encoding!==void 0?{encoding:l.encoding}:{}},h;l.version==="v1"&&l.encoding==="text/event-stream"||l.version==="v1"||l.version==="v2"&&l.encoding,h=m.streamEvents(t,c,n);for await(let d of h)yield d}return et.fromAsyncGenerator(u())}let r=this;async function*s(){let a=await r._getModelInstance(o),l=ce(o);yield*a.streamEvents(t,l)}return new Et(s())}get profile(){if(this._profile)return this._profile;let t=this._getCacheKey({});return this._modelInstanceCache.get(t)?.profile??{}}_getCacheKey(t){let o=t??{};if(o.configurable){let{configurable:n}=o,r={};for(let[s,a]of Object.entries(n))s.startsWith("__pregel_")||(r[s]=a);o={...o,configurable:r}}return JSON.stringify(o)}};async function ee(e,t){let{configurableFields:o,configPrefix:n,modelProvider:r,profile:s,...a}={configPrefix:"",...t??{}};if(r===void 0&&e?.includes(":")){let[c,...h]=e.split(":"),d=h.length===0?[c]:[c,h.join(":")];eo.includes(d[0])&&([r,e]=d)}let l=Array.isArray(o)?[...o]:o;!e&&l===void 0&&(l=["model","modelProvider"]),n&&l===void 0&&console.warn(`{ configPrefix: ${n} } has been set but no fields are configurable. Set { configurableFields: [...] } to specify the model params that are configurable.`);let u={...a},m;return l===void 0?m=new qt({defaultConfig:{...u,model:e,modelProvider:r},configPrefix:n,profile:s}):(e&&(u.model=e),r&&(u.modelProvider=r),m=new qt({defaultConfig:u,configPrefix:n,configurableFields:l,profile:s})),await m._getModelInstance(),m}var we=class extends Te{lc_namespace=["langgraph"];func;tags;config;trace=!0;recurse=!0;#e;constructor(e){super(),this.name=e.name??e.func.name,this.func=e.func,this.config=e.tags?{tags:e.tags}:void 0,this.recurse=e.recurse??this.recurse}getState(){return this.#e}setState(e){this.#e={...this.#e,...e}}async invoke(e,t){let o=B(this.config,t),n=await qe.runWithConfig(o,async()=>this.func(e,o));return Te.isRunnable(n)&&this.recurse?await qe.runWithConfig(o,async()=>n.invoke(e,o)):(this.#e=n,n)}};function to(e,t){let o,n;if(t==="inline")o=Ht,n=Gt;else throw new Error(`Invalid agent name mode: ${t}. Needs to be one of: "inline"`);function r(s){return s.map(o)}return ue.from([Ne.from(r),e,Ne.from(n)])}function Do(e){return T.isInstance(e)||H(e)||typeof e=="object"&&e!==null&&"structuredResponse"in e&&"messages"in e}var P="model_request",oo=class extends we{#e;#o;constructor(e){super({name:e.name??"model",func:(t,o)=>this.#t(t,o)}),this.#e=e,this.#o=e.systemMessage}async#r(e,t=this.#e.responseFormat){if(!t)return;let o;pe(e)?o=await e._getModelInstance():typeof e!="string"&&(o=e);let n=$t(t,void 0,o);if(n.length!==0)return n.every(r=>r instanceof q)?{type:"native",strategy:n[0]}:{type:"tool",tools:n.filter(r=>r instanceof G).reduce((r,s)=>(r[s.name]=s,r),{})}}async#t(e,t){let o=e.messages.at(-1);if(o&&M.isInstance(o)&&o.name&&this.#e.shouldReturnDirect.has(o.name))return[new L({update:{messages:[]}})];let{response:n,lastAiMessage:r,collectedCommands:s}=await this.#a(e,t);if(typeof n=="object"&&n!==null&&"structuredResponse"in n&&"messages"in n){let{structuredResponse:u,messages:m}=n;return{messages:[...e.messages,...m],structuredResponse:u}}let a=[],l=T.isInstance(n)?n:r;return l&&(l.name=this.name,l.lc_kwargs.name=this.name,this.#c(e,l)?a.push(new L({update:{messages:[new T({content:"Sorry, need more steps to process this request.",name:this.name,id:l.id})]}})):a.push(new L({update:{messages:[l]}}))),H(n)&&!s.includes(n)&&a.push(n),a.push(...s),a}#s(){if(typeof this.#e.model=="string")return ee(this.#e.model);if(this.#e.model)return this.#e.model;throw new Error("No model option was provided, either via `model` option.")}async#a(e,t,o={}){let n=await this.#s(),r=t,s=this.#o,a=null,l=[],u=async d=>{Be(d.model);let f=await this.#r(d.model,d.responseFormat),g=await this.#d(d.model,d,f),x=[...s.text===""?[]:[s],...d.messages],y=Ue(this.#e.signal,t.signal),w=await Mt(g.invoke(x,{...t,signal:y}),y);if(a=w,f?.type==="native"){let N=f.strategy.parse(w);if(N)return{structuredResponse:N,messages:[w]};if(!w.tool_calls||w.tool_calls.length===0)throw new me(typeof f.strategy.schema?.title=="string"?f.strategy.schema.title:"providerStrategy",["Model output did not satisfy the provided response schema."]);return w}if(!f||!w.tool_calls)return w;let O=w.tool_calls.filter(N=>N.name in f.tools);if(O.length===0)return w;if(O.length>1)return this.#i(w,O,f);let A=f.tools[O[0].name]?.options?.toolMessageContent;return this.#l(w,O[0],f,A??o.lastMessage)},m=this.#e.wrapModelCallHookMiddleware??[],c=u;for(let d=m.length-1;d>=0;d--){let f=m[d],g=Array.isArray(f)?f[0]:f;if(g.wrapModelCall){let x=c,y=g;c=async w=>{let O=s,A=y.contextSchema?te(y.contextSchema,r?.context||{}):r?.context,N=Object.freeze({context:A,store:r.store,configurable:r.configurable,writer:r.writer,interrupt:r.interrupt,signal:r.signal}),K={...w,state:{...g.stateSchema?te(Qt(g.stateSchema),e):{},messages:e.messages},runtime:N},j=async b=>{s=O;let J=b.tools??[],le=new Map(this.#e.toolClasses.filter(ie).map(_=>[_.name,_])),Ee=J.filter(_=>ie(_)&&!le.has(_.name)),ye=J.filter(_=>{if(!ie(_))return!1;let v=le.get(_.name);return v!=null&&v!==_});if(Ee.length>0&&!this.#e.middleware?.some(_=>_.wrapToolCall!=null))throw new Error(`You have added a new tool in "wrapModelCall" hook of middleware "${y.name}": ${Ee.map(_=>_.name).join(", ")}. This is not supported unless a middleware provides a "wrapToolCall" handler to execute it.`);if(ye.length>0)throw new Error(`You have modified a tool in "wrapModelCall" hook of middleware "${y.name}": ${ye.map(_=>_.name).join(", ")}. This is not supported.`);let p=b,C=b.systemPrompt!==s.text,I=b.systemMessage!==s;if(C&&I)throw new Error("Cannot change both systemPrompt and systemMessage in the same request.");C&&(s=new z({content:[{type:"text",text:b.systemPrompt}]}),p={...b,systemPrompt:s.text,systemMessage:s}),I&&(s=new z({...b.systemMessage}),p={...b,systemPrompt:s.text,systemMessage:s});let k=await x(p);return H(k)&&a?(l.includes(k)||l.push(k),a):k};if(!y.wrapModelCall)return j(K);try{let b=await y.wrapModelCall(K,j);if(!Do(b))throw new Error(`Invalid response from "wrapModelCall" in middleware "${y.name}": expected AIMessage or Command, got ${typeof b}`);return T.isInstance(b)?a=b:H(b)&&l.push(b),b}catch(b){throw ne.wrap(b,y.name)}}}}s=this.#o;let h={model:n,responseFormat:this.#e.responseFormat,systemPrompt:s?.text,systemMessage:s,messages:e.messages,tools:this.#e.toolClasses,state:e,runtime:Object.freeze({context:r?.context,store:r.store,configurable:r.configurable,writer:r.writer,interrupt:r.interrupt,signal:r.signal})};return{response:await c(h),lastAiMessage:a,collectedCommands:l}}#i(e,t,o){let n=new Ce(t.map(r=>r.name));return this.#n(n,e,t[0],o)}#l(e,t,o,n){let r=o.tools[t.name];try{let s=r.parse(t.args);return{structuredResponse:s,messages:[e,new M({tool_call_id:t.id??"",content:JSON.stringify(s),name:t.name}),new T(n??`Returning structured response: ${JSON.stringify(s)}`)]}}catch(s){return this.#n(s,e,t,o)}}async#n(e,t,o,n){let r=Object.values(n.tools).at(0)?.options?.handleError,s=o.id;if(!s)throw new Error("Tool call ID is required to handle tool output errors. Please provide a tool call ID.");if(r===!1)throw e;if(r===void 0||typeof r=="boolean"&&r||Array.isArray(r)&&r.some(a=>a instanceof Ce))return new L({update:{messages:[t,new M({content:e.message,tool_call_id:s})]},goto:P});if(typeof r=="string")return new L({update:{messages:[t,new M({content:r,tool_call_id:s})]},goto:P});if(typeof r=="function"){let a=await r(e);if(typeof a!="string")throw new Error("Error handler must return a string.");return new L({update:{messages:[t,new M({content:a,tool_call_id:s})]},goto:P})}return new L({update:{messages:[t,new M({content:e.message,tool_call_id:s})]},goto:P})}#c(e,t){let o=T.isInstance(t)&&t.tool_calls?.every(r=>this.#e.shouldReturnDirect.has(r.name)),n="remainingSteps"in e?e.remainingSteps:void 0;return!!(n&&(n<1&&o||n<2&&ge(e.messages.at(-1))))}async#d(e,t,o){let n={},r=Object.values(o&&"tools"in o?o.tools:{}),s=[...t?.tools??this.#e.toolClasses,...r.map(u=>u.tool)],a=t?.toolChoice||(r.length>0?"any":void 0);if(o?.type==="native"){let u=t?.modelSettings?.strict??o?.strategy?.strict??!0,m={name:o.strategy.schema?.name??"extract",description:_t(o.strategy.schema),schema:o.strategy.schema,strict:u};Object.assign(n,{response_format:{type:"json_schema",json_schema:m},outputConfig:{format:{type:"json_schema",schema:o.strategy.schema}},responseSchema:o.strategy.schema,ls_structured_output_format:{kwargs:{method:"json_schema"},schema:o.strategy.schema},strict:t?.modelSettings?.strict})}let l=await Vt(e,s,{...n,...t?.modelSettings,tool_choice:a});return this.#e.includeAgentName==="inline"?to(l,this.#e.includeAgentName):l}getState(){let e=super.getState();return{messages:[],...e&&!H(e)?e:{}}}};var no=(e,t)=>`Error: ${e} is not a valid tool, try one of [${t.join(", ")}].`,D="tools",ro=e=>Array.isArray(e)&&e.every(Ze.isInstance),$o=e=>typeof e=="object"&&e!=null&&"messages"in e&&ro(e.messages),Bo=e=>typeof e=="object"&&e!=null&&"lg_tool_call"in e;function Uo(e,t){return fe.isInstance(e)?new M({content:e.message,tool_call_id:t.id,name:t.name}):new M({content:`${e}
27
+ Please fix your mistakes.`,tool_call_id:t.id,name:t.name})}var so=class extends we{options;tools;trace=!1;signal;handleToolErrors=Uo;wrapToolCall;constructor(e,t){let{name:o,tags:n,handleToolErrors:r,signal:s,wrapToolCall:a}=t??{};super({name:o,tags:n,func:(l,u)=>this.run(l,u)}),this.options=t,this.tools=e,this.handleToolErrors=r??this.handleToolErrors,this.signal=s,this.wrapToolCall=a}#e(e,t,o){if(pt(e)||this.signal?.aborted)throw e;let n=e,r=o;if(o){let s=e;for(;ne.isInstance(s);)s=s.cause;fe.isInstance(s)&&(n=s,r=!1)}if(r&&this.handleToolErrors!==!0||!this.handleToolErrors)throw n;if(typeof this.handleToolErrors=="function"){let s=this.handleToolErrors(n,t);if(s&&M.isInstance(s))return s;throw n}else if(this.handleToolErrors)return new M({name:t.name,content:`${n}
28
+ Please fix your mistakes.`,tool_call_id:t.id});throw n}async runTool(e,t,o){let n=t,r={context:n?.context,store:n?.store,configurable:n?.configurable,writer:n?.writer,interrupt:n?.interrupt,signal:n?.signal},s=this.tools.find(u=>u.name===e.name),a=async u=>{let{toolCall:m,tool:c}=u,h=c??this.tools.find(f=>f.name===m.name);if(h===void 0){let f=this.tools.map(g=>g.name);return new M({content:no(m.name,f),tool_call_id:m.id,name:m.name,status:"error"})}let d=h;try{let f=await d.invoke({...m,type:"tool_call"},{...t,config:t,toolCallId:m.id,state:t.configurable?.__pregel_scratchpad?.currentTaskInput,signal:Ue(this.signal,t.signal)});return M.isInstance(f)||H(f)?f:new M({name:d.name,content:typeof f=="string"?f:JSON.stringify(f),tool_call_id:m.id})}catch(f){throw f instanceof wt?new fe(f,m):f}},l={toolCall:e,tool:s,state:o,runtime:r};if(this.wrapToolCall)try{return await this.wrapToolCall(l,a)}catch(u){return this.#e(u,e,!0)}if(!s){let u=this.tools.map(m=>m.name);return new M({content:no(e.name,u),tool_call_id:e.id,name:e.name,status:"error"})}try{return await a(l)}catch(u){return this.#e(u,e,!1)}}async run(e,t){let o;if(Bo(e)){let{lg_tool_call:s,jumpTo:a,...l}=e;o=[await this.runTool(e.lg_tool_call,t,l)]}else{let s;if(ro(e))s=e;else if($o(e))s=e.messages;else throw new Error("ToolNode only accepts BaseMessage[] or { messages: BaseMessage[] } as input.");let a=new Set(s.filter(u=>u.getType()==="tool").map(u=>u.tool_call_id)),l;for(let u=s.length-1;u>=0;u-=1){let m=s[u];if(T.isInstance(m)){l=m;break}}if(!T.isInstance(l))throw new Error("ToolNode only accepts AIMessages as input.");o=await Promise.all(l.tool_calls?.filter(u=>u.id==null||!a.has(u.id)).map(u=>this.runTool(u,t,e))??[])}if(!o.some(H))return Array.isArray(e)?o:{messages:o};let n=[],r=null;for(let s of o)H(s)?s.graph===L.PARENT&&Array.isArray(s.goto)&&s.goto.every(a=>zo(a))?r?r.goto.push(...s.goto):r=new L({graph:L.PARENT,goto:s.goto}):n.push(s):n.push(Array.isArray(e)?[s]:{messages:[s]});return r&&n.push(r),n}};function zo(e){return e instanceof $}function Se(e,t){let n=0;if(t&&t.length>0){let r=0;for(let s of t){let a=st(s)?At(s):s;r+=JSON.stringify(a).length}n+=r}for(let r of e){let s;typeof r.content=="string"?s=r.content:Array.isArray(r.content)?s=r.content.map(a=>typeof a=="string"?a:a.type==="text"&&"text"in a?a.text:"").join(""):s="",T.isInstance(r)&&Array.isArray(r.tool_calls)&&r.tool_calls.length>0&&(s+=JSON.stringify(r.tool_calls)),M.isInstance(r)&&(s+=r.tool_call_id??""),n+=s.length}return Math.ceil(n/4)}function X(e){if(!(!e||typeof e=="function"))return e.canJumpTo}function re(e){return typeof e=="function"?e:e.hook}var Fo=class{},Wo=class{},se=class extends we{constructor(e){super(e)}async invokeMiddleware(e,t){let o={};if(this.middleware.contextSchema&&F(this.middleware.contextSchema)){let u=de(this.middleware.contextSchema);if(u){let m={},c=t?.context||{};for(let h of Object.keys(u))h in c&&(m[h]=c[h]);o=te(this.middleware.contextSchema,m)}}let n={...e,messages:e.messages},r={context:o,store:t?.store,configurable:t?.configurable,writer:t?.writer,interrupt:t?.interrupt,signal:t?.signal},s=await this.runHook(n,Object.freeze(Object.assign(new Wo,{...r,context:Object.freeze(Object.assign(new Fo,o))})));if(!s)return{jumpTo:void 0};let a,l;if(this.name?.startsWith("BeforeAgentNode_")?(a=X(this.middleware.beforeAgent),l="beforeAgent.canJumpTo"):this.name?.startsWith("BeforeModelNode_")?(a=X(this.middleware.beforeModel),l="beforeModel.canJumpTo"):this.name?.startsWith("AfterAgentNode_")?(a=X(this.middleware.afterAgent),l="afterAgent.canJumpTo"):this.name?.startsWith("AfterModelNode_")&&(a=X(this.middleware.afterModel),l="afterModel.canJumpTo"),typeof s.jumpTo=="string"&&!a?.includes(s.jumpTo)){let u=a&&a.length>0?`must be one of: ${a?.join(", ")}.`:l?`no ${l} defined in middleware ${this.middleware.name}`:"";throw new Error(`Invalid jump target: ${s.jumpTo}, ${u}.`)}if(typeof s=="object"&&"type"in s){if(s.type==="terminate"){if(s.error)throw s.error;return{...n,...s.result||{},jumpTo:s.jumpTo}}throw new Error(`Invalid control action: ${JSON.stringify(s)}`)}return{...n,...s,jumpTo:s.jumpTo}}get nodeOptions(){return{input:Xt(this.middleware.stateSchema)}}};var ao=class extends se{middleware;lc_namespace=["langchain","agents","beforeAgentNodes"];constructor(e){super({name:`BeforeAgentNode_${e.name}`,func:async(t,o)=>this.invokeMiddleware(t,o)}),this.middleware=e}runHook(e,t){return re(this.middleware.beforeAgent)(e,t)}};var io=class extends se{middleware;lc_namespace=["langchain","agents","beforeModelNodes"];constructor(e){super({name:`BeforeModelNode_${e.name}`,func:async(t,o)=>this.invokeMiddleware(t,o)}),this.middleware=e}runHook(e,t){return re(this.middleware.beforeModel)(e,t)}};var lo=class extends se{middleware;lc_namespace=["langchain","agents","afterModelNodes"];constructor(e){super({name:`AfterModelNode_${e.name}`,func:async(t,o)=>this.invokeMiddleware(t,o)}),this.middleware=e}runHook(e,t){return re(this.middleware.afterModel)(e,t)}};var co=class extends se{middleware;lc_namespace=["langchain","agents","afterAgentNodes"];constructor(e){super({name:`AfterAgentNode_${e.name}`,func:async(t,o)=>this.invokeMiddleware(t,o)}),this.middleware=e}runHook(e,t){return re(this.middleware.afterAgent)(e,t)}};var uo=class mo{options;#e;#o="v2";#r;#t;constructor(t,o){if(this.options=t,this.#t=B(o??{},{metadata:{ls_integration:"langchain_create_agent"},configurable:{ls_agent_type:"root"}}),t.name&&(this.#t=B(this.#t,{metadata:{lc_agent_name:t.name}})),this.#o=t.version??this.#o,!t.model)throw new Error("`model` option is required to create an agent.");typeof t.model!="string"&&Be(t.model);let n=this.options.middleware?.filter(p=>p.tools).flatMap(p=>p.tools)??[],r=[...t.tools??[],...n],s=new Set(r.filter(ie).filter(p=>"returnDirect"in p&&p.returnDirect).map(p=>p.name)),a=!!this.options.middleware?.some(p=>p.wrapModelCall),{state:l,input:u,output:m}=Ft(this.options.responseFormat!==void 0||a,this.options.stateSchema,this.options.middleware),c=new Nt(l,{input:u,output:m,context:this.options.contextSchema}),h=[],d=[],f=[],g=[],x=[];this.#r=new oo({model:this.options.model,systemMessage:Jt(this.options.systemPrompt),includeAgentName:this.options.includeAgentName,name:this.options.name,responseFormat:this.options.responseFormat,middleware:this.options.middleware,toolClasses:r,shouldReturnDirect:s,signal:this.options.signal,wrapModelCallHookMiddleware:x});let y=new Set,w=this.options.middleware??[];for(let p=0;p<w.length;p++){let C,I,k,_,v=w[p];if(y.has(v.name))throw new Error(`Middleware ${v.name} is defined multiple times`);if(y.add(v.name),v.beforeAgent){C=new ao(v);let S=`${v.name}.before_agent`;h.push({index:p,name:S,allowed:X(v.beforeAgent)}),c.addNode(S,C,C.nodeOptions)}if(v.beforeModel){I=new io(v);let S=`${v.name}.before_model`;d.push({index:p,name:S,allowed:X(v.beforeModel)}),c.addNode(S,I,I.nodeOptions)}if(v.afterModel){k=new lo(v);let S=`${v.name}.after_model`;f.push({index:p,name:S,allowed:X(v.afterModel)}),c.addNode(S,k,k.nodeOptions)}if(v.afterAgent){_=new co(v);let S=`${v.name}.after_agent`;g.push({index:p,name:S,allowed:X(v.afterAgent)}),c.addNode(S,_,_.nodeOptions)}v.wrapModelCall&&x.push(v)}c.addNode(P,this.#r);let O=w.some(p=>p.wrapToolCall),A=r.filter(ie);if(A.length>0||O){let p=new so(A,{signal:this.options.signal,wrapToolCall:Kt(w)});c.addNode(D,p)}let N;h.length>0?N=h[0].name:d.length>0?N=d[0].name:N=P;let K=d.length>0?d[0].name:P,j=g.length>0?g[g.length-1].name:R;c.addEdge(ft,N);let b=A.length>0||O;for(let p=0;p<h.length;p++){let C=h[p],I=C.name,k=p===h.length-1?K:h[p+1].name;if(C.allowed&&C.allowed.length>0){let _=C.allowed.map(S=>V(S)).filter(S=>S!=="tools"||b),v=Array.from(new Set([k,..._.map(S=>S===R?j:S)]));c.addConditionalEdges(I,this.#c(A,k,j,b),v)}else c.addEdge(I,k)}for(let p=0;p<d.length;p++){let C=d[p],I=C.name,k=p===d.length-1?P:d[p+1].name;if(C.allowed&&C.allowed.length>0){let _=C.allowed.map(S=>V(S)).filter(S=>S!=="tools"||b),v=Array.from(new Set([k,..._]));c.addConditionalEdges(I,this.#d(A,k,b),v)}else c.addEdge(I,k)}let J=f.at(-1);if(f.length>0&&J)c.addEdge(P,J.name);else{let p=this.#s(A,!1,b).map(C=>C===R?j:C);p.length===1?c.addEdge(P,p[0]):c.addConditionalEdges(P,this.#i(j),p)}for(let p=f.length-1;p>0;p--){let C=f[p],I=C.name,k=f[p-1].name;if(C.allowed&&C.allowed.length>0){let _=C.allowed.map(S=>V(S)).filter(S=>S!=="tools"||b),v=Array.from(new Set([k,..._]));c.addConditionalEdges(I,this.#n(A,C.allowed,k,b),v)}else c.addEdge(I,k)}if(f.length>0){let p=f[0],C=p.name,I=this.#s(A,!0,b).filter(v=>v!=="tools"||b),k=!!(p.allowed&&p.allowed.length>0),_=I.map(v=>v===R?j:v);c.addConditionalEdges(C,this.#l(A,k,j,b),_)}for(let p=g.length-1;p>0;p--){let C=g[p],I=C.name,k=g[p-1].name;if(C.allowed&&C.allowed.length>0){let _=C.allowed.map(S=>V(S)).filter(S=>S!=="tools"||b),v=Array.from(new Set([k,..._]));c.addConditionalEdges(I,this.#n(A,C.allowed,k,b),v)}else c.addEdge(I,k)}if(g.length>0){let p=g[0],C=p.name;if(p.allowed&&p.allowed.length>0){let I=p.allowed.map(_=>V(_)).filter(_=>_!=="tools"||b),k=Array.from(new Set([R,...I]));c.addConditionalEdges(C,this.#n(A,p.allowed,R,b),k)}else c.addEdge(C,R)}if(b){let p=K;s.size>0?c.addConditionalEdges(D,this.#a(s,j,p),[p,j]):c.addEdge(D,p)}let le=(this.options.middleware??[]).flatMap(p=>p.streamTransformers??[]),Ee=[ae([]),he([]),...le,...this.options.streamTransformers??[]];this.#e=c.compile({checkpointer:this.options.checkpointer,store:this.options.store,name:this.options.name,description:this.options.description,transformers:Ee});let ye=Yt(this.#t);Object.keys(ye).length>0&&(this.#e=this.#e.withConfig(ye))}get graph(){return this.#e}get checkpointer(){return this.#e.checkpointer}set checkpointer(t){this.#e.checkpointer=t}get store(){return this.#e.store}set store(t){this.#e.store=t}withConfig(t){return new mo(this.options,B(this.#t,t))}#s(t,o=!1,n=t.length>0){let r=[];return n&&r.push(D),o&&r.push(P),r.push(R),r}#a(t,o,n){return r=>{let s=r.messages,a=s[s.length-1];return M.isInstance(a)&&a.name&&t.has(a.name)?this.options.responseFormat?n:o:n}}#i(t=R){return o=>{let n=o.messages.at(-1);if(!T.isInstance(n)||!n.tool_calls||n.tool_calls.length===0||n.tool_calls.every(s=>s.name.startsWith("extract-")))return t;if(this.#o==="v1")return D;let r=n.tool_calls.filter(s=>!s.name.startsWith("extract-"));return r.length===0?t:r.map(s=>new $(D,{...o,lg_tool_call:s}))}}#l(t,o,n,r=t.length>0){let s=!!this.options.responseFormat;return a=>{let l=a,u=l.messages,m=u.at(-1);if(T.isInstance(m)&&(!m.tool_calls||m.tool_calls.length===0))return n;if(o&&l.jumpTo){let w=V(l.jumpTo);return w===R?n:w==="tools"?r?new $(D,{...a,jumpTo:void 0}):n:new $(P,{...a,jumpTo:void 0})}let c=u.filter(M.isInstance),h=u.filter(T.isInstance).at(-1),d=h?.tool_calls?.filter(w=>!c.some(O=>O.tool_call_id===w.id));if(d&&d.length>0)return this.#o==="v1"?D:d.map(w=>new $(D,{...a,lg_tool_call:w}));let f=h?.tool_calls?.some(w=>w.name.startsWith("extract-"));if(d&&d.length===0&&!f&&s)return P;if(!T.isInstance(m)||!m.tool_calls||m.tool_calls.length===0)return n;let g=m.tool_calls.every(w=>w.name.startsWith("extract-")),x=m.tool_calls.some(w=>!w.name.startsWith("extract-"));if(g||!x)return n;if(this.#o==="v1")return D;let y=m.tool_calls.filter(w=>!w.name.startsWith("extract-"));return y.length===0?n:y.map(w=>new $(D,{...a,lg_tool_call:w}))}}#n(t,o,n,r=t.length>0){let s=new Set(o.map(a=>V(a)));return a=>{let l=a;if(l.jumpTo){let u=V(l.jumpTo);if(u===R&&s.has(R))return R;if(u==="tools"&&s.has("tools"))return r?new $(D,{...a,jumpTo:void 0}):R;if(u==="model_request"&&s.has("model_request"))return new $(P,{...a,jumpTo:void 0})}return n}}#c(t,o,n,r=t.length>0){return s=>{let a=s;if(!a.jumpTo)return o;let l=V(a.jumpTo);return l===R?n:l==="tools"?r?new $(D,{...s,jumpTo:void 0}):n:new $(P,{...s,jumpTo:void 0})}}#d(t,o,n=t.length>0){return r=>{let s=r;if(!s.jumpTo)return o;let a=V(s.jumpTo);return a===R?R:a==="tools"?n?new $(D,{...r,jumpTo:void 0}):R:new $(P,{...r,jumpTo:void 0})}}async#u(t,o){if(!this.options.middleware||this.options.middleware.length===0||t instanceof L||!t)return t;let n=await Zt(this.options.middleware,t),r={...(await this.#e.getState(o).catch(()=>({values:{}}))).values,...t};if(!r)return r;for(let[s,a]of Object.entries(n))s in r||(r[s]=a);return r}async invoke(t,o){let n=B(this.#t,o),r=await this.#u(t,n);return this.#e.invoke(r,n)}async stream(t,o){let n=B(this.#t,o),r=await this.#u(t,n);return this.#e.stream(r,n)}streamEvents(t,o,n){if(o?.version!=="v3"||n!=null){let r=B(this.#t,o),s=o?.version==="v1"||o?.version==="v2"?o.version:"v2";return this.#e.streamEvents(t,{...r,version:s},n)}return(async()=>{let{transformers:r,version:s,...a}=o??{},l=B(this.#t,a),u=await this.#u(t,l);return await this.#e.streamEvents(u,{...l,version:"v3",transformers:r})})()}async drawMermaidPng(t){let o=await(await(await this.#e.getGraphAsync()).drawMermaidPng(t)).arrayBuffer();return new Uint8Array(o)}async drawMermaid(t){return(await this.#e.getGraphAsync()).drawMermaid(t)}getGraphAsync(t){return this.#e.getGraphAsync(t)}getState(t,o){return this.#e.getState(t,o)}getStateHistory(t,o){return this.#e.getStateHistory(t,o)}getSubgraphs(t,o){return this.#e.getSubgraphs(t,o)}getSubgraphsAsync(t,o){return this.#e.getSubgraphsAsync(t,o)}updateState(t,o,n){return this.#e.updateState(t,o,n)}get builder(){return this.#e.builder}};function Vo(e){return new uo(e)}var Yo=i.function().args(i.custom()).returns(i.union([i.boolean(),i.promise(i.boolean())])),Zo=i.function().args(i.custom(),i.custom(),i.custom()).returns(i.union([i.string(),i.promise(i.string())])),Xo=["approve","edit","reject"],Qo=i.enum(Xo),qo=i.object({allowedDecisions:i.array(Qo),description:i.union([i.string(),Zo]).optional(),argsSchema:i.record(i.any()).optional(),when:Yo.optional()}),qa=i.object({interruptOn:i.record(i.union([i.boolean(),qo])).optional(),descriptionPrefix:i.string().default("Tool execution requires approval")});var We="nostream",He=i.object({maxRetries:i.number().min(0).default(2),retryOn:i.union([i.function().args(i.instanceof(Error)).returns(i.boolean()),i.array(i.custom())]).default(()=>e=>gt(e)??!0),backoffFactor:i.number().min(0).default(2),initialDelayMs:i.number().min(0).default(1e3),maxDelayMs:i.number().min(0).default(6e4),jitter:i.boolean().default(!0)});var Ge=`<role>
29
+ Context Extraction Assistant
30
+ </role>
31
+
32
+ <primary_objective>
33
+ Your sole objective in this task is to extract the highest quality/most relevant context from the conversation history below.
34
+ </primary_objective>
35
+
36
+ <objective_information>
37
+ You're nearing the total number of input tokens you can accept, so you must extract the highest quality/most relevant pieces of information from your conversation history.
38
+ This context will then overwrite the conversation history presented below. Because of this, ensure the context you extract is only the most important information to your overall goal.
39
+ </objective_information>
40
+
41
+ <instructions>
42
+ The conversation history below will be replaced with the context you extract in this step. Because of this, you must do your very best to extract and record all of the most important context from the conversation history.
43
+ You want to ensure that you don't repeat any actions you've already completed, so the context you extract from the conversation history should be focused on the most important information to your overall goal.
44
+ </instructions>
45
+
46
+ The user will message you with the full message history you'll be extracting context from, to then replace. Carefully read over it all, and think deeply about what information is most important to your overall goal that should be saved:
47
+
48
+ With all of this in mind, please carefully read over the entire conversation history, and extract the most important and relevant context to replace it so that you can free up space in the conversation history.
49
+ Respond ONLY with the extracted context. Do not include any additional information, or text before or after the extracted context.
50
+
51
+ <messages>
52
+ Messages to summarize:
53
+ {messages}
54
+ </messages>`,en="Here is a summary of the conversation to date:",Je=20,tn=4e3,fo=5,on=i.function().args(i.array(i.custom())).returns(i.union([i.number(),i.promise(i.number())])),ke=i.object({fraction:i.number().gt(0,"Fraction must be greater than 0").max(1,"Fraction must be less than or equal to 1").optional(),tokens:i.number().positive("Tokens must be greater than 0").optional(),messages:i.number().int("Messages must be an integer").positive("Messages must be greater than 0").optional()}).refine(e=>[e.fraction,e.tokens,e.messages].filter(t=>t!==void 0).length>=1,{message:"At least one of fraction, tokens, or messages must be provided"}),mt=i.object({fraction:i.number().min(0,"Messages must be non-negative").max(1,"Fraction must be less than or equal to 1").optional(),tokens:i.number().min(0,"Tokens must be greater than or equal to 0").optional(),messages:i.number().int("Messages must be an integer").min(0,"Messages must be non-negative").optional()}).refine(e=>[e.fraction,e.tokens,e.messages].filter(t=>t!==void 0).length===1,{message:"Exactly one of fraction, tokens, or messages must be provided"}),po=i.object({model:i.custom(),trigger:i.union([ke,i.array(ke)]).optional(),keep:mt.optional(),tokenCounter:on.optional(),summaryPrompt:i.string().default(Ge),trimTokensToSummarize:i.number().optional(),summaryPrefix:i.string().optional(),maxTokensBeforeSummary:i.number().optional(),messagesToKeep:i.number().optional()});function Ve(e){if("profile"in e&&typeof e.profile=="object"&&e.profile&&"maxInputTokens"in e.profile&&(typeof e.profile.maxInputTokens=="number"||e.profile.maxInputTokens==null))return e.profile.maxInputTokens??void 0;if("model"in e&&typeof e.model=="string")return nt(e.model);if("modelName"in e&&typeof e.modelName=="string")return nt(e.modelName)}function go(e){let{data:t,error:o}=Ct(po,e);if(o)throw new Error(`Invalid summarization middleware options: ${U.prettifyError(o)}`);return E({name:"SummarizationMiddleware",contextSchema:po.extend({model:i.custom().optional()}),beforeModel:async(n,r)=>{let s=t.trigger,a=t.keep;t.maxTokensBeforeSummary!==void 0&&(console.warn("maxTokensBeforeSummary is deprecated. Use `trigger: { tokens: value }` instead."),s===void 0&&(s={tokens:t.maxTokensBeforeSummary})),t.messagesToKeep!==void 0&&(console.warn("messagesToKeep is deprecated. Use `keep: { messages: value }` instead."),(!a||a&&"messages"in a&&a.messages===Je)&&(a={messages:t.messagesToKeep}));let l=r.context?.trigger!==void 0?r.context.trigger:s,u=r.context?.keep!==void 0?r.context.keep:a??{messages:Je},m=mt.parse(u),c=[];l===void 0?c=[]:Array.isArray(l)?c=l.map(J=>ke.parse(J)):c=[ke.parse(l)];let h=c.some(J=>"fraction"in J)||"fraction"in m,d=typeof t.model=="string"?await ee(t.model):t.model;if(h&&!Ve(d))throw new Error("Model profile information is required to use fractional token limits. Use absolute token counts instead.");let f=r.context?.summaryPrompt===Ge?t.summaryPrompt??Ge:r.context?.summaryPrompt??t.summaryPrompt??Ge,g=r.context.summaryPrefix??t.summaryPrefix??en,x=r.context?.trimTokensToSummarize!==void 0?r.context.trimTokensToSummarize:t.trimTokensToSummarize??tn;nn(n.messages);let y=r.context?.tokenCounter!==void 0?r.context.tokenCounter:t.tokenCounter??Se,w=await y(n.messages);if(!await an(n.messages,w,c,d))return;let{systemPrompt:O,conversationMessages:A}=rn(n.messages),N=await ln(A,m,y,d);if(N<=0)return;let{messagesToSummarize:K,preservedMessages:j}=sn(O,A,N),b=new Q({content:`${g}
55
+
56
+ ${await un(K,d,f,y,x,r)}`,id:A[0].id,additional_kwargs:{lc_source:"summarization"}});return{messages:[new Qe({id:Ot}),b,...j]}}})}function nn(e){for(let t of e)t.id||(t.id=ht())}function rn(e){return e.length>0&&z.isInstance(e[0])?{systemPrompt:e[0],conversationMessages:e.slice(1)}:{conversationMessages:e}}function sn(e,t,o){let n=t.slice(0,o),r=t.slice(o);return e&&n.unshift(e),{messagesToSummarize:n,preservedMessages:r}}async function an(e,t,o,n){if(o.length===0)return!1;for(let r of o){let s=!0,a=!1;if(r.messages!==void 0&&(a=!0,e.length<r.messages&&(s=!1)),r.tokens!==void 0&&(a=!0,t<r.tokens&&(s=!1)),r.fraction!==void 0){a=!0;let l=Ve(n);typeof l=="number"?t<Math.floor(l*r.fraction)&&(s=!1):s=!1}if(a&&s)return!0}return!1}async function ln(e,t,o,n){if("tokens"in t||"fraction"in t){let r=await cn(e,t,o,n);return typeof r=="number"?r:ho(e,Je)}return ho(e,t.messages??Je)}async function cn(e,t,o,n){if(e.length===0)return 0;let r;if("fraction"in t&&t.fraction!==void 0){let c=Ve(n);if(typeof c!="number")return;r=Math.floor(c*t.fraction)}else if("tokens"in t&&t.tokens!==void 0)r=Math.floor(t.tokens);else return;if(r<=0&&(r=1),await o(e)<=r)return 0;let s=0,a=e.length,l=e.length,u=Math.floor(Math.log2(e.length))+1;for(let c=0;c<u&&!(s>=a);c++){let h=Math.floor((s+a)/2);await o(e.slice(h))<=r?(l=h,a=h):s=h+1}if(l===e.length&&(l=s),l>=e.length){if(e.length===1)return 0;l=e.length-1}let m=Mo(e,l);if(m<=l)return m;for(let c=l;c>=0;c--)if(wo(e,c))return c;return 0}function ho(e,t){if(e.length<=t)return 0;let o=e.length-t,n=Mo(e,o);if(n<=o)return n;for(let r=o;r>=0;r--)if(wo(e,r))return r;return 0}function wo(e,t){if(t>=e.length)return!0;if(t<e.length&&T.isInstance(e[t])&&ge(e[t]))return!1;let o=Math.max(0,t-fo),n=Math.min(e.length,t+fo);for(let r=o;r<n;r++){if(!ge(e[r]))continue;let s=yo(e[r]);if(dn(e,r,t,s))return!1}return!0}function yo(e){let t=new Set;if(e.tool_calls)for(let o of e.tool_calls){let n=typeof o=="object"&&"id"in o?o.id:null;n&&t.add(n)}return t}function Mo(e,t){if(t>=e.length||!M.isInstance(e[t]))return t;let o=new Set,n=t;for(;n<e.length&&M.isInstance(e[n]);){let r=e[n];r.tool_call_id&&o.add(r.tool_call_id),n++}for(let r=t-1;r>=0;r--){let s=e[r];if(T.isInstance(s)&&ge(s)){let a=yo(s);for(let l of o)if(a.has(l))return r}}return n}function dn(e,t,o,n){for(let r=t+1;r<e.length;r++){let s=e[r];if(M.isInstance(s)&&n.has(s.tool_call_id)&&t<o!=r<o)return!0}return!1}async function un(e,t,o,n,r,s){if(!e.length)return"No previous conversation history.";let a=await mn(e,n,r);if(!a.length)return"Previous conversation was too long to summarize.";let l=yt(a);try{let u=o.replace("{messages}",l),m=B(Ae(s)??{},{metadata:{lc_source:"summarization"},tags:[We]}),c=(await t.invoke(u,m)).content;return typeof c=="string"?c.trim():Array.isArray(c)?c.map(h=>typeof h=="string"?h:typeof h=="object"&&h!==null&&"text"in h?h.text:"").join("").trim():"Error generating summary: Invalid response format"}catch(u){return`Error generating summary: ${u}`}}async function mn(e,t,o){if(o===void 0)return e;try{return await ot(e,{maxTokens:o,tokenCounter:async n=>t(n),strategy:"last",allowPartial:!0,includeSystem:!0})}catch{return e.slice(-15)}}var Ei=i.object({model:i.string().or(i.instanceof(kt)).optional(),systemPrompt:i.string().optional(),maxTools:i.number().optional(),alwaysInclude:i.array(i.string()).optional()});var ji=i.object({applyToInput:i.boolean().optional(),applyToOutput:i.boolean().optional(),applyToToolResults:i.boolean().optional()});var Ui=i.object({rules:i.record(i.string(),i.instanceof(RegExp).describe("Regular expression pattern to match PII")).optional()});var fn=["continue","error","end"],pn="continue";var hn=i.enum(fn).default(pn);i.object({toolName:i.string().optional(),threadLimit:i.number().optional(),runLimit:i.number().optional(),exitBehavior:hn});var Zi=i.object({threadToolCallCount:i.record(i.string(),i.number()).default({}),runToolCallCount:i.record(i.string(),i.number()).default({})});var gn=i.enum(["pending","in_progress","completed"]).describe("Status of the todo"),wn=i.object({content:i.string().describe("Content of the todo item"),status:gn}),rl=i.object({todos:i.array(wn).default([])});var yn="end",Mn=i.object({threadLimit:i.number().optional(),runLimit:i.number().optional(),exitBehavior:i.enum(["error","end"]).optional()}),Tn=i.object({threadModelCallCount:i.number().default(0),runModelCallCount:i.number().default(0)}),To=class extends Error{constructor({threadLimit:e,runLimit:t,threadCount:o,runCount:n}){let r=[];typeof e=="number"&&typeof o=="number"&&r.push(`thread level call limit reached with ${o} model calls`),typeof t=="number"&&typeof n=="number"&&r.push(`run level call limit reached with ${n} model calls`),super(`Model call limits exceeded${r.length>0?`: ${r.join(", ")}`:""}`),this.name="ModelCallLimitMiddlewareError"}};function bo(e){return E({name:"ModelCallLimitMiddleware",contextSchema:Mn,stateSchema:Tn,beforeModel:{canJumpTo:["end"],hook:(t,o)=>{let n=o.context.exitBehavior??e?.exitBehavior??yn;n==="throw"&&(console.warn("The 'throw' exit behavior is deprecated. Please use 'error' instead."),n="error");let r=o.context.threadLimit??e?.threadLimit,s=o.context.runLimit??e?.runLimit,a=t.threadModelCallCount,l=t.runModelCallCount;if(typeof r=="number"&&r<=a){let u=new To({threadLimit:r,threadCount:a});if(n==="end")return{jumpTo:"end",messages:[new T(u.message)]};throw u}if(typeof s=="number"&&s<=l){let u=new To({runLimit:s,runCount:l});if(n==="end")return{jumpTo:"end",messages:[new T(u.message)]};throw u}return t}},afterModel:t=>({runModelCallCount:t.runModelCallCount+1,threadModelCallCount:t.threadModelCallCount+1}),afterAgent:()=>({runModelCallCount:0})})}var bl=i.object({onFailure:i.union([i.literal("error"),i.literal("continue"),i.function().args(i.instanceof(Error)).returns(i.string())]).default("continue")}).merge(He);var Al=i.object({tools:i.array(i.union([i.custom(),i.custom(),i.string()])).optional(),onFailure:i.union([i.literal("error"),i.literal("continue"),i.literal("raise"),i.literal("return_message"),i.function().args(i.instanceof(Error)).returns(i.string())]).default("continue")}).merge(He);var Zl=i.object({enableCaching:i.boolean().optional(),ttl:i.enum(["5m","1h"]).optional(),minMessagesToCache:i.number().optional(),unsupportedModelBehavior:i.enum(["ignore","warn","raise"]).optional()});var ec=i.object({enableCaching:i.boolean().optional(),ttl:i.enum(["5m","1h"]).optional(),minMessagesToCache:i.number().optional(),unsupportedModelBehavior:i.enum(["ignore","warn","raise"]).optional()});export{E as a,Vo as b,go as c,bo as d};
@@ -0,0 +1,2 @@
1
+ /* COPYRIGHT Esri - https://js.arcgis.com/5.2/LICENSE.txt */
2
+ import{Dd as o}from"./MWYBF3F3.js";var r=o;export{r as a};
@@ -0,0 +1,2 @@
1
+ /* COPYRIGHT Esri - https://js.arcgis.com/5.2/LICENSE.txt */
2
+ import s from"./C5ZL5Z52.js";import q from"./SZ2QSSB3.js";import p from"./OYSPNIJI.js";import{a as o,c as a}from"./V6HOUZPZ.js";import n from"./KITIP6J2.js";import"./Z5W4V7RC.js";import m from"./RHYNE5OE.js";import l from"./KWD2ECTM.js";import k from"./U2D53TAX.js";import j from"./OAKRPM7D.js";import h from"./V52XWEGV.js";import g from"./CCC6LBMY.js";import"./34O57OGV.js";import"./7SRLZQVC.js";import"./FDOMMK2M.js";import f from"./6HF36IKA.js";import"./Y7XD7ZRD.js";import"./VLLZ2FFU.js";import e from"./5ZFUGNRN.js";import"./LLUGJKAQ.js";import"./WKTQVBFJ.js";import"./K2R6XVK3.js";import"./3UEKINYC.js";import"./RLEHNAIA.js";import d from"./AT4XVTJR.js";import"./7M6VKBTK.js";import"./5WYRJMBW.js";import"./YEZ3AMNX.js";import c from"./JKIESH74.js";import b from"./QNNGPA3Q.js";import"./ONQ6JSBJ.js";import{v as i,z as r}from"./X3COUAXY.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(([,,,,,,,,,,,,,,,,,,,,,s])=>{var t=class extends i{constructor(){super(...arguments),this.agent=s}static{this.properties={referenceElement:1}}#t;#i;getContext(){if(!this.#t)throw new Error("arcgis-assistant-data-exploration-agent requires a mapView");return{mapView:this.#t}}load(){this.#t=o(this,"arcgis-assistant-data-exploration-agent"),this.#i=a(this)}disconnectedCallback(){this.#i?.unregister(this.agent.id),super.disconnectedCallback()}};r("arcgis-assistant-data-exploration-agent",t);return t},"identity/IdentityManager","portal/Portal","request","config","core/reactiveUtils","layers/FeatureLayer","rest/knowledgeGraphService",b,c,d,e,f,g,h,j,k,l,m,n,p,q,s)
@@ -0,0 +1,2 @@
1
+ /* COPYRIGHT Esri - https://js.arcgis.com/5.2/LICENSE.txt */
2
+ import{a as i}from"./ONQ6JSBJ.js";import{Dc as n}from"./AI6DYOKR.js";import{Dd as r}from"./MWYBF3F3.js";async function s(a,t){await t.when();let e=t.map?.allLayers.find(l=>l.id===a);if(!e)return console.warn(`[goToLayer] No matching FeatureLayer found for: ${a}`),{text:`Could not find layer for: ${a}`};let o;return(e.type==="link-chart"||e.type==="knowledge-graph-sublayer")&&t.map?.activeLinkChartLayer?o=t.map.diagramNodesExtent:o=e.fullExtent,o?(await t.goTo(o),e.visible=!0,{text:`Successfully zoomed to: ${e.title??""}`}):{text:"Layer has no defined extent. Cannot zoom to layer."}}async function m({layerId:a},t){let{mapView:e}=i(t,["mapView"]);return await s(a,e)}var c=r.object({layerId:r.string().describe("The id of the layer to navigate to")}),p=n(m,{name:"goToLayer",description:"Zooms the map view to the full extent of the top matching layer.",schema:c});export{p as a};
@@ -0,0 +1,2 @@
1
+ /* COPYRIGHT Esri - https://js.arcgis.com/5.2/LICENSE.txt */
2
+ import{a as r}from"./434TAA3J.js";import{a as m,b}from"./V6F3HEK7.js";import"./RLEHNAIA.js";import{g as l,h as e,v as c,x as d,z as g}from"./X3COUAXY.js";import"./R74ZHFA6.js";import"./UZLQALHY.js";var p=l`:host{display:block;container-type:inline-size}.container{display:flex;flex-direction:column;align-items:flex-start;gap:var(--calcite-spacing-sm);width:100%;text-align:left}.icon{padding:var(--calcite-spacing-sm);border-radius:var(--calcite-spacing-xl);background:var(--calcite-color-brand);color:var(--calcite-color-foreground-1)}.content-container{display:flex;flex:1;flex-direction:column;width:100%;min-width:0;gap:var(--calcite-spacing-md)}.content{display:flex;flex-direction:column;min-width:0;gap:var(--calcite-spacing-sm)}.blocks{display:flex;flex-direction:column;gap:var(--calcite-spacing-sm)}.block-pending{display:flex;justify-content:center;align-items:center;padding:var(--calcite-spacing-sm);background:linear-gradient(90deg,color-mix(in srgb,var(--calcite-color-foreground-2) 65%,transparent),color-mix(in srgb,var(--calcite-color-foreground-3) 85%,transparent),color-mix(in srgb,var(--calcite-color-foreground-2) 65%,transparent));background-size:200% 100%;animation:assistant-message-loading-shimmer 2s ease-in-out infinite;border-radius:var(--calcite-border-radius);min-height:100px}.message-error{font-style:italic}@container (min-width: 480px){.container{max-width:80%}}@keyframes assistant-message-loading-shimmer{0%{background-position:-150% 0}to{background-position:150% 0}}@media(prefers-reduced-motion){.block-pending{animation:none}}`;function u({message:a}){let s=new Map;return a&&a.blocks?.forEach((i,t)=>{if(!i.isPending){let n=r(a.id,t);s.set(n,{data:{block:i,index:t,message:a},name:"block",slotName:n})}}),s}var o=class extends c{constructor(){super(...arguments),this._messages=b({blocking:!0}),this.arcgisSlottableRequest=m(this,["message"],u),this.feedbackEnabled=!1,this.logEnabled=!1,this.copyEnabled=!1,this.readAloudEnabled=!1,this.footerDisabled=!1,this.assistantAvatarEnabled=!1}static{this.properties={_isStreaming:16,feedbackEnabled:5,logEnabled:5,copyEnabled:5,readAloudEnabled:5,footerDisabled:5,message:0,assistantAvatarEnabled:5}}static{this.styles=p}get _isStreaming(){return!!this.message?.isStreaming}_renderContent(){let s=this.message,i=s?.id;if(i)return e`<div class="content"><arcgis-assistant-interrupt-preview .interrupts=${this.message?.interrupts}></arcgis-assistant-interrupt-preview>${s.blocks?.length?e`<div class="blocks">${s.blocks.map((t,n)=>t.isPending&&t.type!=="text"?e`<div class="block-pending"></div>`:e`<slot name=${r(i,n)??d}></slot>`)}</div>`:null}</div>`}_renderFooter(){return e`<arcgis-assistant-message-footer .message=${this.message} .feedbackEnabled=${this.feedbackEnabled} .logEnabled=${this.logEnabled} .copyEnabled=${this.copyEnabled} .readAloudEnabled=${this.readAloudEnabled}></arcgis-assistant-message-footer>`}render(){return e`<div class="container">${this.assistantAvatarEnabled?e`<slot name=icon><calcite-icon icon=effects class="icon" scale=s></calcite-icon></slot>`:null}<div class="content-container"><slot name=content>${this._renderContent()}</slot>${this.message?.error?e`<div class="message-error">${this.message.error}</div>`:null}${this._isStreaming?e`<div class="streaming-indicator"><calcite-loader .label=${this._messages.loadingLabel} inline></calcite-loader></div>`:null}${!this.footerDisabled&&!this._isStreaming?e`<slot name=footer>${this._renderFooter()}</slot>`:null}</div></div>`}};g("arcgis-assistant-message",o);export{o as ArcgisAssistantMessage};
@@ -0,0 +1,6 @@
1
+ /* COPYRIGHT Esri - https://js.arcgis.com/5.2/LICENSE.txt */
2
+ import a from"./VNJMTA6O.js";import{c as C,e as N}from"./ZLWWWTH4.js";import"./7M6VKBTK.js";import"./EWLXNGKH.js";import"./AI6DYOKR.js";import"./MWYBF3F3.js";import"./UZLQALHY.js";export default $arcgis.t(([{property:B,subclass:D},{a:h,b:S,c:p,d:A}])=>{var G=Object.defineProperty,z=Object.getOwnPropertyDescriptor,P=(t,e,s,n)=>{for(var r=n>1?void 0:n?z(e,s):e,o=t.length-1,a;o>=0;o--)(a=t[o])&&(r=(n?a(e,s,r):a(r))||r);return n&&r&&G(e,s,r),r},x=class extends A{constructor(t){super(t)}getAgents(){return this.agents}generate(){let t=this.getAgents();this.validateAgents(t);for(let o of t)o.generate();let e=S(t.flatMap(o=>o.getSchemas()));for(let[o]of t.entries())e[_(o)]=void 0;let s=C(e),n=this.buildNodes(t),r=this.buildEdges(t);return{workspace:s,createGraph:()=>N(n,r,s,{entryNode:this.getEntryNode(t)})}}getEntryNode(t){return y}isTerminalAgent(t,e){return!1}buildNodes(t){let e={};for(let[s,n]of t.entries()){let r=_(s),o=p(n,s);e[o]=async(a,u)=>{let l=await n.run(F(a,n),u),i={},m=i;return m[r]=l,i}}return e[y]=()=>({}),e[k]=s=>R(s,t),e}buildEdges(t){return[...t.map((e,s)=>({from:y,to:p(e,s)})),...t.map((e,s)=>({from:p(e,s),to:k}))]}};P([B()],x.prototype,"agents",2);x=P([D("ParallelWorkflow")],x);var y="__parallel_fanOut",k="__parallel_join";function _(t){return`__parallel_update_${t}`}function W(t,e){return Object.fromEntries(e.filter(s=>Object.hasOwn(t,s)).map(s=>[s,t[s]]))}function F(t,e){let s=e.inputSchema;return s?{...W(t,h(s)),agentExecutionContext:t.agentExecutionContext,outputMessage:t.outputMessage,status:void 0,summary:""}:{...t,status:void 0,summary:""}}function I(t,e){return t.outputSchema?W(e,h(t.outputSchema)):{}}function K(t,e){let s=t.agentExecutionContext?.messages??[],n=e.agentExecutionContext?.messages??[];return n.length>s.length?n.slice(s.length):void 0}function R(t,e){let s=[],n=[],r=[],o={},a={},u=new Set;for(let[m,J]of e.entries()){let E=_(m),d=t[E];if(a[E]=void 0,!d||typeof d!="object")continue;let c=d,b=c.outputMessage,O=K(t,c),v=c.summary,$=I(J,c),w=b.trim();typeof b=="string"&&w&&s.push(w);let j=v.trim();typeof v=="string"&&j&&n.push(j),Array.isArray(O)&&r.push(...O),c.status&&u.add(c.status);for(let[f,g]of Object.entries($))if(!(g===void 0||f.startsWith("__parallel_update_"))&&!M(t[f],g)){if(!Object.hasOwn(o,f)){o[f]=g;continue}if(!M(o[f],g))throw new Error(`ParallelWorkflow detected conflicting updates for state key "${f}".`)}}let l={...a,...o},i=l;return r.length>0&&(i.agentExecutionContext={...t.agentExecutionContext,messages:[...t.agentExecutionContext.messages,...r]}),s.length&&(i.outputMessage=s.join(`
3
+
4
+ `)),n.length&&(i.summary=n.join(`
5
+
6
+ `)),u.size&&(i.status=u.has("failed")?"failed":u.has("success")?"success":void 0),l}function M(t,e){return t===e?!0:t&&e?JSON.stringify(t)===JSON.stringify(e):!1}return x},"core/accessorSupport/decorators",a)
@@ -0,0 +1,2 @@
1
+ /* COPYRIGHT Esri - https://js.arcgis.com/5.2/LICENSE.txt */
2
+ import{a as s,b as c}from"./4KOV2NEI.js";import"./5FL5BTTX.js";import{g as e,h as t,v as i,z as r}from"./X3COUAXY.js";import"./R74ZHFA6.js";import"./UZLQALHY.js";var n=e`:host{display:block;min-width:0}.container{display:flex;align-items:center;gap:var(--calcite-spacing-md);background:color-mix(in srgb,var(--calcite-color-brand) 15%,var(--calcite-color-foreground-1));color:var(--calcite-color-text-1);padding:var(--calcite-spacing-md);border-radius:var(--calcite-border-radius);width:fit-content;max-width:100%;min-width:0;margin-left:auto;justify-content:flex-end}.container>div:first-child{min-width:0}.avatar{display:flex;align-items:center;justify-content:center}.content{min-width:0;overflow-wrap:anywhere;>*{margin:0}>*+*{margin-block-start:var(--calcite-spacing-sm)}:is(ol,ul){padding-inline-start:var(--calcite-spacing-lg)}>calcite-table{display:block;max-width:100%}pre{background-color:var(--calcite-color-foreground-1);padding:var(--calcite-spacing-sm);border-radius:var(--calcite-border-radius);color:var(--calcite-color-text-1);direction:ltr;max-width:100%;overflow:auto}pre code{display:block;white-space:pre;font-family:var(--calcite-code-family)}}@container (min-width: 480px){.container{max-width:80%}}`,a=class extends i{constructor(){super(...arguments),this.userAvatarEnabled=!1}static{this.properties={content:1,user:1,message:0,userAvatarEnabled:5}}static{this.styles=n}_getContent(){return this.message?.role==="user"?this.message.content:this.content}render(){return t`<div class="container"><div><slot name=content><div class="content">${s(c(this._getContent()))}</div></slot></div>${this.userAvatarEnabled?t`<slot name=icon><div class="avatar"><calcite-avatar .fullName=${this.user} scale=s></calcite-avatar></div></slot>`:null}</div>`}};r("arcgis-assistant-user-message",a);export{a as ArcgisAssistantUserMessage};