@arcgis/ai-components 5.2.0-next.10 → 5.2.0-next.101

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 (300) 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 +121 -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 +60 -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 +157 -0
  60. package/dist/agents/tools/query/getTopFeatures/adapter.d.ts +8 -0
  61. package/dist/agents/tools/query/getTopFeatures/adapter.js +144 -0
  62. package/dist/agents/tools/query/queryFeatures/adapter.d.ts +8 -0
  63. package/dist/agents/tools/query/queryFeatures/adapter.js +130 -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/22KHSDJI.js +2 -0
  69. package/dist/cdn/2EY3BQQX.js +2 -0
  70. package/dist/cdn/{SWOXSJ62.js → 2O4DON37.js} +1 -1
  71. package/dist/cdn/34O57OGV.js +2 -0
  72. package/dist/cdn/{5W7S2RS4.js → 3UEKINYC.js} +1 -1
  73. package/dist/cdn/4OGR5QKS.js +2 -0
  74. package/dist/cdn/5FL5BTTX.js +66 -0
  75. package/dist/cdn/5HBAJ57P.js +2 -0
  76. package/dist/cdn/5K5ZY267.js +2 -0
  77. package/dist/cdn/5MK44FNO.js +2 -0
  78. package/dist/cdn/5WYRJMBW.js +2 -0
  79. package/dist/cdn/5X7EG7D2.js +2 -0
  80. package/dist/cdn/5XZLS7UO.js +2 -0
  81. package/dist/cdn/5ZFUGNRN.js +2 -0
  82. package/dist/cdn/655YIKL3.js +11 -0
  83. package/dist/cdn/6ECRQVHY.js +2 -0
  84. package/dist/cdn/6OOZSZRJ.js +2 -0
  85. package/dist/cdn/{D3TNNRP4.js → 6P44KOKX.js} +1 -1
  86. package/dist/cdn/6YYPVU7H.js +3 -0
  87. package/dist/cdn/7BCQMK6D.js +2 -0
  88. package/dist/cdn/7SRLZQVC.js +5 -0
  89. package/dist/cdn/7V6OSTFC.js +2 -0
  90. package/dist/cdn/7VAQUCBU.js +9 -0
  91. package/dist/cdn/7VUSIGEM.js +2 -0
  92. package/dist/cdn/ACJTJLZN.js +2 -0
  93. package/dist/cdn/AI6DYOKR.js +181 -0
  94. package/dist/cdn/AKD5UOVX.js +2 -0
  95. package/dist/cdn/ANRQWYU2.js +2 -0
  96. package/dist/cdn/{ZS2TZ6BF.js → AOVJ34QE.js} +1 -1
  97. package/dist/cdn/APFZY4PI.js +2 -0
  98. package/dist/cdn/B2JDVLA6.js +2 -0
  99. package/dist/cdn/BE7BRJZD.js +2 -0
  100. package/dist/cdn/{FL4W4VYN.js → BL273EGZ.js} +17 -1
  101. package/dist/cdn/C4FEETBZ.js +2 -0
  102. package/dist/cdn/C4JT4S5E.js +2 -0
  103. package/dist/cdn/CCC6LBMY.js +2 -0
  104. package/dist/cdn/{5ZZGKP7N.js → CEKOEHB3.js} +1 -1
  105. package/dist/cdn/CJMUJXPL.js +2 -0
  106. package/dist/cdn/COH3QXWG.js +4 -0
  107. package/dist/cdn/CP5BVGJU.js +2 -0
  108. package/dist/cdn/D5UFYQHN.js +44 -0
  109. package/dist/cdn/EWLXNGKH.js +208 -0
  110. package/dist/cdn/EYOWRGDP.js +2 -0
  111. package/dist/cdn/F5NIRETW.js +2 -0
  112. package/dist/cdn/FDOMMK2M.js +2 -0
  113. package/dist/cdn/FG647IP6.js +2 -0
  114. package/dist/cdn/FJO4KNOZ.js +2 -0
  115. package/dist/cdn/FUF3NAU7.js +2 -0
  116. package/dist/cdn/FXP5UIQU.js +156 -0
  117. package/dist/cdn/{T537PKP4.js → FYZATVB3.js} +1 -1
  118. package/dist/cdn/G2EGT3CF.js +6 -0
  119. package/dist/cdn/G3SF6U2U.js +2 -0
  120. package/dist/cdn/G7OMHU2B.js +2 -0
  121. package/dist/cdn/HAEFC2SJ.js +2 -0
  122. package/dist/cdn/HDACNIZF.js +2 -0
  123. package/dist/cdn/HHFNQR6Z.js +2 -0
  124. package/dist/cdn/HHUQXL3R.js +2 -0
  125. package/dist/cdn/IBZ2NEAO.js +2 -0
  126. package/dist/cdn/{FX7UOGHP.js → ICBIUFK7.js} +1 -1
  127. package/dist/cdn/ICQCK5D3.js +2 -0
  128. package/dist/cdn/IHP25JWI.js +99 -0
  129. package/dist/cdn/IJVMUS2L.js +14 -0
  130. package/dist/cdn/J6A4AS7E.js +22 -0
  131. package/dist/cdn/J6SZIQJA.js +2 -0
  132. package/dist/cdn/JCOA24UH.js +3 -0
  133. package/dist/cdn/{NE7E52YR.js → JEBRN3EU.js} +9 -3
  134. package/dist/cdn/JO5ETMPS.js +2 -0
  135. package/dist/cdn/K2R6XVK3.js +2 -0
  136. package/dist/cdn/KITIP6J2.js +2 -0
  137. package/dist/cdn/KWD2ECTM.js +2 -0
  138. package/dist/cdn/{MODWHY3R.js → LAYVGCPL.js} +6 -4
  139. package/dist/cdn/{7RCQFLPP.js → LK7ZIQW6.js} +1 -1
  140. package/dist/cdn/LLUGJKAQ.js +2 -0
  141. package/dist/cdn/MWYBF3F3.js +66 -0
  142. package/dist/cdn/{VMXLYWUK.js → MXTXJKFE.js} +1 -1
  143. package/dist/cdn/MY47B3CE.js +3 -0
  144. package/dist/cdn/NEV6OZN3.js +71 -0
  145. package/dist/cdn/NNXISHCA.js +14 -0
  146. package/dist/cdn/NZSOJ726.js +2 -0
  147. package/dist/cdn/O4NVW75A.js +2 -0
  148. package/dist/cdn/OE3GW5LE.js +2 -0
  149. package/dist/cdn/{23EQTPO3.js → OKVLGJAG.js} +1 -1
  150. package/dist/cdn/ONQ6JSBJ.js +2 -0
  151. package/dist/cdn/OX64WOEL.js +22 -0
  152. package/dist/cdn/{LQ6R5YRN.js → PQ2DPOFM.js} +1 -1
  153. package/dist/cdn/PUHRBGKB.js +2 -0
  154. package/dist/cdn/Q57QWN5W.js +2 -0
  155. package/dist/cdn/QUKNPVAF.js +2 -0
  156. package/dist/cdn/R2PQVY4O.js +2 -0
  157. package/dist/cdn/R74ZHFA6.js +2 -0
  158. package/dist/cdn/RBE55SWR.js +2 -0
  159. package/dist/cdn/RHYNE5OE.js +2 -0
  160. package/dist/cdn/RLEHNAIA.js +2 -0
  161. package/dist/cdn/RVSTAUQS.js +2 -0
  162. package/dist/cdn/{X2ZDYHCG.js → SDWWUWAF.js} +10 -5
  163. package/dist/cdn/{GTLS44GI.js → SXM4NUT5.js} +1 -1
  164. package/dist/cdn/SZ2QSSB3.js +2 -0
  165. package/dist/cdn/T4RIGOXB.js +2 -0
  166. package/dist/cdn/TCH5I5LS.js +2 -0
  167. package/dist/cdn/TEPP7YPR.js +2 -0
  168. package/dist/cdn/TMVF2W5N.js +36 -0
  169. package/dist/cdn/TPULIO6I.js +34 -0
  170. package/dist/cdn/UDRKUVZP.js +2 -0
  171. package/dist/cdn/{6YMR4QSD.js → UHEYPSOR.js} +1 -1
  172. package/dist/cdn/UHNVDALX.js +18 -0
  173. package/dist/cdn/UZLQALHY.js +2 -0
  174. package/dist/cdn/V6HOUZPZ.js +2 -0
  175. package/dist/cdn/VAXH6RUQ.js +134 -0
  176. package/dist/cdn/VLLZ2FFU.js +2 -0
  177. package/dist/cdn/VOKXKU7M.js +56 -0
  178. package/dist/cdn/VXFQANGJ.js +2 -0
  179. package/dist/cdn/WGO5SER7.js +6 -0
  180. package/dist/cdn/WJXXOKGA.js +9 -0
  181. package/dist/cdn/WKTQVBFJ.js +2 -0
  182. package/dist/cdn/{2SJAOYZT.js → WSWB3B7B.js} +1 -1
  183. package/dist/cdn/XX6GHMNR.js +2 -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/Z5HWPSZN.js +2 -0
  188. package/dist/cdn/Z5W4V7RC.js +2 -0
  189. package/dist/cdn/ZDV4K4WG.js +2 -0
  190. package/dist/cdn/ZOEMBHRF.js +2 -0
  191. package/dist/cdn/ZRVZMPFN.js +2 -0
  192. package/dist/cdn/{ZTBA5PM7.js → ZU2FHVNK.js} +1 -1
  193. package/dist/cdn/agent-utils/index.js +2 -0
  194. package/dist/cdn/agent-utils/middlewares/humanInTheLoop.js +3 -0
  195. package/dist/cdn/agent-utils/middlewares/middleware.js +2 -0
  196. package/dist/cdn/agent-utils/middlewares/trace.js +2 -0
  197. package/dist/cdn/assets/assistant/t9n/messages.en.json +1 -1
  198. package/dist/cdn/assets/assistant-interrupt/t9n/messages.en.json +1 -1
  199. package/dist/cdn/assets/assistant-interrupt-preview/t9n/messages.en.json +1 -0
  200. package/dist/cdn/assets/assistant-message/t9n/messages.en.json +1 -0
  201. package/dist/cdn/assets/assistant-message-loading/t9n/messages.en.json +1 -0
  202. package/dist/cdn/index.js +1 -1
  203. package/dist/chunks/adapter.js +1295 -2104
  204. package/dist/chunks/arcgisKnowledgeGraph.js +128 -72
  205. package/dist/chunks/arcgis_knowledge_current_lc_context.js +19 -2
  206. package/dist/chunks/arcgis_knowledge_current_map_context.js +31 -2
  207. package/dist/chunks/arcgis_knowledge_cypher_query_prompt.js +102 -0
  208. package/dist/chunks/arcgis_knowledge_summarize_result_prompt.js +116 -27
  209. package/dist/chunks/baseAgentState.js +58 -0
  210. package/dist/chunks/converterUtils.js +66 -41
  211. package/dist/chunks/dataExplorationGraph.js +131 -182
  212. package/dist/chunks/data_explore_query_prompt.js +9 -4
  213. package/dist/chunks/fetchAgentContext.js +13 -0
  214. package/dist/chunks/fetchService.js +10 -0
  215. package/dist/chunks/fieldStatistics.js +79 -0
  216. package/dist/chunks/formatFeatureAttributes.js +132 -0
  217. package/dist/chunks/generateLayerDescriptions.js +259 -282
  218. package/dist/chunks/helpGraph.js +35 -25
  219. package/dist/chunks/help_prompt.js +34 -17
  220. package/dist/chunks/index.js +11 -0
  221. package/dist/chunks/intent_prompt.js +16 -0
  222. package/dist/chunks/layerStylingGraph.js +39 -33
  223. package/dist/chunks/mergeWhereClauses.js +15 -0
  224. package/dist/chunks/navigationGraph.js +140 -116
  225. package/dist/chunks/navigation_intent_prompt.js +8 -2
  226. package/dist/chunks/orchestrator.js +444 -233
  227. package/dist/chunks/resolvePointGeometryFilter.js +92 -0
  228. package/dist/chunks/state.js +21 -27
  229. package/dist/chunks/toolCallResponse.js +14 -10
  230. package/dist/chunks/utils2.js +11 -11
  231. package/dist/components/arcgis-assistant/customElement.d.ts +82 -1
  232. package/dist/components/arcgis-assistant/customElement.js +332 -183
  233. package/dist/components/arcgis-assistant-agent/customElement.d.ts +13 -1
  234. package/dist/components/arcgis-assistant-agent/customElement.js +614 -10
  235. package/dist/components/arcgis-assistant-chat/customElement.js +22 -17
  236. package/dist/components/arcgis-assistant-data-exploration-agent/customElement.js +20 -4
  237. package/dist/components/arcgis-assistant-help-agent/customElement.js +29 -7
  238. package/dist/components/arcgis-assistant-interrupt/customElement.d.ts +4 -0
  239. package/dist/components/arcgis-assistant-interrupt/customElement.js +11 -12
  240. package/dist/components/arcgis-assistant-interrupt-preview/customElement.js +12 -8
  241. package/dist/components/arcgis-assistant-knowledge-agent/customElement.d.ts +7 -7
  242. package/dist/components/arcgis-assistant-knowledge-agent/customElement.js +40 -16
  243. package/dist/components/arcgis-assistant-layer-styling-agent/customElement.js +30 -7
  244. package/dist/components/arcgis-assistant-message/customElement.d.ts +3 -0
  245. package/dist/components/arcgis-assistant-message/customElement.js +9 -8
  246. package/dist/components/arcgis-assistant-message-block/customElement.js +1 -1
  247. package/dist/components/arcgis-assistant-message-loading/customElement.d.ts +3 -0
  248. package/dist/components/arcgis-assistant-message-loading/customElement.js +11 -10
  249. package/dist/components/arcgis-assistant-message-text/customElement.d.ts +1 -0
  250. package/dist/components/arcgis-assistant-message-text/customElement.js +12 -12
  251. package/dist/components/arcgis-assistant-navigation-agent/customElement.js +18 -4
  252. package/dist/components/arcgis-assistant-speech-input/customElement.js +34 -52
  253. package/dist/components/arcgis-assistant-user-message/customElement.d.ts +2 -0
  254. package/dist/components/arcgis-assistant-user-message/customElement.js +15 -10
  255. package/dist/docs/api.json +1 -1
  256. package/dist/docs/docs.json +1 -1
  257. package/dist/docs/vscode.html-custom-data.json +1 -1
  258. package/dist/docs/web-types.json +1 -1
  259. package/dist/loader.js +6 -6
  260. package/dist/oauth-callback.html +1 -1
  261. package/dist/orchestrator/orchestrator/orchestratorEvents.d.ts +78 -0
  262. package/dist/types/lumina.d.ts +5 -4
  263. package/dist/types/preact.d.ts +5 -4
  264. package/dist/types/react.d.ts +5 -4
  265. package/dist/types/stencil.d.ts +7 -6
  266. package/dist/utils/index.d.ts +65 -38
  267. package/dist/utils/index.js +56 -55
  268. package/package.json +32 -12
  269. package/dist/cdn/462JBSEV.js +0 -422
  270. package/dist/cdn/5QAHYX7Y.js +0 -5
  271. package/dist/cdn/64PJB5NU.js +0 -2
  272. package/dist/cdn/6AWNQHCO.js +0 -4
  273. package/dist/cdn/AXDZBBNL.js +0 -45
  274. package/dist/cdn/BIV2IPHH.js +0 -2
  275. package/dist/cdn/CCY4TSBO.js +0 -2
  276. package/dist/cdn/CTSALWEP.js +0 -2
  277. package/dist/cdn/D2N2NSRQ.js +0 -72
  278. package/dist/cdn/DOV5ZJ7M.js +0 -2
  279. package/dist/cdn/EEUCKMU7.js +0 -2
  280. package/dist/cdn/EGHBXLNG.js +0 -2
  281. package/dist/cdn/ETRWZ3MS.js +0 -108
  282. package/dist/cdn/EWI4V3GQ.js +0 -36
  283. package/dist/cdn/F2AHA4GB.js +0 -54
  284. package/dist/cdn/I6HNBTWY.js +0 -2
  285. package/dist/cdn/JBHNHHWO.js +0 -3
  286. package/dist/cdn/JOFUPKIB.js +0 -2
  287. package/dist/cdn/KMQ3SP4I.js +0 -5
  288. package/dist/cdn/KUEOKIQR.js +0 -2
  289. package/dist/cdn/LKRAPK4A.js +0 -165
  290. package/dist/cdn/NXKKG5TK.js +0 -2
  291. package/dist/cdn/OBUZ7HBN.js +0 -2
  292. package/dist/cdn/OIVRK7HT.js +0 -2
  293. package/dist/cdn/RUURNLTP.js +0 -2
  294. package/dist/cdn/RVOAPUBN.js +0 -2
  295. package/dist/cdn/TSZPHE7L.js +0 -22
  296. package/dist/cdn/VAZNJSKA.js +0 -16
  297. package/dist/cdn/VNQN5ZQO.js +0 -14
  298. package/dist/cdn/WIDTPVSU.js +0 -2
  299. package/dist/cdn/XER22VYQ.js +0 -3
  300. package/dist/cdn/YIMNOUTF.js +0 -2
@@ -1,55 +1,171 @@
1
1
  /* COPYRIGHT Esri - https://js.arcgis.com/5.2/LICENSE.txt */
2
- import { c as $ } from "../../chunks/runtime.js";
3
- import { css as C, html as l } from "lit";
4
- import I from "@arcgis/core/core/Collection.js";
5
- import { whenOnce as P, watch as A, when as x } from "@arcgis/core/core/reactiveUtils.js";
6
- import L from "@arcgis/core/portal/Portal.js";
7
- import { LitElement as R, createEvent as g, nothing as k } from "@arcgis/lumina";
8
- import { rethrowError as O } from "@arcgis/toolkit/log";
9
- import { createRef as _, ref as v } from "lit/directives/ref.js";
10
- import { u as M } from "../../chunks/useT9n.js";
11
- import { O as D } from "../../chunks/orchestrator.js";
2
+ import { c as x } from "../../chunks/runtime.js";
3
+ import { css as L, html as g } from "lit";
4
+ import T from "@arcgis/core/core/Collection.js";
5
+ import { whenOnce as R, watch as D, when as M } from "@arcgis/core/core/reactiveUtils.js";
6
+ import O from "@arcgis/core/portal/Portal.js";
7
+ import { LitElement as U, createEvent as d, nothing as _ } from "@arcgis/lumina";
8
+ import * as B from "@arcgis/toolkit/log";
9
+ import { rethrowError as z } from "@arcgis/toolkit/log";
10
+ import { createRef as w, ref as k } from "lit/directives/ref.js";
11
+ import { u as q } from "../../chunks/useT9n.js";
12
+ import { O as N } from "../../chunks/orchestrator.js";
12
13
  import "@langchain/core/callbacks/dispatch/web";
13
14
  import "@langchain/core/prompts";
14
15
  import "@langchain/openai";
15
- import T from "@arcgis/core/identity/IdentityManager.js";
16
+ import "@arcgis/core/request.js";
17
+ import V from "@arcgis/core/identity/IdentityManager.js";
18
+ import "@arcgis/toolkit/string";
19
+ import "@arcgis/core/config.js";
16
20
  import "@langchain/core/messages";
17
21
  import "@arcgis/core/layers/FeatureLayer.js";
18
22
  import "../../chunks/generateLayerDescriptions.js";
19
23
  import "@langchain/langgraph/web";
20
- import N from "@arcgis/core/core/Accessor.js";
21
- import { property as b, subclass as B } from "@arcgis/core/core/accessorSupport/decorators.js";
22
- import { g as V } from "../../chunks/utils3.js";
23
- import { g as w } from "../../chunks/slottableRequestUtils.js";
24
- const z = C`:host{display:block;width:var(--arcgis-internal-panel-width, 100%);height:var(--arcgis-internal-expand-max-height, 100%);--calcite-panel-content-bottom-space: 0}.footer-container{display:flex;flex-direction:column;flex:1 1 0;gap:var(--calcite-spacing-md)}.content-container{display:flex;flex-direction:column;flex:1 1 0;min-height:0;position:relative;overflow:auto}.suggested-prompts-container{display:flex;justify-content:center;width:100%;background:var(--calcite-panel-background-color, var(--calcite-color-background))}.suggested-prompts{display:block;padding:var(--calcite-spacing-md);max-width:100%;box-sizing:border-box}.error-notice{padding:var(--calcite-spacing-sm)}.interrupt-waiting-message{font-style:italic;color:var(--calcite-color-text-2)}`;
25
- var H = Object.defineProperty, j = Object.getOwnPropertyDescriptor, m = (c, t, e, i) => {
26
- for (var r = i > 1 ? void 0 : i ? j(t, e) : t, n = c.length - 1, s; n >= 0; n--)
27
- (s = c[n]) && (r = (i ? s(t, e, r) : s(r)) || r);
28
- return i && r && H(t, e, r), r;
29
- };
30
- const q = async (c) => await new Promise((t) => setTimeout(t, c));
31
- async function* F(c, {
32
- chunkSize: t = 5,
33
- // chars per "token"
34
- delay: e = 20
35
- // ms between chunks
36
- } = {}) {
37
- let i = 0;
38
- for (; i < c.length; )
39
- yield c.slice(i, i + t), i += t, await q(e);
24
+ import F from "@arcgis/core/core/Accessor.js";
25
+ import { property as b, subclass as j } from "@arcgis/core/core/accessorSupport/decorators.js";
26
+ import { marked as $ } from "marked";
27
+ import { g as H } from "../../chunks/utils3.js";
28
+ import { g as I } from "../../chunks/slottableRequestUtils.js";
29
+ const W = L`:host{display:block;width:var(--arcgis-internal-panel-width, 100%);height:var(--arcgis-internal-expand-max-height, 100%);--calcite-panel-content-bottom-space: 0}.footer-container{display:flex;flex-direction:column;flex:1 1 0;gap:var(--calcite-spacing-md)}.content-container{display:flex;flex-direction:column;flex:1 1 0;min-height:0;position:relative;overflow:auto}.suggested-prompts-container{display:flex;justify-content:center;width:100%;background:var(--calcite-panel-background-color, var(--calcite-color-background))}.suggested-prompts{display:block;padding:var(--calcite-spacing-md);max-width:100%;box-sizing:border-box}.error-notice{padding:var(--calcite-spacing-sm)}.interrupt-waiting-message{font-style:italic;color:var(--calcite-color-text-2)}`;
30
+ function E(o) {
31
+ return o.trim() ? $.lexer(o).filter((t) => t.type !== "space").map((t) => $.parser([t])) : [];
40
32
  }
41
- async function* E(c, t, e, i) {
42
- for await (const r of F(c)) {
33
+ class A {
34
+ constructor() {
35
+ this._stableParts = [], this._stableText = "", this._rawText = "";
36
+ }
37
+ // full streamed markdown so far
38
+ // Add one chunk and return all current segments.
39
+ push(t) {
40
+ return this._rawText += t, this._advanceStableBoundary(), this.getParts();
41
+ }
42
+ // Parse the remaining live tail. Call once at stream end.
43
+ finalize() {
44
+ const t = this._rawText.slice(this._stableText.length);
45
+ return t.trim() && (this._stableParts.push(...E(t)), this._stableText = this._rawText), this._stableParts;
46
+ }
47
+ // Get full output: stable segments + current live tail.
48
+ getParts() {
49
+ const t = this._trimIncompleteTail(this._rawText.slice(this._stableText.length)), e = t.trim() ? E(t) : [];
50
+ return [...this._stableParts, ...e];
51
+ }
52
+ reset() {
53
+ this._stableParts = [], this._stableText = "", this._rawText = "";
54
+ }
55
+ // Move parse-safe content from live tail into stable content.
56
+ _advanceStableBoundary() {
57
+ const t = this._rawText.slice(this._stableText.length), e = this._lastSafeBoundary(t);
58
+ if (e <= 0)
59
+ return;
60
+ const i = t.slice(0, e);
61
+ this._stableParts.push(...E(i)), this._stableText += i;
62
+ }
63
+ /**
64
+ * Find the last blank-line boundary that is outside code fences.
65
+ * Returns 0 if no safe boundary is available yet.
66
+ */
67
+ _lastSafeBoundary(t) {
68
+ const e = t.split(`
69
+ `);
70
+ let i = !1, r = 0, s = 0;
71
+ for (const l of e)
72
+ /^\s*(```|~~~)/u.test(l) && (i = !i), s += l.length + 1, l.trim() === "" && !i && (r = s);
73
+ return r < t.length ? r : 0;
74
+ }
75
+ /**
76
+ * Remove incomplete syntax at the end so we do not render partial markup.
77
+ * Handles:
78
+ * - open HTML tags without closing '>'
79
+ * - HTML elements missing closing tags
80
+ * - markdown links missing closing ')'
81
+ */
82
+ _trimIncompleteTail(t) {
83
+ const e = t.lastIndexOf("<");
84
+ if (e !== -1 && !t.includes(">", e))
85
+ return t.slice(0, e);
86
+ const i = this._earliestUnclosedTag(t);
87
+ if (i !== -1)
88
+ return t.slice(0, i);
89
+ const r = t.lastIndexOf("[");
90
+ if (r !== -1) {
91
+ const s = t.slice(r);
92
+ if (!/\[[^\]]*\]\([^)]*\)/u.test(s))
93
+ return t.slice(0, r);
94
+ }
95
+ return t;
96
+ }
97
+ /**
98
+ * Return the index of the earliest unclosed opening tag, or -1.
99
+ * Ignores void elements (img, br, input, etc.) and self-closing tags.
100
+ */
101
+ _earliestUnclosedTag(t) {
102
+ const e = /* @__PURE__ */ new Set([
103
+ "br",
104
+ "img",
105
+ "hr",
106
+ "input",
107
+ "meta",
108
+ "link",
109
+ "area",
110
+ "base",
111
+ "col",
112
+ "embed",
113
+ "source",
114
+ "track",
115
+ "wbr"
116
+ ]), i = /<(\/?)([a-zA-Z][\w-]*)\b[^>]*?(\/?)>/gu, r = [];
117
+ for (let s = i.exec(t); s; s = i.exec(t)) {
118
+ const [, l, a, n] = s, c = a.toLowerCase();
119
+ if (!(e.has(c) || n === "/"))
120
+ if (l === "/") {
121
+ for (let h = r.length - 1; h >= 0; h--)
122
+ if (r[h].name === c) {
123
+ r.splice(h);
124
+ break;
125
+ }
126
+ } else
127
+ r.push({ name: c, index: s.index });
128
+ }
129
+ return r.length ? r[0].index : -1;
130
+ }
131
+ }
132
+ function G(o) {
133
+ const t = new A();
134
+ return t.push(o), t.finalize();
135
+ }
136
+ const Z = async (o) => await new Promise((t) => setTimeout(t, o));
137
+ async function* J(o, { chunkSize: t = 15, delay: e = 50 } = {}) {
138
+ const i = new A();
139
+ for (let r = 0; r < o.length; r += t)
140
+ yield i.push(o.slice(r, r + t)), await Z(e);
141
+ yield i.finalize();
142
+ }
143
+ var K = Object.defineProperty, Q = Object.getOwnPropertyDescriptor, m = (o, t, e, i) => {
144
+ for (var r = i > 1 ? void 0 : i ? Q(t, e) : t, s = o.length - 1, l; s >= 0; s--)
145
+ (l = o[s]) && (r = (i ? l(t, e, r) : l(r)) || r);
146
+ return i && r && K(t, e, r), r;
147
+ };
148
+ const S = (o) => !o || typeof o != "object" ? !1 : o.name === "AbortError";
149
+ async function* C(o, t, e, i, r = !1) {
150
+ if (r) {
43
151
  if (i?.aborted) {
44
152
  yield { type: "cancelled", log: e, runId: t };
45
153
  return;
46
154
  }
47
- yield { type: "block-data", blockType: "text", data: { content: r }, runId: t };
155
+ yield { type: "block-data", blockType: "text", data: { parts: G(o) }, runId: t };
156
+ return;
157
+ }
158
+ for await (const s of J(o)) {
159
+ if (i?.aborted) {
160
+ yield { type: "cancelled", log: e, runId: t };
161
+ return;
162
+ }
163
+ yield { type: "block-data", blockType: "text", data: { parts: s }, runId: t };
48
164
  }
49
165
  }
50
- let d = class extends N {
51
- constructor(c) {
52
- super(c), this.view = null, this.loading = !1, this.processing = !1, this.processingStep = "";
166
+ let p = class extends F {
167
+ constructor(o) {
168
+ super(o), this.view = null, this.streamingDisabled = !1, this.runtimeEventsEnabled = !1, this.loading = !1, this.processing = !1, this.processingStep = "";
53
169
  }
54
170
  async load() {
55
171
  this._set("loading", !0);
@@ -63,14 +179,15 @@ let d = class extends N {
63
179
  this.orchestrator?.dispose(), super.destroy();
64
180
  }
65
181
  async _initialize() {
66
- this.removeHandles(), await Promise.all([this.portal.load(), this.view?.when()]), this.view && await P(() => !this.view.updating), this._set(
182
+ this.removeHandles(), await Promise.all([this.portal.load(), this.view?.when()]), this.view && await R(() => !this.view.updating), this._set(
67
183
  "orchestrator",
68
- await D.init({
184
+ await N.init({
69
185
  agents: [...this.agents],
186
+ runtimeEventsEnabled: this.runtimeEventsEnabled,
70
187
  view: this.view ?? void 0
71
188
  })
72
189
  ), this.addHandles([
73
- A(
190
+ D(
74
191
  () => [this.view, this.agents],
75
192
  () => {
76
193
  this._initialize();
@@ -81,85 +198,95 @@ let d = class extends N {
81
198
  clearChatHistory() {
82
199
  this.orchestrator?.newConversation();
83
200
  }
84
- async *ask(c, t) {
201
+ async *ask(o, t, e) {
85
202
  if (!this.orchestrator)
86
203
  throw new Error("Orchestrator not initialized yet.");
87
204
  this._set("processing", !0), this._set("processingStep", "");
88
- const e = [];
89
- let i;
205
+ const i = [];
206
+ let r, s = "pending";
90
207
  try {
91
- const r = this.orchestrator.ask(c);
92
- for await (const n of r) {
93
- const s = n.runId;
94
- switch (n.type) {
208
+ const l = this.orchestrator.ask(o, t);
209
+ for await (const a of l)
210
+ switch (s = a.runId, a.type) {
211
+ case "runtime": {
212
+ yield { type: "runtime", event: a, runId: s };
213
+ break;
214
+ }
95
215
  case "trace": {
96
- this._set("processingStep", n.data.text), e.push(n.data.text);
216
+ this._set("processingStep", a.data.text), i.push(a.data.text);
97
217
  break;
98
218
  }
99
219
  case "completed": {
100
220
  this._set("processing", !1), this._set("processingStep", "");
101
- const a = n.result, o = !!a.content.length, h = !!i?.length;
102
- if (!o && !h) {
103
- yield { type: "completed", error: "No response received.", log: e, runId: s };
221
+ const n = a.result, c = !!n.content.length, h = !!r?.length;
222
+ if (!c && !h) {
223
+ yield { type: "completed", error: "No response received.", log: i, runId: s };
104
224
  return;
105
225
  }
106
- const p = a.content;
107
- if (yield { type: "block-start", blockType: "text", runId: s }, yield* E(p, s, e, t), yield { type: "block-end", blockType: "text", runId: s }, h)
108
- for (const f of i) {
109
- if (t?.aborted) {
110
- yield { type: "cancelled", log: e, runId: s };
226
+ const u = n.content;
227
+ if (yield { type: "block-start", blockType: "text", runId: s }, yield* C(u, s, i, e, this.streamingDisabled), yield { type: "block-end", blockType: "text", runId: s }, h)
228
+ for (const y of r) {
229
+ if (e?.aborted) {
230
+ yield { type: "cancelled", log: i, runId: s };
111
231
  return;
112
232
  }
113
- const { type: u, data: y } = f;
114
- if (yield { type: "block-start", blockType: u, runId: s }, u === "text") {
115
- const S = typeof y?.content == "string" ? y.content : "";
116
- yield* E(S, s, e, t);
233
+ const { type: f, data: v } = y;
234
+ if (yield { type: "block-start", blockType: f, runId: s }, f === "text") {
235
+ const P = typeof v?.content == "string" ? v.content : "";
236
+ yield* C(P, s, i, e, this.streamingDisabled);
117
237
  } else
118
- yield { type: "block-data", blockType: u, data: y, runId: s };
119
- yield { type: "block-end", blockType: u, runId: s };
238
+ yield { type: "block-data", blockType: f, data: v, runId: s };
239
+ yield { type: "block-end", blockType: f, runId: s };
120
240
  }
121
- yield { type: "completed", response: p, blocks: i, log: e, runId: s };
241
+ yield { type: "completed", response: u, blocks: r, log: i, runId: s };
122
242
  return;
123
243
  }
124
244
  case "ux-suggestion": {
125
- const a = n.suggestion;
126
- i = i ? [...i, a] : [a];
245
+ const n = a.suggestion;
246
+ r = r ? [...r, n] : [n];
127
247
  break;
128
248
  }
129
249
  case "interrupt": {
130
- const { kind: a, message: o, metadata: h } = n.interrupt, p = Array.isArray(h) ? h.filter((u) => typeof u == "string") : [], f = (() => {
131
- switch (a) {
250
+ const { kind: n, message: c, metadata: h } = a.interrupt, u = Array.isArray(h) ? h.filter((f) => typeof f == "string") : [], y = (() => {
251
+ switch (n) {
132
252
  case "booleanChoice":
133
- return { type: "boolean-choice", message: o, options: p };
253
+ return { type: "boolean-choice", message: c, options: u };
134
254
  case "singleSelection":
135
- return { type: "single-select", message: o, options: p };
255
+ return { type: "single-select", message: c, options: u };
136
256
  case "multipleSelection":
137
- return { type: "multi-select", message: o, options: p };
257
+ return { type: "multi-select", message: c, options: u };
138
258
  case "textInput":
139
- return { type: "text-input", message: o };
259
+ return { type: "text-input", message: c };
140
260
  default:
141
- return { type: a, message: o, options: p };
261
+ return { type: n, message: c, options: u };
142
262
  }
143
263
  })();
144
- this._set("processingStep", "Waiting for user input..."), yield { type: "interrupt", payload: f, runId: s };
264
+ this._set("processingStep", "Waiting for user input..."), yield { type: "interrupt", payload: y, runId: s };
145
265
  break;
146
266
  }
147
267
  case "cancelled": {
148
- yield { type: "cancelled", log: e, runId: s };
268
+ yield { type: "cancelled", log: i, runId: s };
149
269
  return;
150
270
  }
151
271
  case "error": {
152
- yield { type: "completed", error: n.error.message, log: e, runId: s };
272
+ if (e?.aborted || S(a.error)) {
273
+ yield { type: "cancelled", log: i, runId: s };
274
+ return;
275
+ }
276
+ yield { type: "completed", error: a.error.message, log: i, runId: s };
153
277
  return;
154
278
  }
155
279
  default: {
156
- console.warn("Unknown event type:", n);
280
+ console.warn("Unknown event type:", a);
157
281
  break;
158
282
  }
159
283
  }
284
+ } catch (l) {
285
+ if (e?.aborted || S(l)) {
286
+ yield { type: "cancelled", log: i, runId: s };
287
+ return;
160
288
  }
161
- } catch (r) {
162
- console.warn("Error during message processing:", r), yield { type: "completed", error: "An error occurred during message processing.", log: e, runId: "error" };
289
+ console.warn("Error during message processing:", l), yield { type: "completed", error: "An error occurred during message processing.", log: i, runId: "error" };
163
290
  return;
164
291
  } finally {
165
292
  this._set("processing", !1);
@@ -171,34 +298,40 @@ let d = class extends N {
171
298
  };
172
299
  m([
173
300
  b({ readOnly: !0 })
174
- ], d.prototype, "orchestrator", 2);
301
+ ], p.prototype, "orchestrator", 2);
302
+ m([
303
+ b()
304
+ ], p.prototype, "agents", 2);
305
+ m([
306
+ b()
307
+ ], p.prototype, "portal", 2);
175
308
  m([
176
309
  b()
177
- ], d.prototype, "agents", 2);
310
+ ], p.prototype, "view", 2);
178
311
  m([
179
312
  b()
180
- ], d.prototype, "portal", 2);
313
+ ], p.prototype, "streamingDisabled", 2);
181
314
  m([
182
315
  b()
183
- ], d.prototype, "view", 2);
316
+ ], p.prototype, "runtimeEventsEnabled", 2);
184
317
  m([
185
318
  b({ readOnly: !0 })
186
- ], d.prototype, "loading", 2);
319
+ ], p.prototype, "loading", 2);
187
320
  m([
188
321
  b({ readOnly: !0 })
189
- ], d.prototype, "processing", 2);
322
+ ], p.prototype, "processing", 2);
190
323
  m([
191
324
  b({ readOnly: !0 })
192
- ], d.prototype, "processingStep", 2);
193
- d = m([
194
- B("OrchestratorController")
195
- ], d);
196
- const G = "Embeddings resource 'embeddings-v01.json' not found in the webmap portal item.", U = "Embeddings not found for this web map.", W = "https://developers.arcgis.com/javascript/latest/agentic-apps/ai-webmap-setup/#embeddings";
197
- class Y extends R {
325
+ ], p.prototype, "processingStep", 2);
326
+ p = m([
327
+ j("OrchestratorController")
328
+ ], p);
329
+ const X = "Embeddings resource 'embeddings-v01.json' not found in the webmap portal item.", Y = "Embeddings not found for this web map.", tt = "https://developers.arcgis.com/javascript/latest/agentic-apps/ai-webmap-setup/#embeddings";
330
+ class et extends U {
198
331
  constructor() {
199
- super(...arguments), this._messages = M({ blocking: !0 }), this.#t = _(), this.#n = _(), this.#s = _(), this.#e = null, this.#o = /* @__PURE__ */ new Map(), this.#i = L.getDefault(), this.#r = (t) => {
332
+ super(...arguments), this._messages = q({ blocking: !0 }), this.#t = w(), this.#o = w(), this.#s = w(), this.#e = null, this.#r = /* @__PURE__ */ new Map(), this.#i = O.getDefault(), this.#a = (t) => {
200
333
  t.stopPropagation(), this.cancelInterrupt();
201
- }, this.#a = (t) => {
334
+ }, this.#n = (t) => {
202
335
  t.stopPropagation();
203
336
  const e = t.detail;
204
337
  this.submitInterrupt(e);
@@ -216,46 +349,35 @@ class Y extends R {
216
349
  t.stopPropagation();
217
350
  const e = t.detail;
218
351
  this.arcgisFeedback.emit(e);
219
- }, this.#p = (t) => {
352
+ }, this.#g = (t) => {
220
353
  t.stopPropagation();
221
354
  const e = t.detail;
222
355
  this._inputValue = e.prompt, this.arcgisPromptSelect.emit(e);
223
- }, this.#g = (t) => {
356
+ }, this.#u = (t) => {
224
357
  this.arcgisSlottableRequest.emit(t.detail);
225
- }, this._orchestratorController = null, this._interrupt = null, this._interruptDetails = [], this._error = null, this._inputValue = "", this._isAnswering = !1, this._canceling = !1, this.messages = new I([]), this.referenceElement = null, this.suggestedPrompts = [], this.feedbackEnabled = !1, this.keepSuggestedPrompts = !1, this.logEnabled = !1, this.copyEnabled = !1, this.voiceInputEnabled = !1, this.readAloudEnabled = !1, this.assistantAvatarEnabled = !1, this.arcgisCancel = g(), this.arcgisError = g(), this.arcgisFeedback = g(), this.arcgisInterrupt = g(), this.arcgisInterruptCancel = g(), this.arcgisInterruptSubmit = g(), this.arcgisPromptSelect = g(), this.arcgisReady = g(), this.arcgisSubmit = g(), this.arcgisSlottableRequest = g({ bubbles: !1, composed: !1 }), this.arcgisResponse = g();
358
+ }, this._orchestratorController = null, this._interrupt = null, this._interruptDetails = [], this._error = null, this._inputValue = "", this._isAnswering = !1, this._canceling = !1, this.messages = new T([]), this.referenceElement = null, this.suggestedPrompts = [], this.feedbackEnabled = !1, this.keepSuggestedPrompts = !1, this.streamingDisabled = !1, this.runtimeEventsEnabled = !1, this.logEnabled = !1, this.copyEnabled = !1, this.voiceInputEnabled = !1, this.readAloudEnabled = !1, this.assistantAvatarEnabled = !1, this.userAvatarEnabled = !1, this.arcgisCancel = d(), this.arcgisError = d(), this.arcgisFeedback = d(), this.arcgisInterrupt = d(), this.arcgisInterruptCancel = d(), this.arcgisInterruptSubmit = d(), this.arcgisPromptSelect = d(), this.arcgisReady = d(), this.arcgisResponse = d(), this.arcgisRuntime = d({ bubbles: !1, composed: !1 }), this.arcgisSlottableRequest = d({ bubbles: !1, composed: !1 }), this.arcgisSubmit = d();
226
359
  }
227
360
  static {
228
- this.properties = { _orchestratorController: 16, _interrupt: 16, _interruptDetails: 16, _error: 16, _inputValue: 16, _isAnswering: 16, _canceling: 16, _user: 16, awaitingResponse: 32, awaitingResponseStep: 32, interrupt: 32, messages: 0, orchestrator: 32, entryMessage: 1, heading: 1, description: 1, referenceElement: 1, suggestedPrompts: 0, feedbackEnabled: 5, keepSuggestedPrompts: 5, logEnabled: 5, copyEnabled: 5, voiceInputEnabled: 5, readAloudEnabled: 5, assistantAvatarEnabled: 5 };
361
+ this.properties = { _orchestratorController: 16, _interrupt: 16, _interruptDetails: 16, _error: 16, _inputValue: 16, _isAnswering: 16, _signedInUserId: 16, _canceling: 16, _isSignedIn: 16, _user: 16, awaitingResponse: 32, awaitingResponseStep: 32, interrupt: 32, messages: 0, orchestrator: 32, entryMessage: 1, heading: 1, description: 1, referenceElement: 1, alwaysUseAgentId: 1, allowedAgentIds: 0, suggestedPrompts: 0, feedbackEnabled: 5, keepSuggestedPrompts: 5, streamingDisabled: 5, runtimeEventsEnabled: 5, logEnabled: 5, copyEnabled: 5, voiceInputEnabled: 5, readAloudEnabled: 5, assistantAvatarEnabled: 5, userAvatarEnabled: 5 };
229
362
  }
230
363
  static {
231
- this.styles = z;
364
+ this.styles = W;
232
365
  }
233
366
  #t;
234
- #n;
367
+ #o;
235
368
  #s;
236
369
  #e;
237
- #o;
238
- #i;
239
370
  #r;
371
+ #i;
240
372
  #a;
373
+ #n;
241
374
  #l;
242
375
  #c;
243
376
  #h;
244
- #p;
245
377
  #g;
246
- async #d() {
247
- try {
248
- const t = V(this.el, this.referenceElement);
249
- await t?.componentOnReady();
250
- const e = [...this.#o.values()];
251
- return e.length ? (this._orchestratorController = new d({
252
- agents: e,
253
- portal: this.#i,
254
- view: t?.view
255
- }), await this._orchestratorController.load(), !0) : (this._error = "No agents found.", !1);
256
- } catch (t) {
257
- return this._error = t?.message ?? "Error initializing orchestrator.", O(this)(t), !1;
258
- }
378
+ #u;
379
+ get _isSignedIn() {
380
+ return !!this.#i?.user || !!this._signedInUserId;
259
381
  }
260
382
  get _user() {
261
383
  return this.#i?.user?.fullName || this.#i?.user?.username;
@@ -272,14 +394,17 @@ class Y extends R {
272
394
  get orchestrator() {
273
395
  return this._orchestratorController?.orchestrator;
274
396
  }
275
- async clearChatHistory() {
276
- this._reset(), this._orchestratorController?.clearChatHistory();
277
- }
278
397
  cancelInterrupt() {
279
398
  this.arcgisInterruptCancel.emit(), this.orchestrator?.cancelInterrupt(), this._interrupt = null;
280
399
  }
400
+ async clearChatHistory() {
401
+ this._reset(), this._orchestratorController?.clearChatHistory();
402
+ }
281
403
  register(t) {
282
- this.#o.set(t.agent.id, t);
404
+ this.#r.set(t.agent.id, t), this._orchestratorController && this.#d();
405
+ }
406
+ submitInterrupt(t) {
407
+ this.arcgisInterruptSubmit.emit(t), this._interrupt && (this._interruptDetails = [...this._interruptDetails, { interrupt: this._interrupt, response: t }]), this.orchestrator?.resumeInterrupt(t), this._interrupt = null;
283
408
  }
284
409
  async submitMessage(t) {
285
410
  const e = t.trim();
@@ -290,140 +415,164 @@ class Y extends R {
290
415
  content: e
291
416
  }), !this._orchestratorController))
292
417
  return;
293
- this.#e = new AbortController();
294
- const i = this._orchestratorController.ask(e, this.#e?.signal);
295
- for await (const r of i) {
296
- const n = r.runId, s = this.messages.at(-1);
297
- switch (r.type) {
418
+ this.#e = new AbortController(), this._orchestratorController.streamingDisabled = this.streamingDisabled;
419
+ const i = this.alwaysUseAgentId ? { routing: "direct", agentId: this.alwaysUseAgentId } : { routing: "auto", agentIds: this.allowedAgentIds }, r = this._orchestratorController.ask(e, i, this.#e?.signal);
420
+ for await (const s of r) {
421
+ const l = s.runId, a = this.messages.at(-1);
422
+ switch (s.type) {
423
+ case "runtime":
424
+ this.arcgisRuntime.emit(s.event);
425
+ break;
298
426
  case "block-start": {
299
427
  this._isAnswering = !0;
300
- const a = { type: r.blockType, isPending: !0 };
301
- if (s?.role === "assistant" && s.id === n) {
302
- const o = [...s.blocks ?? [], a];
303
- this.messages.splice(-1, 1, { ...s, blocks: o });
428
+ const n = { type: s.blockType, isPending: !0 };
429
+ if (a?.role === "assistant" && a.id === l) {
430
+ const c = [...a.blocks ?? [], n];
431
+ this.messages.splice(-1, 1, { ...a, blocks: c });
304
432
  } else
305
433
  this.messages.push({
306
434
  role: "assistant",
307
- blocks: [a],
308
- id: n,
435
+ blocks: [n],
436
+ id: l,
309
437
  isStreaming: !0,
310
438
  interrupts: this._interruptDetails
311
439
  }), this._interruptDetails = [];
312
440
  break;
313
441
  }
314
442
  case "block-data": {
315
- if (s?.role !== "assistant" || s?.id !== n)
443
+ if (a?.role !== "assistant" || a?.id !== l)
316
444
  break;
317
- const a = [...s.blocks ?? []], o = a[a.length - 1], { blockType: h, data: p } = r;
318
- if (o?.type !== h || !o.isPending)
445
+ const n = [...a.blocks ?? []], c = n[n.length - 1], { blockType: h, data: u } = s;
446
+ if (c?.type !== h || !c.isPending)
319
447
  break;
320
- if (h === "text") {
321
- const f = typeof o.data?.content == "string" ? o.data.content : "", u = typeof p?.content == "string" ? p.content : "";
322
- a[a.length - 1] = { ...o, data: { ...o.data, content: f + u } };
323
- } else
324
- a[a.length - 1] = { ...o, data: { ...o.data, ...p ?? {} } };
325
- this.messages.splice(-1, 1, { ...s, blocks: a });
448
+ h === "text" ? n[n.length - 1] = {
449
+ ...c,
450
+ data: {
451
+ ...c.data,
452
+ parts: u?.parts
453
+ }
454
+ } : n[n.length - 1] = { ...c, data: { ...c.data, ...u ?? {} } }, this.messages.splice(-1, 1, { ...a, blocks: n });
326
455
  break;
327
456
  }
328
457
  case "block-end": {
329
- if (s?.role !== "assistant" || s?.id !== n)
458
+ if (a?.role !== "assistant" || a?.id !== l)
330
459
  break;
331
- const a = [...s.blocks ?? []], o = a[a.length - 1];
332
- if (o?.type !== r.blockType || !o.isPending)
460
+ const n = [...a.blocks ?? []], c = n[n.length - 1];
461
+ if (c?.type !== s.blockType || !c.isPending)
333
462
  break;
334
- const h = o;
335
- a[a.length - 1] = { ...h, data: { ...h.data }, isPending: !1 }, this.messages.splice(-1, 1, { ...s, blocks: a });
463
+ const h = c;
464
+ n[n.length - 1] = { ...h, data: { ...h.data }, isPending: !1 }, this.messages.splice(-1, 1, { ...a, blocks: n });
336
465
  break;
337
466
  }
338
467
  case "completed":
339
- r.error ? (this.messages.push({
468
+ s.error ? (this.messages.push({
340
469
  role: "assistant",
341
- log: r.log,
342
- error: r.error,
343
- id: n,
470
+ log: s.log,
471
+ error: s.error,
472
+ id: l,
344
473
  interrupts: this._interruptDetails
345
- }), this._interruptDetails = []) : s?.role === "assistant" && s.id === n && this.messages.splice(-1, 1, {
346
- ...s,
347
- content: r.response,
348
- blocks: s.blocks?.map((a) => ({ ...a, isPending: !1 })) ?? [],
474
+ }), this._interruptDetails = []) : a?.role === "assistant" && a.id === l && this.messages.splice(-1, 1, {
475
+ ...a,
476
+ content: s.response,
477
+ blocks: a.blocks?.map((n) => ({ ...n, data: { ...n.data }, isPending: !1 })) ?? [],
349
478
  isStreaming: !1,
350
- log: r.log
479
+ log: s.log
351
480
  }), this._isAnswering = !1, this.#e = null, this._canceling = !1;
352
481
  break;
353
482
  case "interrupt":
354
- this._interrupt = { ...r.payload, id: n }, this.arcgisInterrupt.emit(this._interrupt);
483
+ this._interrupt = { ...s.payload, id: l }, this.arcgisInterrupt.emit(this._interrupt);
355
484
  break;
356
485
  case "cancelled":
357
- s?.role === "assistant" && s.id === n ? this.messages.splice(-1, 1, {
358
- ...s,
359
- blocks: s.blocks?.filter((a) => a.type === "text" || !a.isPending) ?? [],
486
+ a?.role === "assistant" && a.id === l ? this.messages.splice(-1, 1, {
487
+ ...a,
488
+ blocks: a.blocks?.filter((n) => n.type === "text" || !n.isPending) ?? [],
360
489
  isStreaming: !1,
361
- log: r.log,
362
- error: "(Stopped by user)"
363
- // TODO: use strings from t9n
490
+ log: s.log,
491
+ error: `(${this._messages.stoppedByUserLabel})`
364
492
  }) : (this.messages.push({
365
493
  role: "assistant",
366
- log: r.log,
367
- error: "(Stopped by user)",
368
- // TODO: use strings from t9n
369
- id: n,
494
+ log: s.log,
495
+ error: `(${this._messages.stoppedByUserLabel})`,
496
+ id: l,
370
497
  interrupts: this._interruptDetails
371
498
  }), this._interruptDetails = []), this._isAnswering = !1, this.#e = null, this._canceling = !1;
372
499
  break;
373
500
  }
374
501
  }
375
502
  }
376
- submitInterrupt(t) {
377
- this.arcgisInterruptSubmit.emit(t), this._interrupt && (this._interruptDetails = [...this._interruptDetails, { interrupt: this._interrupt, response: t }]), this.orchestrator?.resumeInterrupt(t), this._interrupt = null;
503
+ unregister(t) {
504
+ this.#r.delete(t), this._orchestratorController && this.#d();
378
505
  }
379
506
  load() {
380
507
  this.manager.onLifecycle(this._reset.bind(this));
381
508
  }
382
509
  loaded() {
383
510
  this.manager.onLifecycle(() => {
384
- this.#t.value?.addEventListener("arcgisPromptSelect", this.#p), this.#t.value?.addEventListener("arcgisSubmit", this.#l), this.#t.value?.addEventListener("arcgisCancel", this.#c), this.#t.value?.addEventListener("arcgisFeedback", this.#h);
385
- const t = x(() => !!this._interrupt && !!this.#s.value, () => {
511
+ this.#t.value?.addEventListener("arcgisPromptSelect", this.#g), this.#t.value?.addEventListener("arcgisSubmit", this.#l), this.#t.value?.addEventListener("arcgisCancel", this.#c), this.#t.value?.addEventListener("arcgisFeedback", this.#h);
512
+ const t = M(() => !!this._interrupt && !!this.#s.value, () => {
386
513
  const i = this.#s.value;
387
- i.removeEventListener("arcgisSubmit", this.#a), i.removeEventListener("arcgisCancel", this.#r), i.addEventListener("arcgisSubmit", this.#a, { once: !0 }), i.addEventListener("arcgisCancel", this.#r, { once: !0 });
514
+ i.removeEventListener("arcgisSubmit", this.#n), i.removeEventListener("arcgisCancel", this.#a), i.addEventListener("arcgisSubmit", this.#n, { once: !0 }), i.addEventListener("arcgisCancel", this.#a, { once: !0 });
388
515
  }), e = this.messages.on("after-add", (i) => {
389
516
  const r = i.item;
390
517
  r.role === "assistant" && (r.error || r.content) && this.arcgisResponse.emit(r);
391
518
  });
392
519
  return queueMicrotask(() => {
393
- this.#d().then((i) => {
394
- i ? this.arcgisReady.emit() : this._error && this.arcgisError.emit(new Error(this._error));
395
- });
520
+ this.#p();
396
521
  }), () => {
397
- t.remove(), e.remove(), this.#t.value?.removeEventListener("arcgisPromptSelect", this.#p), this.#s.value?.removeEventListener("arcgisSubmit", this.#a), this.#s.value?.removeEventListener("arcgisCancel", this.#r), this.#t.value?.removeEventListener("arcgisSubmit", this.#l), this.#t.value?.removeEventListener("arcgisCancel", this.#c), this.#t.value?.removeEventListener("arcgisFeedback", this.#h), this._orchestratorController?.destroy(), this._orchestratorController = null;
522
+ t.remove(), e.remove(), this.#t.value?.removeEventListener("arcgisPromptSelect", this.#g), this.#s.value?.removeEventListener("arcgisSubmit", this.#n), this.#s.value?.removeEventListener("arcgisCancel", this.#a), this.#t.value?.removeEventListener("arcgisSubmit", this.#l), this.#t.value?.removeEventListener("arcgisCancel", this.#c), this.#t.value?.removeEventListener("arcgisFeedback", this.#h), this._orchestratorController?.destroy(), this._orchestratorController = null;
398
523
  };
399
524
  });
400
525
  }
526
+ willUpdate(t) {
527
+ this.hasUpdated && t.has("runtimeEventsEnabled") && this._orchestratorController && (this._orchestratorController.destroy(), this._orchestratorController = null, this.#p());
528
+ }
529
+ async #d() {
530
+ try {
531
+ this._error = null;
532
+ const t = H(this.el, this.referenceElement);
533
+ await t?.componentOnReady();
534
+ const e = [...this.#r.values()];
535
+ return e.length ? (this._orchestratorController?.destroy(), this._orchestratorController = new p({
536
+ agents: e,
537
+ portal: this.#i,
538
+ runtimeEventsEnabled: this.runtimeEventsEnabled,
539
+ streamingDisabled: this.streamingDisabled,
540
+ view: t?.view
541
+ }), await this._orchestratorController.load(), this.requestUpdate(), !0) : (this._error = this._messages.noAgentsFoundMessage, !1);
542
+ } catch (t) {
543
+ return this._error = t?.message ?? this._messages.orchestratorInitializationErrorMessage, z(this)(t), !1;
544
+ }
545
+ }
546
+ async #p() {
547
+ await this.#d() ? this.arcgisReady.emit() : this._error && this.arcgisError.emit(new Error(this._error));
548
+ }
401
549
  _reset() {
402
- this._orchestratorController?.cancel(), this.#e?.abort(), this._interrupt = null, this.messages.removeAll(), this._error = null, this._inputValue = "";
550
+ this._orchestratorController?.cancel(), this.#e?.abort(), this._interrupt = null, this.messages.removeAll(), this._error = null, this._inputValue = "", this._signedInUserId = void 0;
403
551
  }
404
552
  _renderEntryMessage() {
405
- return !this._user ? this._renderSignInNotice() : this._error ? this._renderErrorNotice() : this.entryMessage ? this.messages.length > 0 ? null : l`<calcite-notice open kind=brand closable icon width=full><div slot=message>${this.entryMessage}</div></calcite-notice>` : l`<slot name=entry-message></slot>`;
553
+ return this._isSignedIn ? this._error ? this._renderErrorNotice() : this.entryMessage ? this.messages.length > 0 ? null : g`<calcite-notice open kind=brand closable icon width=full><div slot=message>${this.entryMessage}</div></calcite-notice>` : g`<slot name=entry-message></slot>` : this._renderSignInNotice();
406
554
  }
407
555
  _renderSignInNotice() {
408
556
  const t = this.#i;
409
- return l`<calcite-notice slot=entry-message open kind=brand icon width=full><div slot=message>You need to sign in to use the assistant chat.</div>${t ? l`<calcite-link slot=link @click=${async () => {
557
+ return g`<calcite-notice slot=entry-message open kind=brand icon width=full><div slot=message>${this._messages.signInRequiredMessage}</div>${t ? g`<calcite-link slot=link @click=${async () => {
410
558
  try {
411
- await T.getCredential(t.url), this._error = null, await this.#d(), this.arcgisReady.emit();
559
+ const e = await V.getCredential(`${t.url}/sharing`);
560
+ this._signedInUserId = e.userId, this._error = null, this.requestUpdate(), await this.#p();
412
561
  } catch (e) {
413
- console.error("Error signing in:", e);
562
+ this._error = e?.message ?? this._messages.signInErrorMessage, this.arcgisError.emit(new Error(this._error)), B.log("error", this, "Error signing in:", { detail: { error: e } });
414
563
  }
415
- }} target=_blank title="Sign in to ArcGIS Online">Sign in</calcite-link>` : l`<div slot=link>No portal information available</div>`}</calcite-notice>`;
564
+ }} target=_blank title=${this._messages.signInToArcGISOnlineLabel ?? _}>${this._messages.signInLabel}</calcite-link>` : g`<div slot=link>${this._messages.noPortalInformationMessage}</div>`}</calcite-notice>`;
416
565
  }
417
566
  _renderErrorNotice() {
418
- return this._error ? l`<calcite-notice slot=entry-message open kind=brand icon width=full>${this._error === G ? l`<div slot=message>${U}</div><calcite-link slot=link .href=${W} target=_blank title="Learn about web map embeddings">Read more</calcite-link>` : l`<div slot=message>${this._error}</div>`}</calcite-notice>` : null;
567
+ return this._error ? g`<calcite-notice slot=entry-message open kind=brand icon width=full>${this._error === X ? g`<div slot=message>${Y}</div><calcite-link slot=link .href=${tt} target=_blank title=${this._messages.learnAboutWebMapEmbeddingsLabel ?? _}>${this._messages.readMoreLabel}</calcite-link>` : g`<div slot=message>${this._error}</div>`}</calcite-notice>` : null;
419
568
  }
420
569
  render() {
421
- return l`<calcite-panel .loading=${!this._orchestratorController && !this._error || this._orchestratorController?.loading} .heading=${this.heading ?? this._messages.assistantLabel} .description=${this.description} ${v(this.#t)}><slot name=header-actions-start slot=header-actions-start></slot><slot name=header-actions-end slot=header-actions-end></slot><div class="content-container"><arcgis-assistant-chat .loading=${this.awaitingResponse} .messages=${this.messages} .interrupt=${this._interrupt}><slot name=message-starter slot=message-starter></slot><slot name=messages slot=messages>${this.messages.map((t) => t.role === "assistant" ? l`<arcgis-assistant-message .message=${t} .feedbackEnabled=${this.feedbackEnabled} .logEnabled=${this.logEnabled} .copyEnabled=${this.copyEnabled} .readAloudEnabled=${this.readAloudEnabled} @arcgisSlottableRequest=${this.#g} .assistantAvatarEnabled=${this.assistantAvatarEnabled}>${t.blocks?.map((e, i) => l`<slot name=${w(t.id, i) ?? k} slot=${w(t.id, i) ?? k}><arcgis-assistant-message-block .block=${e}></arcgis-assistant-message-block></slot>`)}</arcgis-assistant-message>` : l`<arcgis-assistant-user-message .message=${t} .user=${this._user}></arcgis-assistant-user-message>`)}</slot>${this._interrupt ? l`<div slot=message-loading><div class="interrupt-waiting-message">waiting for user input...</div> // TODO: use t9n strings</div>` : l`<slot name=message-loading slot=message-loading><arcgis-assistant-message-loading .loading=${this.awaitingResponse} .loadingMessage=${this.awaitingResponseStep} .assistantAvatarEnabled=${this.assistantAvatarEnabled} .interrupts=${this._interruptDetails}></arcgis-assistant-message-loading></slot>`}</arcgis-assistant-chat></div>${this._interrupt ? l`<arcgis-assistant-interrupt slot=content-bottom .type=${this._interrupt.type} .message=${this._interrupt.message} .options=${this._interrupt.options} ${v(this.#s)}></arcgis-assistant-interrupt>` : this.suggestedPrompts?.length ? l`<div class="suggested-prompts-container" slot=content-bottom><arcgis-assistant-suggested-prompts class="suggested-prompts" .prompts=${this.suggestedPrompts}></arcgis-assistant-suggested-prompts></div>` : null}<div class="footer-container" slot=footer>${this._renderEntryMessage()}<slot name=chat-entry><arcgis-assistant-chat-entry .awaitingResponse=${this.awaitingResponse || this._isAnswering} .inputValue=${this._inputValue} .messages=${this.messages} .voiceInputEnabled=${this.voiceInputEnabled} .disabled=${this._canceling || !this._user || !!this._interrupt} ${v(this.#n)}><slot name=entry-actions-start slot=entry-actions-start></slot><slot name=entry-actions-end slot=entry-actions-end><calcite-button .iconStart=${this.awaitingResponse || this._isAnswering ? "circle-stop" : "send"} @click=${() => {
422
- this.#n.value?.submitMessage();
570
+ return g`<calcite-panel .loading=${!this._orchestratorController && !this._error || this._orchestratorController?.loading} .heading=${this.heading ?? this._messages.assistantLabel} .description=${this.description} ${k(this.#t)}><slot name=header-actions-start slot=header-actions-start></slot><slot name=header-actions-end slot=header-actions-end></slot><div class="content-container"><arcgis-assistant-chat .loading=${this.awaitingResponse} .messages=${this.messages} .interrupt=${this._interrupt}><slot name=message-starter slot=message-starter></slot><slot name=messages slot=messages>${this.messages.map((t) => t.role === "assistant" ? g`<arcgis-assistant-message .message=${t} .feedbackEnabled=${this.feedbackEnabled} .logEnabled=${this.logEnabled} .copyEnabled=${this.copyEnabled} .readAloudEnabled=${this.readAloudEnabled} @arcgisSlottableRequest=${this.#u} .assistantAvatarEnabled=${this.assistantAvatarEnabled}>${t.blocks?.map((e, i) => g`<slot name=${I(t.id, i) ?? _} slot=${I(t.id, i) ?? _}><arcgis-assistant-message-block .block=${e}></arcgis-assistant-message-block></slot>`)}</arcgis-assistant-message>` : g`<arcgis-assistant-user-message .message=${t} .user=${this._user} .userAvatarEnabled=${this.userAvatarEnabled}></arcgis-assistant-user-message>`)}</slot>${this._interrupt ? g`<div slot=message-loading><div class="interrupt-waiting-message">${this._messages.waitingForUserInputMessage}</div></div>` : g`<slot name=message-loading slot=message-loading><arcgis-assistant-message-loading .loading=${this.awaitingResponse} .loadingMessage=${this.awaitingResponseStep} .assistantAvatarEnabled=${this.assistantAvatarEnabled} .interrupts=${this._interruptDetails}></arcgis-assistant-message-loading></slot>`}</arcgis-assistant-chat></div>${this._interrupt ? g`<slot name=interrupt><arcgis-assistant-interrupt slot=content-bottom .type=${this._interrupt.type} .message=${this._interrupt.message} .options=${this._interrupt.options} ${k(this.#s)}></arcgis-assistant-interrupt></slot>` : this.suggestedPrompts?.length ? g`<div class="suggested-prompts-container" slot=content-bottom><arcgis-assistant-suggested-prompts class="suggested-prompts" .prompts=${this.suggestedPrompts}></arcgis-assistant-suggested-prompts></div>` : null}<div class="footer-container" slot=footer>${this._renderEntryMessage()}<slot name=chat-entry><arcgis-assistant-chat-entry .awaitingResponse=${this.awaitingResponse || this._isAnswering} .inputValue=${this._inputValue} .messages=${this.messages} .voiceInputEnabled=${this.voiceInputEnabled} .disabled=${this._canceling || !this._isSignedIn || !!this._interrupt || !!this._error} ${k(this.#o)}><slot name=entry-actions-start slot=entry-actions-start></slot><slot name=entry-actions-end slot=entry-actions-end><calcite-button .iconStart=${this.awaitingResponse || this._isAnswering ? "circle-stop" : "send"} @click=${() => {
571
+ this.#o.value?.submitMessage();
423
572
  }} round>${this.awaitingResponse || this._isAnswering ? this._messages.stopButtonLabel : this._messages.askButtonLabel}</calcite-button></slot></arcgis-assistant-chat-entry></slot><slot name=footer-content></slot></div></calcite-panel>`;
424
573
  }
425
574
  }
426
- $("arcgis-assistant", Y);
575
+ x("arcgis-assistant", et);
427
576
  export {
428
- Y as ArcgisAssistant
577
+ et as ArcgisAssistant
429
578
  };