@arcgis/ai-components 5.2.0-next.11 → 5.2.0-next.110

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 (371) hide show
  1. package/LICENSE.md +4 -2
  2. package/README.md +2 -2
  3. package/dist/agent-utils/BaseAgent.js +1 -1
  4. package/dist/agent-utils/FunctionAgent.js +1 -1
  5. package/dist/agent-utils/LLMAgent.d.ts +5 -2
  6. package/dist/agent-utils/LLMAgent.js +7 -4
  7. package/dist/agent-utils/WorkflowAgent.js +15 -16
  8. package/dist/agent-utils/index.d.ts +78 -0
  9. package/dist/agent-utils/index.js +117 -98
  10. package/dist/agent-utils/middlewares/humanInTheLoop.js +1 -1
  11. package/dist/agent-utils/middlewares/middleware.js +1 -1
  12. package/dist/agent-utils/middlewares/trace.d.ts +2 -0
  13. package/dist/agent-utils/middlewares/trace.js +1 -1
  14. package/dist/agent-utils/middlewares/types.js +1 -1
  15. package/dist/agent-utils/tools/FunctionTool.js +1 -1
  16. package/dist/agent-utils/types.d.ts +13 -13
  17. package/dist/agent-utils/workflows/ConditionalWorkflow.js +1 -1
  18. package/dist/agent-utils/workflows/LoopWorkflow.js +1 -1
  19. package/dist/agent-utils/workflows/ParallelWorkflow.js +1 -1
  20. package/dist/agent-utils/workflows/RouterWorkflow.js +1 -1
  21. package/dist/agent-utils/workflows/SequentialWorkflow.js +1 -1
  22. package/dist/agent-utils/workflows/SwitchWorkflow.js +1 -1
  23. package/dist/agentic-workflow/AgenticWorkflowRuntime.d.ts +24 -0
  24. package/dist/agentic-workflow/Edge.d.ts +16 -0
  25. package/dist/agentic-workflow/WebAgent.d.ts +39 -0
  26. package/dist/agentic-workflow/jsonTypes.d.ts +189 -0
  27. package/dist/agentic-workflow/nodes/AgentNode.d.ts +28 -0
  28. package/dist/agentic-workflow/nodes/BaseNode.d.ts +35 -0
  29. package/dist/agentic-workflow/nodes/EndMessageNode.d.ts +25 -0
  30. package/dist/agentic-workflow/nodes/StartNode.d.ts +21 -0
  31. package/dist/agentic-workflow/nodes/tools/ArcgisTool.d.ts +21 -0
  32. package/dist/agentic-workflow/types.d.ts +29 -0
  33. package/dist/agents/runtime/skill/createSkillAgent.d.ts +31 -0
  34. package/dist/agents/runtime/skill/createSkillAgent.js +260 -0
  35. package/dist/agents/runtime/skill/loadAgentSkills.d.ts +16 -0
  36. package/dist/agents/runtime/skill/types.d.ts +28 -0
  37. package/dist/agents/runtime/skill/types.js +2 -0
  38. package/dist/agents/tools/filter/clearFilters/adapter.d.ts +8 -0
  39. package/dist/agents/tools/filter/clearFilters/adapter.js +22 -0
  40. package/dist/agents/tools/filter/resetMap/adapter.d.ts +8 -0
  41. package/dist/agents/tools/filter/resetMap/adapter.js +22 -0
  42. package/dist/agents/tools/filter/setFeatureEffect/adapter.d.ts +8 -0
  43. package/dist/agents/tools/filter/setFeatureEffect/adapter.js +122 -0
  44. package/dist/agents/tools/help/listFields/adapter.d.ts +11 -0
  45. package/dist/agents/tools/help/listFields/adapter.js +30 -0
  46. package/dist/agents/tools/navigation/goToAddress/adapter.d.ts +10 -0
  47. package/dist/agents/tools/navigation/goToAddress/adapter.js +60 -0
  48. package/dist/agents/tools/navigation/goToBookmark/adapter.d.ts +8 -0
  49. package/dist/agents/tools/navigation/goToBookmark/adapter.js +30 -0
  50. package/dist/agents/tools/navigation/goToFeatures/adapter.d.ts +8 -0
  51. package/dist/agents/tools/navigation/goToFeatures/adapter.js +50 -0
  52. package/dist/agents/tools/navigation/goToFullExtent/adapter.d.ts +8 -0
  53. package/dist/agents/tools/navigation/goToFullExtent/adapter.js +27 -0
  54. package/dist/agents/tools/navigation/goToHomeExtent/adapter.d.ts +8 -0
  55. package/dist/agents/tools/navigation/goToHomeExtent/adapter.js +24 -0
  56. package/dist/agents/tools/navigation/goToLayer/adapter.d.ts +8 -0
  57. package/dist/agents/tools/navigation/goToLayer/adapter.js +26 -0
  58. package/dist/agents/tools/navigation/goToScale/adapter.d.ts +8 -0
  59. package/dist/agents/tools/navigation/goToScale/adapter.js +21 -0
  60. package/dist/agents/tools/navigation/goToViewpoint/adapter.d.ts +8 -0
  61. package/dist/agents/tools/navigation/goToViewpoint/adapter.js +42 -0
  62. package/dist/agents/tools/navigation/goToZoom/adapter.d.ts +8 -0
  63. package/dist/agents/tools/navigation/goToZoom/adapter.js +21 -0
  64. package/dist/agents/tools/query/getAttribute/adapter.d.ts +8 -0
  65. package/dist/agents/tools/query/getAttribute/adapter.js +40 -0
  66. package/dist/agents/tools/query/getStatistics/adapter.d.ts +8 -0
  67. package/dist/agents/tools/query/getStatistics/adapter.js +158 -0
  68. package/dist/agents/tools/query/getTopFeatures/adapter.d.ts +8 -0
  69. package/dist/agents/tools/query/getTopFeatures/adapter.js +145 -0
  70. package/dist/agents/tools/query/queryFeatures/adapter.d.ts +8 -0
  71. package/dist/agents/tools/query/queryFeatures/adapter.js +131 -0
  72. package/dist/agents/tools/search/findRelevantFields/adapter.d.ts +8 -0
  73. package/dist/agents/tools/search/findRelevantFields/adapter.js +57 -0
  74. package/dist/agents/tools/search/findRelevantLayers/adapter.d.ts +8 -0
  75. package/dist/agents/tools/search/findRelevantLayers/adapter.js +38 -0
  76. package/dist/agents/tools/shared/resolveToolArtifact.d.ts +22 -0
  77. package/dist/agents/tools/shared/resolveToolArtifact.js +20 -0
  78. package/dist/agents/tools/shared/types.d.ts +22 -0
  79. package/dist/agents/tools/shared/types.js +6 -0
  80. package/dist/cdn/24EIZVUM.js +2 -0
  81. package/dist/cdn/25MBI4PD.js +2 -0
  82. package/dist/cdn/275FFTBE.js +2 -0
  83. package/dist/cdn/27CK3JHY.js +2 -0
  84. package/dist/cdn/2F4TPWZQ.js +2 -0
  85. package/dist/cdn/2LVYAXHG.js +44 -0
  86. package/dist/cdn/2UJPYWWZ.js +3 -0
  87. package/dist/cdn/2WXXSZP5.js +2 -0
  88. package/dist/cdn/{Q7TL5Q5N.js → 3KNLFIM3.js} +2 -2
  89. package/dist/cdn/3PPXAIRE.js +14 -0
  90. package/dist/cdn/45BDE3MG.js +2 -0
  91. package/dist/cdn/477I66FH.js +56 -0
  92. package/dist/cdn/4CFCV47G.js +2 -0
  93. package/dist/cdn/4IWDBEMN.js +34 -0
  94. package/dist/cdn/4OI4QEV7.js +6 -0
  95. package/dist/cdn/{DXVU45KM.js → 4VBOTWC3.js} +2 -2
  96. package/dist/cdn/4YOG5F3W.js +2 -0
  97. package/dist/cdn/53KIFJFA.js +4 -0
  98. package/dist/cdn/5X23DDDZ.js +2 -0
  99. package/dist/cdn/65LCK3GG.js +3 -0
  100. package/dist/cdn/6KWGSXIN.js +2 -0
  101. package/dist/cdn/7DOYUO7L.js +71 -0
  102. package/dist/cdn/{WAIFKDR3.js → 7UBTNDV6.js} +2 -2
  103. package/dist/cdn/7Y43R7QJ.js +2 -0
  104. package/dist/cdn/A6LBMS7A.js +2 -0
  105. package/dist/cdn/AP3KPOHN.js +2 -0
  106. package/dist/cdn/AUCKEB52.js +2 -0
  107. package/dist/cdn/B3HXSEBN.js +2 -0
  108. package/dist/cdn/BBEGLIZC.js +2 -0
  109. package/dist/cdn/BJMGT6GV.js +19 -0
  110. package/dist/cdn/BTOBEN7Q.js +2 -0
  111. package/dist/cdn/BTTCBEPW.js +2 -0
  112. package/dist/cdn/BVUCNXC5.js +2 -0
  113. package/dist/cdn/CAOMMQSY.js +66 -0
  114. package/dist/cdn/CKUUYQLO.js +2 -0
  115. package/dist/cdn/{ZEYIBYSF.js → CSE6BHOJ.js} +2 -2
  116. package/dist/cdn/CX2HJ67C.js +2 -0
  117. package/dist/cdn/EGRRZTF6.js +2 -0
  118. package/dist/cdn/EK3PM4L5.js +2 -0
  119. package/dist/cdn/EXMEB4X2.js +2 -0
  120. package/dist/cdn/EYGZJKVD.js +2 -0
  121. package/dist/cdn/{24QNMEFG.js → FDRAKF5D.js} +2 -2
  122. package/dist/cdn/FHBRXZLV.js +2 -0
  123. package/dist/cdn/{5CV7R5IS.js → FK2CVSXW.js} +6 -6
  124. package/dist/cdn/FLUI6GCU.js +2 -0
  125. package/dist/cdn/{ZTBA5PM7.js → FPH52WOH.js} +2 -2
  126. package/dist/cdn/FRYS2PZJ.js +2 -0
  127. package/dist/cdn/FSLQCZRN.js +2 -0
  128. package/dist/cdn/{LQ6R5YRN.js → FTTLFIBV.js} +2 -2
  129. package/dist/cdn/FV6FHLYW.js +2 -0
  130. package/dist/cdn/G24MNC7D.js +6 -0
  131. package/dist/cdn/{F6QHMKF5.js → GW3IVAAZ.js} +2 -2
  132. package/dist/cdn/HI3XKFHD.js +2 -0
  133. package/dist/cdn/HKIA5PWU.js +2 -0
  134. package/dist/cdn/{6ZW7Z36F.js → HMMYCSOK.js} +4 -4
  135. package/dist/cdn/HNTSDY3J.js +2 -0
  136. package/dist/cdn/HV7MVIQV.js +2 -0
  137. package/dist/cdn/I3SUE2TR.js +2 -0
  138. package/dist/cdn/I72ST4JR.js +134 -0
  139. package/dist/cdn/{T537PKP4.js → IHUWQOMK.js} +2 -2
  140. package/dist/cdn/JMXXRRKQ.js +22 -0
  141. package/dist/cdn/JUNMTIB3.js +2 -0
  142. package/dist/cdn/{6YMR4QSD.js → JYNHWJUZ.js} +2 -2
  143. package/dist/cdn/KAX4A7SF.js +2 -0
  144. package/dist/cdn/KBSXHSBX.js +2 -0
  145. package/dist/cdn/KKCLHXHG.js +2 -0
  146. package/dist/cdn/L2HLFWCV.js +72 -0
  147. package/dist/cdn/{7RCQFLPP.js → L3BTURBA.js} +2 -2
  148. package/dist/cdn/LBTGOMCT.js +2 -0
  149. package/dist/cdn/LIRT72WY.js +2 -0
  150. package/dist/cdn/LL324IL6.js +2 -0
  151. package/dist/cdn/LLY5A2E2.js +2 -0
  152. package/dist/cdn/LXIKAXUT.js +2 -0
  153. package/dist/cdn/M2U456J5.js +181 -0
  154. package/dist/cdn/M3KKORBG.js +2 -0
  155. package/dist/cdn/M5B6X46F.js +2 -0
  156. package/dist/cdn/{X2ZDYHCG.js → MZUDIQQH.js} +11 -6
  157. package/dist/cdn/NBDOPGSN.js +2 -0
  158. package/dist/cdn/NGR5NVZE.js +2 -0
  159. package/dist/cdn/{5ZZGKP7N.js → NNPA3NLK.js} +2 -2
  160. package/dist/cdn/NV7CL4S3.js +2 -0
  161. package/dist/cdn/{5W7S2RS4.js → OALQBAZR.js} +2 -2
  162. package/dist/cdn/OF3TAARW.js +2 -0
  163. package/dist/cdn/{AZGGTNA3.js → OXC2WP7W.js} +2 -2
  164. package/dist/cdn/PJPP6LOS.js +3 -0
  165. package/dist/cdn/PUZ6RAFQ.js +2 -0
  166. package/dist/cdn/QAX6UF4L.js +99 -0
  167. package/dist/cdn/{NE7E52YR.js → QTEPFTAU.js} +10 -4
  168. package/dist/cdn/ROS22KOA.js +2 -0
  169. package/dist/cdn/RSM7MEVT.js +9 -0
  170. package/dist/cdn/SBNNJ5WA.js +2 -0
  171. package/dist/cdn/SDX46GZY.js +2 -0
  172. package/dist/cdn/SI22EJLC.js +2 -0
  173. package/dist/cdn/SJMAKF4P.js +2 -0
  174. package/dist/cdn/SNG3WODY.js +2 -0
  175. package/dist/cdn/STOGCXJH.js +2 -0
  176. package/dist/cdn/SUC2MIGE.js +2 -0
  177. package/dist/cdn/SXYKNDOF.js +2 -0
  178. package/dist/cdn/SZ2L5556.js +2 -0
  179. package/dist/cdn/T6W6F4TF.js +2 -0
  180. package/dist/cdn/TB2GJALS.js +2 -0
  181. package/dist/cdn/TFAJNKBC.js +2 -0
  182. package/dist/cdn/TLPZELG3.js +2 -0
  183. package/dist/cdn/TXZQZR3I.js +2 -0
  184. package/dist/cdn/UAZPINUQ.js +2 -0
  185. package/dist/cdn/UGIHS7OA.js +2 -0
  186. package/dist/cdn/{FX7UOGHP.js → V266DJ5V.js} +2 -2
  187. package/dist/cdn/V4PJMCJZ.js +2 -0
  188. package/dist/cdn/{P7DG5T3Z.js → V52GSTOC.js} +2 -2
  189. package/dist/cdn/VGLBH473.js +2 -0
  190. package/dist/cdn/VK6CCPTG.js +2 -0
  191. package/dist/cdn/{ZS2TZ6BF.js → VLPELJUS.js} +2 -2
  192. package/dist/cdn/VT5EWFH7.js +2 -0
  193. package/dist/cdn/{7CYGX4F4.js → VXLKTQ36.js} +2 -2
  194. package/dist/cdn/W54XYT2A.js +2 -0
  195. package/dist/cdn/X42ACC66.js +5 -0
  196. package/dist/cdn/XNUWVZN7.js +2 -0
  197. package/dist/cdn/XOTPSCNF.js +2 -0
  198. package/dist/cdn/XRVGYRXL.js +14 -0
  199. package/dist/cdn/XV7RMYLR.js +2 -0
  200. package/dist/cdn/XVJFPZTW.js +2 -0
  201. package/dist/cdn/XZF7Y6B2.js +2 -0
  202. package/dist/cdn/{UPEEHMSY.js → Y4TYL2AL.js} +2 -2
  203. package/dist/cdn/Y4ZOB6UH.js +2 -0
  204. package/dist/cdn/Y6CV2NZR.js +2 -0
  205. package/dist/cdn/YIXASZUW.js +2 -0
  206. package/dist/cdn/YOW3YKWR.js +11 -0
  207. package/dist/cdn/{23EQTPO3.js → ZA7ZU2F7.js} +2 -2
  208. package/dist/cdn/ZJWR4W2S.js +208 -0
  209. package/dist/cdn/ZWIKFBOU.js +2 -0
  210. package/dist/cdn/ZY3JQCZQ.js +179 -0
  211. package/dist/cdn/agent-utils/index.js +2 -2
  212. package/dist/cdn/agent-utils/middlewares/humanInTheLoop.js +2 -2
  213. package/dist/cdn/agent-utils/middlewares/middleware.js +2 -2
  214. package/dist/cdn/agent-utils/middlewares/trace.js +2 -2
  215. package/dist/cdn/assets/assistant/t9n/messages.en.json +1 -1
  216. package/dist/cdn/assets/assistant-interrupt/t9n/messages.en.json +1 -1
  217. package/dist/cdn/assets/assistant-interrupt-preview/t9n/messages.en.json +1 -0
  218. package/dist/cdn/assets/assistant-message/t9n/messages.en.json +1 -0
  219. package/dist/cdn/assets/assistant-message-loading/t9n/messages.en.json +1 -0
  220. package/dist/cdn/index.js +2 -2
  221. package/dist/chunks/BaseWorkflow.js +1 -1
  222. package/dist/chunks/SKILL.js +5 -0
  223. package/dist/chunks/SKILL2.js +5 -0
  224. package/dist/chunks/SKILL3.js +22 -0
  225. package/dist/chunks/SKILL4.js +5 -0
  226. package/dist/chunks/adapter.js +1127 -2011
  227. package/dist/chunks/aiFactory.js +94 -0
  228. package/dist/chunks/arcgisKnowledgeGraph.js +97 -77
  229. package/dist/chunks/arcgisToolRegistry.js +88 -0
  230. package/dist/chunks/arcgis_knowledge_current_lc_context.js +20 -3
  231. package/dist/chunks/arcgis_knowledge_current_map_context.js +32 -3
  232. package/dist/chunks/arcgis_knowledge_cypher_query_prompt.js +102 -0
  233. package/dist/chunks/arcgis_knowledge_lucene_generation_prompt.js +1 -1
  234. package/dist/chunks/arcgis_knowledge_summarize_result_prompt.js +117 -28
  235. package/dist/chunks/arcgis_knowledge_tool_prompt.js +1 -1
  236. package/dist/chunks/baseAgentState.js +58 -0
  237. package/dist/chunks/converterUtils.js +67 -42
  238. package/dist/chunks/dataExplorationAgent.js +19 -0
  239. package/dist/chunks/data_explore_filter_prompt.js +1 -1
  240. package/dist/chunks/data_explore_query_prompt.js +10 -5
  241. package/dist/chunks/embeddings.worker.js +1 -1
  242. package/dist/chunks/fetchAgentContext.js +13 -0
  243. package/dist/chunks/fetchService.js +10 -0
  244. package/dist/chunks/fieldStatistics.js +79 -0
  245. package/dist/chunks/field_descriptions_prompt.js +1 -1
  246. package/dist/chunks/formatFeatureAttributes.js +132 -0
  247. package/dist/chunks/generateLayerDescriptions.js +190 -311
  248. package/dist/chunks/graph.js +1 -1
  249. package/dist/chunks/helpAgent.js +34 -0
  250. package/dist/chunks/help_prompt.js +35 -18
  251. package/dist/chunks/index.js +1 -1
  252. package/dist/chunks/intent_prompt.js +3 -3
  253. package/dist/chunks/layerStylingGraph.js +102 -84
  254. package/dist/chunks/layer_descriptions_prompt.js +1 -1
  255. package/dist/chunks/layer_styling_prompt.js +1 -1
  256. package/dist/chunks/mergeWhereClauses.js +15 -0
  257. package/dist/chunks/navigationAgent.js +27 -0
  258. package/dist/chunks/navigation_intent_prompt.js +9 -3
  259. package/dist/chunks/navigation_tool_prompt.js +1 -1
  260. package/dist/chunks/orchestrator.js +446 -235
  261. package/dist/chunks/requireAgentServices.js +11 -0
  262. package/dist/chunks/resolvePointGeometryFilter.js +92 -0
  263. package/dist/chunks/runtime.js +1 -1
  264. package/dist/chunks/slottableRequestUtils.js +1 -1
  265. package/dist/chunks/state.js +22 -28
  266. package/dist/chunks/summarize_query_response_prompt.js +1 -1
  267. package/dist/chunks/useT9n.js +1 -1
  268. package/dist/chunks/utils.js +1 -1
  269. package/dist/chunks/utils2.js +12 -12
  270. package/dist/chunks/utils3.js +1 -1
  271. package/dist/components/arcgis-assistant/customElement.d.ts +102 -1
  272. package/dist/components/arcgis-assistant/customElement.js +332 -184
  273. package/dist/components/arcgis-assistant-agent/customElement.d.ts +13 -1
  274. package/dist/components/arcgis-assistant-agent/customElement.js +533 -11
  275. package/dist/components/arcgis-assistant-chat/customElement.js +23 -18
  276. package/dist/components/arcgis-assistant-chat-entry/customElement.js +1 -1
  277. package/dist/components/arcgis-assistant-data-exploration-agent/customElement.js +35 -9
  278. package/dist/components/arcgis-assistant-help-agent/customElement.js +32 -9
  279. package/dist/components/arcgis-assistant-interrupt/customElement.d.ts +4 -0
  280. package/dist/components/arcgis-assistant-interrupt/customElement.js +12 -13
  281. package/dist/components/arcgis-assistant-interrupt-preview/customElement.js +13 -9
  282. package/dist/components/arcgis-assistant-knowledge-agent/customElement.d.ts +1 -1
  283. package/dist/components/arcgis-assistant-knowledge-agent/customElement.js +41 -17
  284. package/dist/components/arcgis-assistant-layer-styling-agent/customElement.js +31 -8
  285. package/dist/components/arcgis-assistant-message/customElement.d.ts +3 -0
  286. package/dist/components/arcgis-assistant-message/customElement.js +10 -9
  287. package/dist/components/arcgis-assistant-message-block/customElement.js +2 -2
  288. package/dist/components/arcgis-assistant-message-feedback/customElement.js +1 -1
  289. package/dist/components/arcgis-assistant-message-footer/customElement.js +1 -1
  290. package/dist/components/arcgis-assistant-message-loading/customElement.d.ts +3 -0
  291. package/dist/components/arcgis-assistant-message-loading/customElement.js +12 -11
  292. package/dist/components/arcgis-assistant-message-log/customElement.js +1 -1
  293. package/dist/components/arcgis-assistant-message-read-aloud/customElement.js +1 -1
  294. package/dist/components/arcgis-assistant-message-text/customElement.d.ts +1 -0
  295. package/dist/components/arcgis-assistant-message-text/customElement.js +13 -13
  296. package/dist/components/arcgis-assistant-navigation-agent/customElement.js +34 -10
  297. package/dist/components/arcgis-assistant-speech-input/customElement.js +35 -53
  298. package/dist/components/arcgis-assistant-suggested-prompts/customElement.js +1 -1
  299. package/dist/components/arcgis-assistant-user-message/customElement.d.ts +2 -0
  300. package/dist/components/arcgis-assistant-user-message/customElement.js +16 -11
  301. package/dist/docs/api.json +1 -1
  302. package/dist/docs/docs.json +1 -1
  303. package/dist/docs/vscode.html-custom-data.json +1 -1
  304. package/dist/docs/web-types.json +1 -1
  305. package/dist/index.js +1 -1
  306. package/dist/loader.js +7 -7
  307. package/dist/oauth-callback.html +1 -1
  308. package/dist/orchestrator/models/types.d.ts +1 -0
  309. package/dist/orchestrator/orchestrator/orchestratorEvents.d.ts +78 -0
  310. package/dist/orchestrator/providers/arcgis/aiFactory.d.ts +15 -0
  311. package/dist/orchestrator/types/types.d.ts +17 -0
  312. package/dist/types/lumina.d.ts +5 -4
  313. package/dist/types/preact.d.ts +5 -4
  314. package/dist/types/react.d.ts +5 -4
  315. package/dist/types/stencil.d.ts +7 -6
  316. package/dist/utils/index.d.ts +75 -39
  317. package/dist/utils/index.js +708 -84
  318. package/package.json +35 -12
  319. package/dist/cdn/34SG44C3.js +0 -72
  320. package/dist/cdn/3JGWGKT6.js +0 -2
  321. package/dist/cdn/3NBDVZ2I.js +0 -2
  322. package/dist/cdn/3VOQD2MR.js +0 -2
  323. package/dist/cdn/434TAA3J.js +0 -2
  324. package/dist/cdn/53NTYC4I.js +0 -2
  325. package/dist/cdn/5QAHYX7Y.js +0 -5
  326. package/dist/cdn/AXDZBBNL.js +0 -45
  327. package/dist/cdn/B7WJFBOZ.js +0 -2
  328. package/dist/cdn/BX7FSMUU.js +0 -56
  329. package/dist/cdn/CHPQM77M.js +0 -181
  330. package/dist/cdn/DHKUXLU3.js +0 -179
  331. package/dist/cdn/DQSEBKOX.js +0 -2
  332. package/dist/cdn/DZ2QWNUA.js +0 -3
  333. package/dist/cdn/EBISDZ5H.js +0 -2
  334. package/dist/cdn/ERL2CB2Y.js +0 -14
  335. package/dist/cdn/F2AHA4GB.js +0 -54
  336. package/dist/cdn/FUIGPHBH.js +0 -2
  337. package/dist/cdn/H2CHHGGH.js +0 -2
  338. package/dist/cdn/HWKDNS4K.js +0 -4
  339. package/dist/cdn/IMQ4TVHF.js +0 -16
  340. package/dist/cdn/IOD3GDA7.js +0 -2
  341. package/dist/cdn/IR7PTESF.js +0 -2
  342. package/dist/cdn/IRZDTYO2.js +0 -2
  343. package/dist/cdn/JIWK6QK6.js +0 -2
  344. package/dist/cdn/JLKGS6Y5.js +0 -36
  345. package/dist/cdn/K3JCH4XW.js +0 -2
  346. package/dist/cdn/KHXUWZHB.js +0 -2
  347. package/dist/cdn/KMQ3SP4I.js +0 -5
  348. package/dist/cdn/LIFK3QSD.js +0 -2
  349. package/dist/cdn/NXKKG5TK.js +0 -2
  350. package/dist/cdn/O3EN27N5.js +0 -2
  351. package/dist/cdn/O3RFFPU3.js +0 -6
  352. package/dist/cdn/PBO6FZN6.js +0 -2
  353. package/dist/cdn/Q3ZW4FYA.js +0 -3
  354. package/dist/cdn/Q6LRANX6.js +0 -2
  355. package/dist/cdn/QCSN44H4.js +0 -2
  356. package/dist/cdn/R56X6ZKR.js +0 -161
  357. package/dist/cdn/RUURNLTP.js +0 -2
  358. package/dist/cdn/T43LEBBE.js +0 -47
  359. package/dist/cdn/TR4GFL7X.js +0 -2
  360. package/dist/cdn/WNS5ZUF5.js +0 -2
  361. package/dist/cdn/X4XY5HIE.js +0 -2
  362. package/dist/cdn/XOH56EQ2.js +0 -2
  363. package/dist/cdn/XON27U6U.js +0 -2
  364. package/dist/cdn/YIMNOUTF.js +0 -2
  365. package/dist/cdn/YLN2BZ5J.js +0 -2
  366. package/dist/cdn/YUKR4AZW.js +0 -2
  367. package/dist/cdn/Z2G7MP5L.js +0 -22
  368. package/dist/chunks/dataExplorationGraph.js +0 -310
  369. package/dist/chunks/helpGraph.js +0 -126
  370. package/dist/chunks/navigationGraph.js +0 -270
  371. package/dist/chunks/toolCallResponse.js +0 -31
@@ -1,81 +1,128 @@
1
- /* COPYRIGHT Esri - https://js.arcgis.com/5.2/LICENSE.txt */
2
- import R from "@arcgis/core/identity/IdentityManager.js";
3
- import C from "@arcgis/core/portal/Portal.js";
4
- import { n as I, o as v, D as k, p as A, q as M, W as F } from "./generateLayerDescriptions.js";
5
- import { isGraphInterrupt as D, StateGraph as L, START as W, END as $, MemorySaver as j } from "@langchain/langgraph/web";
6
- import { HumanMessage as q, AIMessage as H } from "@langchain/core/messages";
7
- import { s as l } from "./index.js";
8
- import * as P from "@arcgis/core/core/reactiveUtils.js";
9
- import U from "@arcgis/core/layers/FeatureLayer.js";
10
- import O from "@arcgis/core/request.js";
11
- const T = async (t) => {
12
- const e = await N(), r = await I("default"), s = C.getDefault(), a = (await R.getCredential(`${s.url}/sharing`)).token, i = {
1
+ /* COPYRIGHT Esri - https://js.arcgis.com/1.0/LICENSE.txt */
2
+ import M from "@arcgis/core/identity/IdentityManager.js";
3
+ import _ from "@arcgis/core/portal/Portal.js";
4
+ import { g as $, a as D } from "./aiFactory.js";
5
+ import { isGraphInterrupt as F, StateGraph as L, START as W, END as q, MemorySaver as T } from "@langchain/langgraph/web";
6
+ import { generateGuid as b } from "@arcgis/toolkit/string";
7
+ import { g as A, D as j, b as H, W as P } from "./generateLayerDescriptions.js";
8
+ import { HumanMessage as U, AIMessage as O } from "@langchain/core/messages";
9
+ import { s as p } from "./index.js";
10
+ import { BaseCallbackHandler as G } from "@langchain/core/callbacks/base";
11
+ import * as N from "@arcgis/core/core/reactiveUtils.js";
12
+ import V from "@arcgis/core/layers/FeatureLayer.js";
13
+ import z from "@arcgis/core/request.js";
14
+ const B = async (n) => {
15
+ const e = await Q(), r = await $("default"), s = _.getDefault(), a = (await M.getCredential(`${s.url}/sharing`)).token, i = {
13
16
  type: "generateEmbeddings",
14
- webmapEmbeddings: t,
17
+ webmapEmbeddings: n,
15
18
  auth: { apiUrl: r, token: a }
16
19
  };
17
- return e.postMessage(i), await new Promise((c, d) => {
18
- const o = (u) => {
19
- u.data === "completed" && (e.removeEventListener("message", o), c());
20
- }, g = (u) => {
21
- e.removeEventListener("message", o), d(u instanceof Error ? u : new Error("Embeddings worker error"));
20
+ return e.postMessage(i), await new Promise((o, d) => {
21
+ const c = (g) => {
22
+ g.data === "completed" && (e.removeEventListener("message", c), o());
23
+ }, u = (g) => {
24
+ e.removeEventListener("message", c), d(g instanceof Error ? g : new Error("Embeddings worker error"));
22
25
  };
23
- e.addEventListener("message", o), e.addEventListener("error", g, { once: !0 });
26
+ e.addEventListener("message", c), e.addEventListener("error", u, { once: !0 });
24
27
  }), e;
25
- }, N = async () => {
28
+ }, Q = async () => {
26
29
  {
27
- const t = (await import("./embeddings.worker.js")).default;
28
- return new t();
29
- }
30
- }, G = (t) => {
31
- t.currentIntent = "none";
32
- }, _ = async (t, e) => {
33
- const r = v(e);
34
- if (t.agentExecutionContext.userRequest) {
35
- const n = new q(t.agentExecutionContext.userRequest.trim());
36
- t.agentExecutionContext.messages = [...t.agentExecutionContext.messages, n], G(t);
37
- }
38
- const s = r?.services.agentRegistry.list().map((n) => n.agent.id) ?? [];
39
- return await l({ text: `Available agents: ${[...s].join(", ")}` }, e), await l({ text: "Analyzing user input" }, e), t;
40
- }, V = async (t, e) => (await l({ text: "Exiting..." }, e), t), w = (t) => typeof t == "object" && t !== null && !Array.isArray(t), z = (t, e) => {
41
- if (!w(t)) {
42
- t !== void 0 && console.warn(`Agent "${e}" returned invalid sharedStatePatch. Ignoring it.`);
30
+ const n = (await import("./embeddings.worker.js")).default;
31
+ return new n();
32
+ }
33
+ }, K = (n) => {
34
+ n.currentIntent = "none";
35
+ }, J = async (n, e) => {
36
+ const r = A(e);
37
+ if (n.agentExecutionContext.userRequest) {
38
+ const t = new U(n.agentExecutionContext.userRequest.trim());
39
+ n.agentExecutionContext.messages = [...n.agentExecutionContext.messages, t], K(n);
40
+ }
41
+ const s = r?.services.agentRegistry.list().map((t) => t.agent.id) ?? [];
42
+ return await p({ text: `Available agents: ${[...s].join(", ")}` }, e), await p({ text: "Analyzing user input" }, e), n;
43
+ }, X = async (n, e) => (await p({ text: "Exiting..." }, e), n), E = (n) => typeof n == "object" && n !== null && !Array.isArray(n), Y = (n, e) => {
44
+ if (!E(n)) {
45
+ n !== void 0 && console.warn(`Agent "${e}" returned invalid sharedStatePatch. Ignoring it.`);
43
46
  return;
44
47
  }
45
48
  const r = {};
46
- for (const [s, n] of Object.entries(t)) {
47
- if (!w(n) || !("value" in n)) {
49
+ for (const [s, t] of Object.entries(n)) {
50
+ if (!E(t) || !("value" in t)) {
48
51
  console.warn(
49
52
  `Agent "${e}" returned invalid sharedStatePatch entry for key "${s}". Ignoring that entry.`
50
53
  );
51
54
  continue;
52
55
  }
53
- r[s] = { value: n.value };
56
+ r[s] = { value: t.value };
54
57
  }
55
58
  return r;
56
- }, Q = (t) => {
57
- const { previousSharedState: e, patch: r, agentId: s } = t;
59
+ }, Z = (n) => {
60
+ const { previousSharedState: e, patch: r, agentId: s } = n;
58
61
  if (!r)
59
62
  return e;
60
- const n = Date.now(), a = {
63
+ const t = Date.now(), a = {
61
64
  ...e
62
65
  };
63
- for (const [i, c] of Object.entries(r))
64
- c?.value !== void 0 && (a[i] = {
65
- value: c.value,
66
+ for (const [i, o] of Object.entries(r))
67
+ o?.value !== void 0 && (a[i] = {
68
+ value: o.value,
66
69
  meta: {
67
70
  updatedByAgentId: s,
68
- updatedAt: n
71
+ updatedAt: t
69
72
  }
70
73
  });
71
74
  return a;
72
- }, f = (t) => {
73
- if (typeof t != "string")
75
+ }, ee = 256, te = /* @__PURE__ */ new Set(["point", "polyline", "polygon", "extent", "custom"]), ne = (n) => typeof n == "object" && n !== null && !Array.isArray(n), re = (n, e) => {
76
+ if (n === void 0)
74
77
  return;
75
- const e = t.trim();
78
+ if (!Array.isArray(n)) {
79
+ console.warn(`Agent "${e}" returned invalid sharedResourceAdditions. Ignoring it.`);
80
+ return;
81
+ }
82
+ const r = [];
83
+ for (const [s, t] of n.entries()) {
84
+ if (!ne(t) || typeof t.kind != "string" || !te.has(t.kind) || typeof t.description != "string" || !t.description.trim() || !("payload" in t) || t.payload === void 0) {
85
+ console.warn(
86
+ `Agent "${e}" returned invalid sharedResourceAdditions entry at index ${s}. Ignoring that entry.`
87
+ );
88
+ continue;
89
+ }
90
+ let a;
91
+ try {
92
+ a = structuredClone(t.payload);
93
+ } catch {
94
+ console.warn(
95
+ `Agent "${e}" returned invalid sharedResourceAdditions entry at index ${s}. Ignoring that entry.`
96
+ );
97
+ continue;
98
+ }
99
+ r.push({
100
+ kind: t.kind,
101
+ description: t.description.trim().slice(0, ee),
102
+ payload: a
103
+ });
104
+ }
105
+ return r.length ? r : void 0;
106
+ }, se = (n) => {
107
+ const { previousSharedResources: e, additions: r, agentId: s } = n;
108
+ if (!r?.length)
109
+ return e;
110
+ const t = Date.now(), a = r.map((i) => ({
111
+ ...i,
112
+ id: b(),
113
+ meta: {
114
+ createdByAgentId: s,
115
+ createdAt: t
116
+ }
117
+ }));
118
+ return [...e, ...a].slice(-50);
119
+ }, R = (n) => {
120
+ if (typeof n != "string")
121
+ return;
122
+ const e = n.trim();
76
123
  return e || void 0;
77
- }, B = (t) => {
78
- switch (t) {
124
+ }, ae = (n) => {
125
+ switch (n) {
79
126
  case "failed":
80
127
  return "Agent failed without a summary.";
81
128
  case "unknown":
@@ -85,98 +132,195 @@ const T = async (t) => {
85
132
  default:
86
133
  return "Agent completed without a summary.";
87
134
  }
88
- }, J = (t, e) => {
89
- const r = f(e?.outputMessage), s = f(e?.summary), n = e?.status, a = n === "success" || n === "failed" ? n : "unknown";
90
- a === "unknown" && console.warn(`Agent "${t}" returned missing/invalid status. Defaulting to "unknown".`);
91
- const i = z(e?.sharedStatePatch, t);
135
+ }, ie = (n, e) => {
136
+ const r = R(e?.outputMessage), s = R(e?.summary), t = e?.status, a = t === "success" || t === "failed" ? t : "unknown";
137
+ a === "unknown" && console.warn(`Agent "${n}" returned missing/invalid status. Defaulting to "unknown".`);
138
+ const i = Y(e?.sharedStatePatch, n), o = re(e?.sharedResourceAdditions, n);
92
139
  return {
93
140
  outputMessage: r,
94
- summary: s ?? r ?? B(a),
141
+ summary: s ?? r ?? ae(a),
95
142
  status: a,
96
- sharedStatePatch: i
143
+ sharedStatePatch: i,
144
+ sharedResourceAdditions: o
97
145
  };
98
- }, E = 4e3, K = async (t, e) => {
99
- const r = v(e);
100
- if (r?.abortSignal?.aborted)
101
- return await l({ text: "Run cancelled; skipping agent execution" }, e), {
102
- ...t,
146
+ }, x = 4e3, oe = async (n, e) => {
147
+ const r = A(e);
148
+ if (e?.signal?.aborted)
149
+ return await p({ text: "Run cancelled; skipping agent execution" }, e), {
150
+ ...n,
103
151
  currentIntent: "none",
104
152
  requiresFollowUp: !1
105
153
  };
106
- const { agentRegistry: s } = r?.services ?? {}, n = s?.get(t.currentIntent);
107
- if (!n)
108
- return console.warn(`No agent found for intent: ${t.currentIntent}`), t;
109
- await l({ text: `Executing registered agent: ${n.agent.name}` }, e);
154
+ const { agentRegistry: s } = r?.services ?? {}, t = s?.get(n.currentIntent);
155
+ if (!t)
156
+ return console.warn(`No agent found for intent: ${n.currentIntent}`), n;
157
+ await p({ text: `Executing registered agent: ${t.agent.name}` }, e);
110
158
  const a = {
111
159
  ...e ?? {},
160
+ metadata: {
161
+ ...e?.metadata,
162
+ agentId: t.agent.id
163
+ },
112
164
  configurable: {
113
165
  ...r ?? {},
114
- agentId: n.agent.id,
115
- context: n.getContext ? await n.getContext() : void 0
166
+ agentId: t.agent.id,
167
+ context: t.getContext ? await t.getContext() : void 0
116
168
  }
117
169
  };
118
170
  let i;
119
171
  try {
120
- const o = await n.agent.createGraph().compile().invoke(
172
+ const c = await t.agent.createGraph().compile().invoke(
121
173
  {
122
174
  agentExecutionContext: {
123
- ...t.agentExecutionContext,
175
+ ...n.agentExecutionContext,
124
176
  // deep clone on messages did not work in agents, so its a shallow clone here.
125
- messages: [...t.agentExecutionContext.messages],
177
+ messages: [...n.agentExecutionContext.messages],
126
178
  // deep clone to prevent accidental mutations by agents
127
- priorSteps: structuredClone(t.agentExecutionContext.priorSteps ?? []),
128
- sharedState: structuredClone(t.agentExecutionContext.sharedState ?? {})
179
+ priorSteps: structuredClone(n.agentExecutionContext.priorSteps ?? []),
180
+ sharedState: structuredClone(n.agentExecutionContext.sharedState ?? {}),
181
+ sharedResources: structuredClone(n.agentExecutionContext.sharedResources ?? [])
129
182
  }
130
183
  },
131
184
  a
132
185
  );
133
- i = J(n.agent.name, o), await l({ text: `Finished executing registered agent: ${n.agent.name}` }, e);
134
- } catch (o) {
135
- if (D(o))
136
- throw o;
137
- const g = o instanceof Error ? o.message : String(o);
138
- console.error(`Agent "${n.agent.name}" failed:`, o), await l({ text: `Registered agent failed: ${n.agent.name}. ${g}` }, e), i = {
186
+ i = ie(t.agent.name, c), await p({ text: `Finished executing registered agent: ${t.agent.name}` }, e);
187
+ } catch (c) {
188
+ if (F(c) || e?.signal?.aborted || c instanceof Error && c.name === "AbortError")
189
+ throw c;
190
+ const u = c instanceof Error ? c.message : String(c);
191
+ console.error(`Agent "${t.agent.name}" failed:`, c), await p({ text: `Registered agent failed: ${t.agent.name}. ${u}` }, e), i = {
139
192
  status: "failed",
140
- outputMessage: `Agent execution failed: ${g}`,
141
- summary: `Agent execution failed: ${g}`
193
+ outputMessage: `Agent execution failed: ${u}`,
194
+ summary: `Agent execution failed: ${u}`
142
195
  };
143
196
  }
144
- const c = i.outputMessage, d = [...t.agentExecutionContext.messages];
145
- if (c) {
146
- const o = c.length > E ? `${c.slice(0, E - 14)}
147
- [truncated]` : c;
148
- d.push(new H(o));
197
+ const o = i.outputMessage, d = [...n.agentExecutionContext.messages];
198
+ if (o) {
199
+ const c = o.length > x ? `${o.slice(0, x - 14)}
200
+ [truncated]` : o;
201
+ d.push(new O(c));
149
202
  }
150
203
  return {
151
- ...t,
152
- stepCount: t.stepCount + 1,
153
- lastExecutedAgent: n.agent.id,
154
- requiresFollowUp: i.status === "failed" ? !0 : t.requiresFollowUp,
155
- finalOutputMessage: c ?? "",
204
+ ...n,
205
+ stepCount: n.stepCount + 1,
206
+ lastExecutedAgent: t.agent.id,
207
+ requiresFollowUp: i.status === "failed" ? !0 : n.requiresFollowUp,
208
+ finalOutputMessage: o ?? "",
156
209
  agentExecutionContext: {
157
- ...t.agentExecutionContext,
210
+ ...n.agentExecutionContext,
158
211
  messages: d,
159
212
  priorSteps: [
160
- ...t.agentExecutionContext.priorSteps ?? [],
213
+ ...n.agentExecutionContext.priorSteps ?? [],
161
214
  {
162
- agentId: n.agent.id,
163
- assignedTask: t.agentExecutionContext.assignedTask,
215
+ agentId: t.agent.id,
216
+ assignedTask: n.agentExecutionContext.assignedTask,
164
217
  summary: i?.summary || "No summary provided.",
165
218
  status: i?.status || "unknown"
166
219
  }
167
220
  ],
168
- sharedState: Q({
169
- previousSharedState: t.agentExecutionContext.sharedState,
221
+ sharedState: Z({
222
+ previousSharedState: n.agentExecutionContext.sharedState,
170
223
  patch: i.sharedStatePatch,
171
- agentId: n.agent.id
224
+ agentId: t.agent.id
225
+ }),
226
+ sharedResources: se({
227
+ previousSharedResources: n.agentExecutionContext.sharedResources,
228
+ additions: i.sharedResourceAdditions,
229
+ agentId: t.agent.id
172
230
  })
173
231
  }
174
232
  };
175
- }, X = 3, Y = () => new L(k).addNode("ingestInput", _).addNode("intentLLM", A).addNode("executeRegisteredAgent", K).addNode("exit", V).addEdge(W, "ingestInput").addEdge("ingestInput", "intentLLM").addConditionalEdges("intentLLM", (e) => e.currentIntent === "none" || e.currentIntent === e.lastExecutedAgent ? "exit" : "executeRegisteredAgent").addConditionalEdges(
176
- "executeRegisteredAgent",
177
- (e) => e.stepCount >= X || !e.requiresFollowUp ? "exit" : "intentLLM"
178
- ).addEdge("exit", $);
179
- class Z {
233
+ }, ce = async (n, e) => {
234
+ if (n.routing.mode !== "direct")
235
+ throw new Error("Direct agent assignment requires direct routing.");
236
+ return await p({ text: `Doing a direct route to agent: ${n.routing.agentId}` }, e), {
237
+ ...n,
238
+ currentIntent: n.routing.agentId,
239
+ requiresFollowUp: !1,
240
+ agentExecutionContext: {
241
+ ...n.agentExecutionContext,
242
+ assignedTask: n.agentExecutionContext.userRequest
243
+ }
244
+ };
245
+ }, de = 3, ue = (n) => n.routing.mode === "direct" ? "assignDirectAgent" : "intentLLM", ge = (n) => n.routing.mode === "direct" || n.stepCount >= de || !n.requiresFollowUp ? "exit" : "intentLLM", le = () => new L(j).addNode("ingestInput", J).addNode("assignDirectAgent", ce).addNode("intentLLM", H).addNode("executeRegisteredAgent", oe).addNode("exit", X).addEdge(W, "ingestInput").addConditionalEdges("ingestInput", ue).addEdge("assignDirectAgent", "executeRegisteredAgent").addConditionalEdges("intentLLM", (e) => e.currentIntent === "none" || e.currentIntent === e.lastExecutedAgent ? "exit" : "executeRegisteredAgent").addConditionalEdges("executeRegisteredAgent", ge).addEdge("exit", q), he = (n, e) => {
246
+ const r = n.output?.usage_metadata ?? e.usage_metadata, s = n.output?.llmOutput?.tokenUsage, t = r?.input_tokens ?? s?.promptTokens, a = r?.output_tokens ?? s?.completionTokens, i = r?.total_tokens ?? s?.totalTokens;
247
+ if (t === void 0 || a === void 0 || i === void 0)
248
+ return;
249
+ const o = r?.input_token_details?.cache_read, d = r?.output_token_details?.reasoning;
250
+ return {
251
+ input: t,
252
+ output: a,
253
+ total: i,
254
+ ...o !== void 0 && { cacheRead: o },
255
+ ...d !== void 0 && { reasoning: d }
256
+ };
257
+ }, pe = (n, e, r, s) => {
258
+ switch (n) {
259
+ case "chat_model":
260
+ case "llm":
261
+ return "model";
262
+ case "tool":
263
+ case "retriever":
264
+ return n;
265
+ case "chain":
266
+ return !s || e === "LangGraph" ? "workflow" : r === e ? "node" : "chain";
267
+ default:
268
+ return;
269
+ }
270
+ }, me = (n) => {
271
+ if (n instanceof Error)
272
+ return { message: n.message, name: n.name };
273
+ const e = n, r = typeof e?.message == "string" ? e.message : String(n ?? "Unknown runtime error"), s = typeof e?.name == "string" ? e.name : void 0;
274
+ return { message: r, ...s && { name: s } };
275
+ }, ye = ({
276
+ event: n,
277
+ runId: e,
278
+ parentSpanId: r,
279
+ timestamp: s
280
+ }) => {
281
+ const t = /^on_(.+)_(start|end|error)$/u.exec(n.event);
282
+ if (!t)
283
+ return;
284
+ const [, a, i] = t, o = n.metadata ?? {}, d = o.langgraph_node, c = pe(a, n.name, d, r);
285
+ if (!c)
286
+ return;
287
+ const u = o.agentId, g = o.model ?? o.ls_model_name, l = n.data, f = i === "end" && c === "model" ? he(l, o) : void 0, h = n.tags?.includes("langsmith:hidden") || d === "__start__", v = {
288
+ ...g && { model: g },
289
+ ...f && { tokenUsage: f },
290
+ ...h && { internal: !0 }
291
+ }, w = {
292
+ id: n.run_id,
293
+ ...r && { parentId: r },
294
+ label: n.name,
295
+ type: c,
296
+ ...Object.keys(v).length && { metadata: v }
297
+ }, m = { runId: e, timestamp: s, type: "runtime", ...u && { agentId: u } };
298
+ switch (i) {
299
+ case "start":
300
+ return {
301
+ ...m,
302
+ phase: "started",
303
+ span: {
304
+ ...w,
305
+ ...l?.input !== void 0 && { input: l.input }
306
+ }
307
+ };
308
+ case "end":
309
+ return {
310
+ ...m,
311
+ phase: "completed",
312
+ span: {
313
+ ...w,
314
+ ...l?.output !== void 0 && { output: l.output }
315
+ }
316
+ };
317
+ case "error":
318
+ return { ...m, phase: "failed", span: { ...w, error: me(l?.error) } };
319
+ default:
320
+ return;
321
+ }
322
+ };
323
+ class S {
180
324
  constructor() {
181
325
  this.agentRegistry = /* @__PURE__ */ new Map();
182
326
  }
@@ -193,7 +337,7 @@ class Z {
193
337
  return [...this.agentRegistry.values()];
194
338
  }
195
339
  }
196
- class ee {
340
+ class fe {
197
341
  /**
198
342
  * Create a new InterruptHandler tied to a specific compiled graph and config.
199
343
  */
@@ -217,7 +361,7 @@ class ee {
217
361
  agentId: e.agentId,
218
362
  id: e.id,
219
363
  payload: r
220
- }, n = this.graph.streamEvents(null, {
364
+ }, t = this.graph.streamEvents(null, {
221
365
  ...this.config,
222
366
  configurable: {
223
367
  ...this.config.configurable,
@@ -226,7 +370,7 @@ class ee {
226
370
  subgraphs: !0,
227
371
  version: "v2"
228
372
  });
229
- this.resolveWait?.(n);
373
+ this.resolveWait?.(t);
230
374
  } catch (s) {
231
375
  this.rejectWait?.(s);
232
376
  } finally {
@@ -240,157 +384,157 @@ class ee {
240
384
  this.rejectWait && (this.rejectWait(new Error("Request cancelled by user.")), this.resolveWait = void 0, this.rejectWait = void 0);
241
385
  }
242
386
  }
243
- const te = async (t) => {
387
+ const we = async (n) => {
244
388
  try {
245
- return await (await M()).embedDocuments(t);
389
+ return await (await D()).embedDocuments(n);
246
390
  } catch (e) {
247
391
  throw console.error("Failed to generate embeddings:", e), e;
248
392
  }
249
- }, b = async (t, e) => {
250
- const r = e.get(t);
393
+ }, C = async (n, e) => {
394
+ const r = e.get(n);
251
395
  if (r)
252
396
  return r;
253
- const s = await te([t]);
254
- return e.set(t, s[0]), s[0];
397
+ const s = await we([n]);
398
+ return e.set(n, s[0]), s[0];
255
399
  };
256
- async function re(t, e, r, s) {
257
- const n = `req-${Date.now()}`, i = {
400
+ async function ve(n, e, r, s) {
401
+ const t = `req-${Date.now()}`, i = {
258
402
  type: "layerSearch",
259
- precomputedEmbedding: s ? await b(t, s) : void 0,
260
- requestId: n,
403
+ precomputedEmbedding: s ? await C(n, s) : void 0,
404
+ requestId: t,
261
405
  minScore: r
262
406
  };
263
- return await new Promise((c) => {
264
- const d = (o) => {
265
- o.data.requestId === n && c(o.data.results);
407
+ return await new Promise((o) => {
408
+ const d = (c) => {
409
+ c.data.requestId === t && o(c.data.results);
266
410
  };
267
411
  e.addEventListener("message", d, { once: !0 }), e.postMessage(i);
268
412
  });
269
413
  }
270
- function ne(t) {
271
- const { worker: e } = t;
414
+ function Ee(n) {
415
+ const { worker: e } = n;
272
416
  return {
273
417
  async searchLayers({
274
418
  text: r,
275
419
  minScore: s,
276
- embeddingCache: n
420
+ embeddingCache: t
277
421
  }) {
278
- return await re(r, e, s, n);
422
+ return await ve(r, e, s, t);
279
423
  }
280
424
  };
281
425
  }
282
- const se = async ({
283
- combinedQuery: t,
426
+ const Re = async ({
427
+ combinedQuery: n,
284
428
  layerIds: e,
285
429
  embeddingsWorker: r,
286
430
  minScore: s,
287
- topResults: n,
431
+ topResults: t,
288
432
  embeddingCache: a
289
433
  }) => {
290
- const i = `req-${Date.now()}`, c = a ? await b(t, a) : void 0, d = {
434
+ const i = `req-${Date.now()}`, o = a ? await C(n, a) : void 0, d = {
291
435
  type: "fieldSearch",
292
436
  layerIdForFieldsSearch: e,
293
- precomputedEmbedding: c,
437
+ precomputedEmbedding: o,
294
438
  requestId: i,
295
439
  minScore: s,
296
- topResults: n
440
+ topResults: t
297
441
  };
298
- return await new Promise((o) => {
299
- const g = (u) => {
300
- if (u.data.requestId !== i)
442
+ return await new Promise((c) => {
443
+ const u = (g) => {
444
+ if (g.data.requestId !== i)
301
445
  return;
302
- const p = u.data.results.map(({ layerId: y, results: m }) => ({
303
- layerId: y,
304
- results: m
446
+ const l = g.data.results.map(({ layerId: f, results: h }) => ({
447
+ layerId: f,
448
+ results: h
305
449
  }));
306
- o(p);
450
+ c(l);
307
451
  };
308
- r.addEventListener("message", g, { once: !0 }), r.postMessage(d);
452
+ r.addEventListener("message", u, { once: !0 }), r.postMessage(d);
309
453
  });
310
454
  };
311
- function ae(t) {
312
- const { worker: e } = t;
455
+ function xe(n) {
456
+ const { worker: e } = n;
313
457
  return {
314
- async searchFields({ text: r, layerIds: s, minScore: n, topResults: a, embeddingCache: i }) {
315
- return await se({
458
+ async searchFields({ text: r, layerIds: s, minScore: t, topResults: a, embeddingCache: i }) {
459
+ return await Re({
316
460
  combinedQuery: r,
317
461
  layerIds: s,
318
462
  embeddingsWorker: e,
319
- minScore: n,
463
+ minScore: t,
320
464
  topResults: a,
321
465
  embeddingCache: i
322
466
  });
323
467
  }
324
468
  };
325
469
  }
326
- const ie = (t) => {
327
- const e = F.safeParse(t);
470
+ const Se = (n) => {
471
+ const e = P.safeParse(n);
328
472
  if (!e.success)
329
473
  throw new Error("Embeddings response validation failed. Regenerate embeddings.");
330
474
  return e.data;
331
- }, oe = (t, e) => {
475
+ }, be = (n, e) => {
332
476
  const r = /* @__PURE__ */ new Map(), s = /* @__PURE__ */ new Map();
333
- if (e.allLayers.forEach((n) => {
334
- n instanceof U && s.set(n.id, n);
335
- }), t.length !== s.size)
477
+ if (e.allLayers.forEach((t) => {
478
+ t instanceof V && s.set(t.id, t);
479
+ }), n.length !== s.size)
336
480
  throw new Error("Layer count mismatch during registry restoration. Regenerate embeddings.");
337
- for (const n of t) {
338
- const a = s.get(n.id);
481
+ for (const t of n) {
482
+ const a = s.get(t.id);
339
483
  if (!a)
340
484
  throw new Error(
341
- `Layer with ID ${n.id} not found in the original map during registry restoration. Regenerate embeddings.`
485
+ `Layer with ID ${t.id} not found in the original map during registry restoration. Regenerate embeddings.`
342
486
  );
343
- if (n.fields.length !== a.fields.length)
487
+ if (t.fields.length !== a.fields.length)
344
488
  throw new Error(
345
- `Field count mismatch for layer ID ${n.id} during registry restoration. Regenerate embeddings.`
489
+ `Field count mismatch for layer ID ${t.id} during registry restoration. Regenerate embeddings.`
346
490
  );
347
491
  const i = {
348
- name: n.name,
349
- title: n.title,
350
- description: n.description
351
- }, c = /* @__PURE__ */ new Map();
352
- for (const d of n.fields) {
353
- const o = a.fieldsIndex.get(d.name);
354
- if (!o)
492
+ name: t.name,
493
+ title: t.title,
494
+ description: t.description
495
+ }, o = /* @__PURE__ */ new Map();
496
+ for (const d of t.fields) {
497
+ const c = a.fieldsIndex.get(d.name);
498
+ if (!c)
355
499
  throw new Error(
356
- `Field with name ${d.name} not found in the original layer ${n.id} during registry restoration. Regenerate embeddings.`
500
+ `Field with name ${d.name} not found in the original layer ${t.id} during registry restoration. Regenerate embeddings.`
357
501
  );
358
- c.set(d.name, {
502
+ o.set(d.name, {
359
503
  name: d.name,
360
504
  alias: a.getFieldAlias(d.name) ?? d.alias,
361
505
  description: d.description,
362
- type: o.type || "unknown",
363
- valueType: o.valueType || "unknown",
506
+ type: c.type || "unknown",
507
+ valueType: c.valueType || "unknown",
364
508
  domain: a.getFieldDomain(d.name) ?? void 0
365
509
  });
366
510
  }
367
- r.set(n.id, {
511
+ r.set(t.id, {
368
512
  layerItem: i,
369
- fieldRegistry: c
513
+ fieldRegistry: o
370
514
  });
371
515
  }
372
516
  return r;
373
- }, ce = async (t) => {
517
+ }, Ae = async (n) => {
374
518
  try {
375
- return (await O(t, {
519
+ return (await z(n, {
376
520
  responseType: "json"
377
521
  })).data;
378
522
  } catch (e) {
379
- throw new Error(`Failed to fetch data from ${t}: ${String(e)}`);
523
+ throw new Error(`Failed to fetch data from ${n}: ${String(e)}`);
380
524
  }
381
- }, de = async (t) => {
382
- const e = t.map;
525
+ }, Ce = async (n) => {
526
+ const e = n.map;
383
527
  if (!e?.portalItem)
384
528
  throw new Error("WebMap portal item is missing.");
385
529
  const { resources: r } = await e.portalItem.fetchResources(), s = r.find((i) => i.resource.path === "embeddings-v01.json");
386
530
  if (!s?.resource.url)
387
531
  throw new Error("Embeddings resource 'embeddings-v01.json' not found in the webmap portal item.");
388
- const n = await ce(s.resource.url);
389
- return ie(n);
532
+ const t = await Ae(s.resource.url);
533
+ return Se(t);
390
534
  };
391
- class x {
535
+ class k {
392
536
  constructor() {
393
- this.orchestratorReady = !1, this.chatHistory = [], this.priorSteps = [], this.sharedState = {}, this.agentRegistry = new Z(), this.activeRunId = "", this.cancelledRunIds = /* @__PURE__ */ new Set(), this.streamEpoch = 0;
537
+ this.orchestratorReady = !1, this.chatHistory = [], this.priorSteps = [], this.sharedState = {}, this.sharedResources = [], this.agentRegistry = new S(), this.activeRunId = "", this.cancelledRunIds = /* @__PURE__ */ new Set(), this.parentRunIds = /* @__PURE__ */ new Map(), this.activeRuntimeSpans = /* @__PURE__ */ new Map(), this.runtimeEventsEnabled = !1, this.streamEpoch = 0;
394
538
  }
395
539
  /**
396
540
  * Creates and returns an AI-ready Orchestrator instance.
@@ -398,15 +542,16 @@ class x {
398
542
  * @returns Ready Orchestrator.
399
543
  */
400
544
  static async init(e) {
401
- const r = new x();
545
+ const r = new k();
546
+ r.runtimeEventsEnabled = e.runtimeEventsEnabled ?? !1;
402
547
  try {
403
548
  if (e.view?.map) {
404
- await P.whenOnce(() => e.view.ready);
405
- const s = await de(e.view), n = oe(
549
+ await N.whenOnce(() => e.view.ready);
550
+ const s = await Ce(e.view), t = be(
406
551
  s.layers,
407
552
  e.view.map
408
553
  );
409
- r.layersAndFieldsRegistry = n, r.embeddingsWorker = await T(s);
554
+ r.layersAndFieldsRegistry = t, r.embeddingsWorker = await B(s);
410
555
  }
411
556
  return e.agents?.forEach((s) => {
412
557
  r.agentRegistry.register(s);
@@ -422,97 +567,105 @@ class x {
422
567
  * - `interrupt`: HITL required, wait for `resumeInterrupt()`
423
568
  * - `completed`: final result with chat history + layer styling
424
569
  * - `cancelled`: user aborted the run
570
+ * @param userInput User request to process.
571
+ * @param options Agent selection and routing behavior for this run.
425
572
  */
426
- async *ask(e) {
573
+ async *ask(e, r = {}) {
427
574
  if (!this.orchestratorReady)
428
575
  throw new Error("Orchestrator is not ready yet.");
429
576
  if (!this.agentRegistry.list().length)
430
577
  throw new Error("Orchestrator has no registered agents.");
578
+ const s = this.createRequestAgentRegistry(r);
579
+ if (!s.list().length)
580
+ throw new Error("Orchestrator has no agents selected for this request.");
431
581
  if (++this.streamEpoch, !e.trim())
432
582
  return;
433
- const r = crypto.randomUUID();
434
- this.activeRunId = r, this.activeAbortController = new AbortController(), this.graph || (this.graph = Y().compile({ checkpointer: new j() }));
435
- const s = this.embeddingsWorker ? ne({ worker: this.embeddingsWorker }) : void 0, n = this.embeddingsWorker ? ae({ worker: this.embeddingsWorker }) : void 0, a = /* @__PURE__ */ new Map(), c = {
583
+ const t = b();
584
+ this.parentRunIds.clear(), this.activeRuntimeSpans.clear(), this.activeRunId = t, this.activeAbortController = new AbortController(), this.graph || (this.graph = le().compile({ checkpointer: new T() }));
585
+ const a = this.embeddingsWorker ? Ee({ worker: this.embeddingsWorker }) : void 0, i = this.embeddingsWorker ? xe({ worker: this.embeddingsWorker }) : void 0, o = /* @__PURE__ */ new Map(), d = r.routing === "direct" ? { mode: "direct", agentId: r.agentId } : { mode: "auto" }, c = {
586
+ // eslint-disable-next-line @typescript-eslint/naming-convention
587
+ thread_id: t,
588
+ hitlResponse: null,
589
+ services: {
590
+ layerSearch: a,
591
+ fieldSearch: i,
592
+ layersAndFieldsRegistry: this.layersAndFieldsRegistry,
593
+ agentRegistry: s,
594
+ embeddingCache: o
595
+ }
596
+ }, u = {
436
597
  version: "v2",
437
598
  streamMode: "custom",
438
- configurable: {
439
- // eslint-disable-next-line @typescript-eslint/naming-convention
440
- thread_id: r,
441
- abortSignal: this.activeAbortController.signal,
442
- hitlResponse: null,
443
- services: {
444
- layerSearch: s,
445
- fieldSearch: n,
446
- layersAndFieldsRegistry: this.layersAndFieldsRegistry,
447
- agentRegistry: this.agentRegistry,
448
- embeddingCache: a
449
- }
450
- },
599
+ signal: this.activeAbortController.signal,
600
+ ...this.runtimeEventsEnabled && { callbacks: [this.createHierarchyCallback()] },
601
+ configurable: c,
451
602
  subgraphs: !0
452
- }, d = this.graph?.streamEvents(
603
+ }, g = this.graph?.streamEvents(
453
604
  {
605
+ routing: d,
454
606
  agentExecutionContext: {
455
607
  userRequest: e,
456
608
  messages: this.chatHistory,
457
609
  priorSteps: this.priorSteps,
458
- sharedState: this.sharedState
610
+ sharedState: this.sharedState,
611
+ sharedResources: this.sharedResources
459
612
  }
460
613
  },
461
- c
462
- ), o = ++this.streamEpoch;
463
- if (yield* this.pipeStream(d, o, r), this.isRunCancelled(r)) {
464
- yield { runId: r, timestamp: Date.now(), type: "cancelled", reason: "user" };
614
+ u
615
+ ), l = ++this.streamEpoch;
616
+ if (yield* this.pipeStream(g, l, t), this.isRunCancelled(t)) {
617
+ yield* this.createCancellationEvents(t);
465
618
  return;
466
619
  }
467
620
  for (; ; ) {
468
- if (this.isRunCancelled(r)) {
469
- yield { runId: r, timestamp: Date.now(), type: "cancelled", reason: "user" };
621
+ if (this.isRunCancelled(t)) {
622
+ yield* this.createCancellationEvents(t);
470
623
  return;
471
624
  }
472
- const m = (await this.graph.getState(c, { subgraphs: !0 })).tasks.find((h) => h.interrupts.length > 0)?.interrupts[0]?.value;
625
+ const m = (await this.graph.getState(u, { subgraphs: !0 })).tasks.find((y) => y.interrupts.length > 0)?.interrupts[0]?.value;
473
626
  if (!m)
474
627
  break;
475
- this.currentInterrupt = m, this.interruptHandler = new ee(this.graph, c), yield { runId: r, timestamp: Date.now(), type: "interrupt", interrupt: m };
628
+ this.currentInterrupt = m, this.interruptHandler = new fe(this.graph, u), yield* this.closeActiveRuntimeSpans(t, "interrupted"), yield { runId: t, timestamp: Date.now(), type: "interrupt", interrupt: m };
476
629
  try {
477
- const h = await this.interruptHandler.waitForUser(), S = ++this.streamEpoch;
478
- yield* this.pipeStream(h, S, r);
479
- } catch (h) {
480
- if (this.isRunCancelled(r)) {
481
- yield { runId: r, timestamp: Date.now(), type: "cancelled", reason: "user" };
630
+ const y = await this.interruptHandler.waitForUser(), I = ++this.streamEpoch;
631
+ yield* this.pipeStream(y, I, t);
632
+ } catch (y) {
633
+ if (this.isRunCancelled(t)) {
634
+ yield* this.createCancellationEvents(t);
482
635
  return;
483
636
  }
484
- if (h) {
637
+ if (y) {
485
638
  yield {
486
- runId: r,
639
+ runId: t,
487
640
  timestamp: Date.now(),
488
641
  type: "error",
489
- error: { message: h?.message }
642
+ error: { message: y?.message }
490
643
  };
491
644
  return;
492
645
  }
493
646
  }
494
647
  }
495
- if (this.isRunCancelled(r)) {
496
- yield { runId: r, timestamp: Date.now(), type: "cancelled", reason: "user" };
648
+ if (this.isRunCancelled(t)) {
649
+ yield* this.createCancellationEvents(t);
497
650
  return;
498
651
  }
499
- const u = (await this.graph.getState(c, { subgraphs: !0 })).values;
500
- if (this.isRunCancelled(r)) {
501
- yield { runId: r, timestamp: Date.now(), type: "cancelled", reason: "user" };
652
+ const h = (await this.graph.getState(u, { subgraphs: !0 })).values;
653
+ if (this.isRunCancelled(t)) {
654
+ yield* this.createCancellationEvents(t);
502
655
  return;
503
656
  }
504
- this.chatHistory = u.agentExecutionContext.messages.length ? u.agentExecutionContext.messages : this.chatHistory, this.priorSteps = u.agentExecutionContext.priorSteps?.slice(-5) ?? [], this.sharedState = u.agentExecutionContext.sharedState ?? {}, yield {
505
- runId: r,
657
+ this.chatHistory = h.agentExecutionContext.messages.length ? h.agentExecutionContext.messages : this.chatHistory, this.priorSteps = h.agentExecutionContext.priorSteps?.slice(-5) ?? [], this.sharedState = h.agentExecutionContext.sharedState ?? {}, this.sharedResources = h.agentExecutionContext.sharedResources ?? [], yield {
658
+ runId: t,
506
659
  timestamp: Date.now(),
507
660
  type: "completed",
508
- result: { content: u.finalOutputMessage }
661
+ result: { content: h.finalOutputMessage }
509
662
  };
510
663
  }
511
664
  /**
512
665
  * Start a new conversation by clearing chat history, prior steps, and shared state.
513
666
  */
514
667
  newConversation() {
515
- this.chatHistory = [], this.priorSteps = [], this.sharedState = {};
668
+ this.chatHistory = [], this.priorSteps = [], this.sharedState = {}, this.sharedResources = [];
516
669
  }
517
670
  /**
518
671
  * Generic resume for any HITL interrupt.
@@ -540,29 +693,87 @@ class x {
540
693
  this.activeRunId && (this.cancelledRunIds.add(this.activeRunId), this.activeAbortController?.abort(), ++this.streamEpoch, this.interruptHandler?.cancel());
541
694
  }
542
695
  async *pipeStream(e, r, s) {
543
- for await (const n of e) {
544
- if (this.isRunCancelled(s) || r !== this.streamEpoch)
545
- break;
546
- n.event === "on_custom_event" && n.name === "trace_message" ? yield { runId: s, timestamp: Date.now(), type: "trace", data: n.data } : n.name === "graph_ux_suggestion" && (yield {
547
- runId: s,
548
- timestamp: Date.now(),
549
- type: "ux-suggestion",
550
- suggestion: n.data
551
- });
696
+ try {
697
+ for await (const t of e) {
698
+ if (this.isRunCancelled(s) || r !== this.streamEpoch)
699
+ break;
700
+ if (this.runtimeEventsEnabled) {
701
+ const a = ye({
702
+ event: t,
703
+ runId: s,
704
+ parentSpanId: this.parentRunIds.get(t.run_id),
705
+ timestamp: Date.now()
706
+ });
707
+ a && (a.phase === "started" ? this.activeRuntimeSpans.set(a.span.id, a) : this.activeRuntimeSpans.delete(a.span.id), yield a);
708
+ }
709
+ t.event === "on_custom_event" && t.name === "trace_message" ? yield { runId: s, timestamp: Date.now(), type: "trace", data: t.data } : t.name === "graph_ux_suggestion" && (yield {
710
+ runId: s,
711
+ timestamp: Date.now(),
712
+ type: "ux-suggestion",
713
+ suggestion: t.data
714
+ });
715
+ }
716
+ } catch (t) {
717
+ if (!this.isRunCancelled(s))
718
+ throw t;
719
+ }
720
+ }
721
+ *createCancellationEvents(e) {
722
+ yield* this.closeActiveRuntimeSpans(e, "cancelled"), yield { runId: e, timestamp: Date.now(), type: "cancelled", reason: "user" };
723
+ }
724
+ *closeActiveRuntimeSpans(e, r) {
725
+ const s = Date.now(), t = [...this.activeRuntimeSpans.values()].reverse();
726
+ this.activeRuntimeSpans.clear();
727
+ for (const a of t) {
728
+ const { input: i, ...o } = a.span;
729
+ yield {
730
+ type: "runtime",
731
+ phase: r,
732
+ runId: e,
733
+ timestamp: s,
734
+ ...a.agentId && { agentId: a.agentId },
735
+ span: o
736
+ };
552
737
  }
553
738
  }
739
+ // v2 stream events omit parent run IDs, so capture them through callbacks to preserve the normalized span hierarchy.
740
+ createHierarchyCallback() {
741
+ const e = (r, s) => {
742
+ s && this.parentRunIds.set(r, s);
743
+ };
744
+ return G.fromMethods({
745
+ handleLLMStart: (r, s, t, a) => e(t, a),
746
+ handleChatModelStart: (r, s, t, a) => e(t, a),
747
+ handleChainStart: (r, s, t, a) => e(t, a),
748
+ handleToolStart: (r, s, t, a) => e(t, a),
749
+ handleRetrieverStart: (r, s, t, a) => e(t, a)
750
+ });
751
+ }
554
752
  isRunCancelled(e) {
555
753
  return this.cancelledRunIds.has(e);
556
754
  }
755
+ /**
756
+ * Creates a request-scoped registry containing all agents by default,
757
+ * or only the explicitly selected agents when filtering is requested.
758
+ */
759
+ createRequestAgentRegistry(e) {
760
+ const r = e.routing === "direct" ? [e.agentId] : e.agentIds, s = r ? r.map((a) => {
761
+ const i = this.agentRegistry.get(a);
762
+ if (!i)
763
+ throw new Error(`Agent is not registered: ${a}`);
764
+ return i;
765
+ }) : this.agentRegistry.list(), t = new S();
766
+ return s.forEach((a) => t.register(a)), t;
767
+ }
557
768
  /**
558
769
  * Disposes this instance by terminating the embeddings worker
559
770
  * and cleaning up all related resources.
560
771
  */
561
772
  dispose() {
562
- this.embeddingsWorker && (this.embeddingsWorker.terminate(), this.embeddingsWorker = void 0), this.orchestratorReady = !1;
773
+ this.sharedResources = [], this.embeddingsWorker && (this.embeddingsWorker.terminate(), this.embeddingsWorker = void 0), this.orchestratorReady = !1;
563
774
  }
564
775
  }
565
776
  export {
566
- x as O,
567
- te as g
777
+ k as O,
778
+ we as g
568
779
  };