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

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (207) hide show
  1. package/dist/agent-utils/FunctionAgent.d.ts +2 -2
  2. package/dist/agent-utils/LLMAgent.d.ts +2 -2
  3. package/dist/agent-utils/LLMAgent.js +23 -22
  4. package/dist/agent-utils/WorkflowAgent.d.ts +2 -2
  5. package/dist/agent-utils/index.d.ts +177 -0
  6. package/dist/agent-utils/index.js +167 -0
  7. package/dist/agent-utils/middlewares/trace.d.ts +2 -0
  8. package/dist/agent-utils/middlewares/trace.js +25 -33
  9. package/dist/agent-utils/tools/FunctionTool.d.ts +2 -2
  10. package/dist/agent-utils/types.d.ts +36 -7
  11. package/dist/agent-utils/workflows/ConditionalWorkflow.d.ts +2 -2
  12. package/dist/agent-utils/workflows/LoopWorkflow.d.ts +2 -2
  13. package/dist/agent-utils/workflows/ParallelWorkflow.d.ts +2 -2
  14. package/dist/agent-utils/workflows/RouterWorkflow.d.ts +2 -2
  15. package/dist/agent-utils/workflows/SequentialWorkflow.d.ts +2 -2
  16. package/dist/agent-utils/workflows/SwitchWorkflow.d.ts +2 -2
  17. package/dist/cdn/27NEUQN3.js +2 -0
  18. package/dist/cdn/2NMR43NW.js +2 -0
  19. package/dist/cdn/3AXQTBIA.js +134 -0
  20. package/dist/cdn/434TAA3J.js +2 -0
  21. package/dist/cdn/4I4MCV7V.js +71 -0
  22. package/dist/cdn/4RZPOYZ7.js +9 -0
  23. package/dist/cdn/5SBLS4NW.js +2 -0
  24. package/dist/cdn/{AMP6IALT.js → 5W7S2RS4.js} +1 -1
  25. package/dist/cdn/6LZ6GOHF.js +56 -0
  26. package/dist/cdn/7IFCBXV7.js +2 -0
  27. package/dist/cdn/ADYIXCSG.js +2 -0
  28. package/dist/cdn/AFLQZIKS.js +180 -0
  29. package/dist/cdn/AMVOJNWN.js +2 -0
  30. package/dist/cdn/C7E7MJSR.js +2 -0
  31. package/dist/cdn/CAECQD75.js +2 -0
  32. package/dist/cdn/CIW3QMKV.js +2 -0
  33. package/dist/cdn/CJIV4KJZ.js +179 -0
  34. package/dist/cdn/CVHJMR5X.js +2 -0
  35. package/dist/cdn/DEAYZ3MK.js +2 -0
  36. package/dist/cdn/{H7422XUG.js → E2HENO3T.js} +1 -1
  37. package/dist/cdn/E7TMP4YV.js +3 -0
  38. package/dist/cdn/EBRNMPPO.js +48 -0
  39. package/dist/cdn/FWU6DFIB.js +2 -0
  40. package/dist/cdn/HBYZSLEZ.js +22 -0
  41. package/dist/cdn/HOCTVCHH.js +2 -0
  42. package/dist/cdn/{4HU7735A.js → HXOSLGWU.js} +6 -4
  43. package/dist/cdn/I64KIZG3.js +2 -0
  44. package/dist/cdn/IB4WTK74.js +2 -0
  45. package/dist/cdn/IC5P5NYY.js +2 -0
  46. package/dist/cdn/IGZWQJW7.js +3 -0
  47. package/dist/cdn/IKEF7ZHH.js +181 -0
  48. package/dist/cdn/IXAKT6L3.js +2 -0
  49. package/dist/cdn/JEIMRNYM.js +2 -0
  50. package/dist/cdn/JN744CAW.js +2 -0
  51. package/dist/cdn/KRE4U7V7.js +2 -0
  52. package/dist/cdn/{NE7E52YR.js → KTK4HNL2.js} +8 -2
  53. package/dist/cdn/L77BTGXY.js +2 -0
  54. package/dist/cdn/LEPJUN3X.js +22 -0
  55. package/dist/cdn/LODKJRS4.js +2 -0
  56. package/dist/cdn/M3SWPT3M.js +2 -0
  57. package/dist/cdn/MAV3DW27.js +4 -0
  58. package/dist/cdn/NOJYPREL.js +3 -0
  59. package/dist/cdn/NXKKG5TK.js +2 -0
  60. package/dist/cdn/O3F47IO5.js +2 -0
  61. package/dist/cdn/O7TGCM5P.js +6 -0
  62. package/dist/cdn/PBTINZTK.js +65 -0
  63. package/dist/cdn/PKHQW7QU.js +18 -0
  64. package/dist/cdn/PSWI3MFB.js +2 -0
  65. package/dist/cdn/Q73PK7Q7.js +2 -0
  66. package/dist/cdn/Q7TL5Q5N.js +2 -0
  67. package/dist/cdn/QSA4T3BU.js +2 -0
  68. package/dist/cdn/RMLXVQZ5.js +2 -0
  69. package/dist/cdn/RX45PCYB.js +9 -0
  70. package/dist/cdn/S27EJSLC.js +14 -0
  71. package/dist/cdn/SMADRJ67.js +2 -0
  72. package/dist/cdn/{ZLXN7NMF.js → T537PKP4.js} +9 -7
  73. package/dist/cdn/{X2ZDYHCG.js → TNMXWUXU.js} +9 -4
  74. package/dist/cdn/TSEQVE2H.js +36 -0
  75. package/dist/cdn/VKU4WAQV.js +2 -0
  76. package/dist/cdn/W2IHPJ54.js +34 -0
  77. package/dist/cdn/W2JAKE2M.js +2 -0
  78. package/dist/cdn/WAVKMZA6.js +2 -0
  79. package/dist/cdn/WDE3HN7K.js +2 -0
  80. package/dist/cdn/WH6QQK6N.js +2 -0
  81. package/dist/cdn/WNS5ZUF5.js +2 -0
  82. package/dist/cdn/{FL4W4VYN.js → X7GE26KU.js} +16 -0
  83. package/dist/cdn/XVQJBUMY.js +2 -0
  84. package/dist/cdn/YJ3QQXF6.js +2 -0
  85. package/dist/cdn/YRBANNQ5.js +2 -0
  86. package/dist/cdn/YYY7HKYX.js +2 -0
  87. package/dist/cdn/ZEYIBYSF.js +66 -0
  88. package/dist/cdn/ZMSJQB65.js +99 -0
  89. package/dist/cdn/ZOSUDIJH.js +2 -0
  90. package/dist/cdn/ZPLFFLPF.js +2 -0
  91. package/dist/cdn/agent-utils/index.js +2 -0
  92. package/dist/cdn/agent-utils/middlewares/humanInTheLoop.js +3 -0
  93. package/dist/cdn/agent-utils/middlewares/middleware.js +2 -0
  94. package/dist/cdn/agent-utils/middlewares/trace.js +2 -0
  95. package/dist/cdn/index.js +1 -1
  96. package/dist/cdn/main.css +1 -1
  97. package/dist/chunks/adapter.js +1794 -1597
  98. package/dist/chunks/arcgisKnowledgeGraph.js +126 -71
  99. package/dist/chunks/arcgis_knowledge_current_lc_context.js +19 -2
  100. package/dist/chunks/arcgis_knowledge_current_map_context.js +31 -2
  101. package/dist/chunks/arcgis_knowledge_cypher_query_prompt.js +102 -0
  102. package/dist/chunks/arcgis_knowledge_summarize_result_prompt.js +116 -27
  103. package/dist/chunks/converterUtils.js +39 -32
  104. package/dist/chunks/dataExplorationGraph.js +139 -113
  105. package/dist/chunks/data_explore_query_prompt.js +9 -4
  106. package/dist/chunks/generateLayerDescriptions.js +231 -191
  107. package/dist/chunks/helpGraph.js +17 -13
  108. package/dist/chunks/help_prompt.js +34 -17
  109. package/dist/chunks/index.js +11 -0
  110. package/dist/chunks/intent_prompt.js +16 -0
  111. package/dist/chunks/layerStylingGraph.js +24 -20
  112. package/dist/chunks/navigationGraph.js +33 -28
  113. package/dist/chunks/navigation_intent_prompt.js +8 -2
  114. package/dist/chunks/orchestrator.js +267 -226
  115. package/dist/chunks/slottableRequestUtils.js +3 -7
  116. package/dist/chunks/state.js +1 -1
  117. package/dist/chunks/summarize_query_response_prompt.js +9 -7
  118. package/dist/chunks/toolCallResponse.js +12 -9
  119. package/dist/chunks/utils2.js +8 -8
  120. package/dist/components/arcgis-assistant/customElement.d.ts +27 -0
  121. package/dist/components/arcgis-assistant/customElement.js +385 -152
  122. package/dist/components/arcgis-assistant/index.js +2 -3
  123. package/dist/components/arcgis-assistant/types.d.ts +14 -1
  124. package/dist/components/arcgis-assistant-agent/customElement.js +5 -1
  125. package/dist/components/arcgis-assistant-chat/customElement.d.ts +8 -2
  126. package/dist/components/arcgis-assistant-chat/customElement.js +23 -18
  127. package/dist/components/arcgis-assistant-chat-entry/customElement.d.ts +4 -1
  128. package/dist/components/arcgis-assistant-chat-entry/customElement.js +25 -18
  129. package/dist/components/arcgis-assistant-data-exploration-agent/customElement.js +11 -5
  130. package/dist/components/arcgis-assistant-help-agent/customElement.js +8 -2
  131. package/dist/components/arcgis-assistant-interrupt/customElement.d.ts +4 -1
  132. package/dist/components/arcgis-assistant-interrupt/customElement.js +12 -8
  133. package/dist/components/arcgis-assistant-interrupt-preview/customElement.js +20 -0
  134. package/dist/components/arcgis-assistant-interrupt-preview/index.js +2 -0
  135. package/dist/components/arcgis-assistant-knowledge-agent/customElement.d.ts +7 -7
  136. package/dist/components/arcgis-assistant-knowledge-agent/customElement.js +17 -11
  137. package/dist/components/arcgis-assistant-layer-styling-agent/customElement.js +10 -4
  138. package/dist/components/arcgis-assistant-message/customElement.d.ts +23 -0
  139. package/dist/components/arcgis-assistant-message/customElement.js +28 -26
  140. package/dist/components/arcgis-assistant-message/index.d.ts +1 -0
  141. package/dist/components/arcgis-assistant-message/index.js +2 -0
  142. package/dist/components/arcgis-assistant-message-block/customElement.d.ts +1 -1
  143. package/dist/components/arcgis-assistant-message-block/customElement.js +18 -11
  144. package/dist/components/arcgis-assistant-message-block/index.js +1 -0
  145. package/dist/components/arcgis-assistant-message-feedback/customElement.d.ts +4 -1
  146. package/dist/components/arcgis-assistant-message-footer/customElement.d.ts +4 -1
  147. package/dist/components/arcgis-assistant-message-loading/customElement.d.ts +8 -1
  148. package/dist/components/arcgis-assistant-message-loading/customElement.js +8 -8
  149. package/dist/components/arcgis-assistant-message-loading/index.js +1 -0
  150. package/dist/components/arcgis-assistant-message-log/customElement.d.ts +4 -1
  151. package/dist/components/arcgis-assistant-message-read-aloud/customElement.d.ts +4 -1
  152. package/dist/components/arcgis-assistant-message-text/customElement.d.ts +5 -1
  153. package/dist/components/arcgis-assistant-message-text/customElement.js +12 -12
  154. package/dist/components/arcgis-assistant-navigation-agent/customElement.js +11 -5
  155. package/dist/components/arcgis-assistant-speech-input/customElement.d.ts +6 -1
  156. package/dist/components/arcgis-assistant-suggested-prompts/customElement.d.ts +4 -1
  157. package/dist/components/arcgis-assistant-suggested-prompts/customElement.js +8 -8
  158. package/dist/components/arcgis-assistant-user-message/customElement.d.ts +4 -1
  159. package/dist/components/arcgis-assistant-user-message/customElement.js +10 -8
  160. package/dist/docs/api.json +1 -1
  161. package/dist/docs/docs.json +1 -1
  162. package/dist/docs/vscode.html-custom-data.json +1 -1
  163. package/dist/docs/web-types.json +1 -1
  164. package/dist/index.d.ts +4 -0
  165. package/dist/loader.js +7 -6
  166. package/dist/types/lumina.d.ts +11 -5
  167. package/dist/types/preact.d.ts +12 -5
  168. package/dist/types/react.d.ts +13 -5
  169. package/dist/types/stencil.d.ts +11 -5
  170. package/dist/utils/index.d.ts +85 -42
  171. package/dist/utils/index.js +54 -49
  172. package/package.json +8 -7
  173. package/dist/cdn/2AXF774U.js +0 -2
  174. package/dist/cdn/3PKJWIC3.js +0 -2
  175. package/dist/cdn/462JBSEV.js +0 -422
  176. package/dist/cdn/5QAHYX7Y.js +0 -5
  177. package/dist/cdn/7BCR6TUO.js +0 -2
  178. package/dist/cdn/7GH7VSB2.js +0 -2
  179. package/dist/cdn/7PLV4QH6.js +0 -2
  180. package/dist/cdn/AO7BQHKC.js +0 -2
  181. package/dist/cdn/AXDZBBNL.js +0 -45
  182. package/dist/cdn/DDLZOMUY.js +0 -2
  183. package/dist/cdn/DHOVCT6R.js +0 -2
  184. package/dist/cdn/F2AHA4GB.js +0 -54
  185. package/dist/cdn/FHVXO2WG.js +0 -166
  186. package/dist/cdn/FX5JFRDL.js +0 -2
  187. package/dist/cdn/GSEPHN3A.js +0 -106
  188. package/dist/cdn/HB5A5R2E.js +0 -2
  189. package/dist/cdn/JY6LLOUJ.js +0 -22
  190. package/dist/cdn/KMQ3SP4I.js +0 -5
  191. package/dist/cdn/MDVYQQUG.js +0 -14
  192. package/dist/cdn/MH5RPXHM.js +0 -2
  193. package/dist/cdn/NAUXSHIE.js +0 -72
  194. package/dist/cdn/NVI3I46B.js +0 -2
  195. package/dist/cdn/OAVEHGB6.js +0 -2
  196. package/dist/cdn/OH64RMOR.js +0 -4
  197. package/dist/cdn/ON2V5XI2.js +0 -3
  198. package/dist/cdn/P6OPJQMC.js +0 -3
  199. package/dist/cdn/QR54T33D.js +0 -2
  200. package/dist/cdn/RVOAPUBN.js +0 -2
  201. package/dist/cdn/S6W6HV4T.js +0 -36
  202. package/dist/cdn/SXDLXCIM.js +0 -2
  203. package/dist/cdn/USMDJUFS.js +0 -2
  204. package/dist/cdn/V2P4AIGG.js +0 -2
  205. package/dist/cdn/V5YEZSRY.js +0 -16
  206. package/dist/cdn/Y333DGV6.js +0 -2
  207. package/dist/cdn/YY2SBO3V.js +0 -2
@@ -0,0 +1,2 @@
1
+ /* COPYRIGHT Esri - https://js.arcgis.com/5.2/LICENSE.txt */
2
+ import{a as o}from"./E2HENO3T.js";import"./QSA4T3BU.js";import"./NXKKG5TK.js";import{g as a,h as e,n as i,v as c,z as n}from"./MAV3DW27.js";import"./ADYIXCSG.js";import"./YIMNOUTF.js";var r=a`.actions{display:flex;flex-direction:row;gap:var(--calcite-spacing-xs)}`,t=class extends c{constructor(){super(...arguments),this._messages=o({blocking:!0}),this.feedbackEnabled=!1,this.arcgisFeedback=i()}static{this.properties={feedbackEnabled:5,message:0}}static{this.styles=r}_handleFeedback(s){this.message&&(this.message.feedback=this.message.feedback?.positive===s?void 0:{positive:s},this.arcgisFeedback.emit(this.message),this.requestUpdate())}_getFeedback(){return this.message?.feedback?.positive}_renderThumbsUpButton(){return e`<calcite-action id=action-thumbs-up icon=thumbs-up scale=s .active=${this._getFeedback()===!0} @click=${()=>this._handleFeedback(!0)} text></calcite-action><calcite-tooltip reference-element=action-thumbs-up overlay-positioning=fixed placement=bottom><span>${this._messages.thumbsUpLabel}</span></calcite-tooltip>`}_renderThumbsDownButton(){return e`<calcite-action id=action-thumbs-down icon=thumbs-down scale=s .active=${this._getFeedback()===!1} @click=${()=>this._handleFeedback(!1)} text></calcite-action><calcite-tooltip reference-element=action-thumbs-down overlay-positioning=fixed placement=bottom><span>${this._messages.thumbsDownLabel}</span></calcite-tooltip>`}render(){return this.feedbackEnabled&&!this.message?.error?e`<div class="actions">${this._renderThumbsUpButton()}${this._renderThumbsDownButton()}</div>`:null}};n("arcgis-assistant-message-feedback",t);export{t as ArcgisAssistantMessageFeedback};
@@ -0,0 +1,22 @@
1
+ /* COPYRIGHT Esri - https://js.arcgis.com/5.2/LICENSE.txt */
2
+ import b from"./AFLQZIKS.js";import a from"./EBRNMPPO.js";import{a as p}from"./4RZPOYZ7.js";import{a as u,b as i,ta as c}from"./CJIV4KJZ.js";export default $arcgis.t(([,,,,,,{r:g},{I:d,J:E,a:h,m:f,n:y,o:m,p:x}])=>{var S=[E],_=e=>{if(!e||e.size===0)return"No layers available in this map.";let t=Array.from(e.values()).map(({layerItem:r,fieldRegistry:a},s)=>{let o=Array.from(a.values()).map(n=>n.name).slice(0,10).join(", "),l=a.size>10?` (and ${a.size-10} more)`:"";return`${s+1}. "${r.title}". Description: ${r.description}
3
+ Fields: ${o}${l}`}).join(`
4
+
5
+ `);return`This map contains ${e.size} layer(s):
6
+
7
+ ${t}`},v=e=>{let t=e?.list()??[];return t.length?t.map(r=>`- ${r.agent.name}: ${r.agent.description}`).join(`
8
+ `):"No agents currently available."};async function $(e,t){let r=await f("help_prompt"),a=m(t,"layersAndFieldsRegistry"),s=m(t,"agentRegistry");try{let o=await g({promptText:r,modelTier:"fast",config:t,tools:S,inputVariables:{layerSummary:_(a),agents:v(s),assignedTask:e.agentExecutionContext.assignedTask,userRequest:e.agentExecutionContext.userRequest,priorSteps:e.agentExecutionContext.priorSteps}}),l=(o.tool_calls?.length??0)>0,n=typeof o.text=="string"?o.text.trim():"";return{...e,helpInternalState:{...e.helpInternalState,toolCallMessage:l?o:void 0},outputMessage:l?e.outputMessage:n,summary:l?"Prepared help tool call from assigned task.":"Provided map-related help based on the assigned task.",status:l?e.status:"success"}}catch(o){let l=o instanceof Error?o.message:String(o);return{...e,outputMessage:`Error invoking help agent: ${l}`,summary:"Help agent execution failed.",status:"failed"}}}var b=(e,t)=>x(["agentRegistry"],"Help Agent")(e,t);async function w(e,t){let r=new h(S,{handleToolErrors:!1});try{let a=e.helpInternalState.toolCallMessage;if(!a)throw new Error("helpToolCalling: missing helpInternalState.toolCallMessage");let s=(await r.invoke({messages:[a]},t)).messages.map(o=>o.text).join(`
9
+ `);return await p({text:`Finished executing help tool: ${s}`},t),{...e,outputMessage:s,status:"success",summary:s?y(s):"Help executed.",helpInternalState:{...e.helpInternalState,toolCallMessage:void 0}}}catch(a){let s=a instanceof Error?a.message:String(a);return await p({text:`Help tool execution failed: ${s}`},t),{...e,outputMessage:`Help tool execution failed: ${s}`,status:"failed",summary:`Help tool execution failed: ${s}`,helpInternalState:{...e.helpInternalState,toolCallMessage:void 0}}}}var C=()=>new c(d).addNode("requireHelpServices",b).addNode("agent",$).addNode("tools",w).addEdge(u,"requireHelpServices").addEdge("requireHelpServices","agent").addConditionalEdges("agent",e=>e.helpInternalState.toolCallMessage?"tools":i).addEdge("tools",i),H=String.raw`- **help** — Enables users to ask questions about the map, layers, fields, and it's capabilities.
10
+
11
+ _Example: “Tell me about this map”_
12
+ _Example: “List all layers in this map”_
13
+ _Example: “List fields in protected areas layer”_
14
+ _Example: “What agents are available to me?”_
15
+ _Example: “What can you do?”_
16
+ _Example: “What can I ask”_
17
+
18
+ If the user asks unrelated queries like "What are the vowels in English alphabet" or "How to cook", call this agent so it can politely refuse and redirect to map-related questions.
19
+
20
+ IF the user asks map related queries, but those that are not performed by any of the agents, call this agent so we can respond that the requested action is not supported.
21
+ _Example: "Create a chart"_
22
+ _Example: "Create a table"_`,P={id:"help",name:"Help Agent",description:H,createGraph:C,workspace:d};return P},"identity/IdentityManager","portal/Portal","config","core/reactiveUtils","layers/FeatureLayer","request",a,b)
@@ -0,0 +1,2 @@
1
+ /* COPYRIGHT Esri - https://js.arcgis.com/5.2/LICENSE.txt */
2
+ import{a as t}from"./4RZPOYZ7.js";export default $arcgis.t(([])=>{var d=async(o,i)=>{let r=o.tool_calls??[];if(r.length===0){await t({text:`LLM did not request any tool calls: ${String(o?.content)}`},i);return}await Promise.all(r.map(async a=>await t({text:`LLM invoked ${a.name} tool with arguments: ${JSON.stringify(a.args,null,2)}`},i)))};return d},"identity/IdentityManager","portal/Portal","config","core/reactiveUtils","layers/FeatureLayer","request")
@@ -1,7 +1,9 @@
1
1
  /* COPYRIGHT Esri - https://js.arcgis.com/5.2/LICENSE.txt */
2
- import c from"./FHVXO2WG.js";import a from"./GSEPHN3A.js";import{Fb as k,Q as x,a as y,b as l}from"./462JBSEV.js";import{c as b,d as A}from"./HB5A5R2E.js";import"./AMP6IALT.js";import"./OAVEHGB6.js";import{v as w,y as f}from"./OH64RMOR.js";import"./YIMNOUTF.js";export default $arcgis.t(([,,,,,,,,,,,,,{fetchKnowledgeGraph:J},{f:c,k:v,m:_},{K:u,L:K,M:S,N:M,O:G,P:T,Q:C,R:N,S:R,T:z,U:F,a:q,m:g,n:d,p:E}])=>{var L=[T,C,z,N,G,F,R];async function I(e,a){let i=await g("arcgis_knowledge_tool_prompt"),s=K(a),n={assignedTask:e.agentExecutionContext.assignedTask,userRequest:e.agentExecutionContext.userRequest,priorSteps:e.agentExecutionContext.priorSteps,contextType:s},r=await _({promptText:i,messages:e.arcgisKnowledgeMessages,inputVariables:n,tools:L}),t=(r.tool_calls?.length??0)>0,o=typeof r.text=="string"?r.text.trim():"",h=o.length>0,p=r.content.toString();return!t&&(s==="map"||s==="knowledgeGraph")?{...e,arcgisKnowledgeMessages:[...e.arcgisKnowledgeMessages,r],outputMessage:s==="map"?"No tools were found for the current view and prompt. Maps do not support changing nonspatial visibility, layout changes, or generation from queries.":"No tools were found for the current prompt and knowledge graph service. A knowledge graph service only supports search and query.",status:"success"}:{...e,arcgisKnowledgeMessages:[...e.arcgisKnowledgeMessages,r],outputMessage:t?p:o,status:t?e.status:h?"success":"failed",summary:p?d(p):"ArcGIS Knowledge Agent tool executed."}}async function U(e,a){let i=new q(L);try{let s=await i.invoke({messages:e.arcgisKnowledgeMessages},a),n=[];for(let t of s.messages){let o;if(typeof t.content!="string")throw new Error(`Unexpected tool message content type: ${typeof t.content}. Expected string.`);try{o=JSON.parse(t.content)}catch{throw new Error(`Failed to parse tool message content as JSON. Tool: ${t.name??"unknown"}`)}if(!o||typeof o!="object"||!("toolName"in o))throw new Error(`Parsed tool message content does not have expected structure. Parsed content: ${JSON.stringify(o)}`);n.push(o)}await c({text:`Finished executing ArcGIS Knowledge Agent tools: ${s.messages.filter(t=>t.name).map(t=>t.name).join(", ")}`},a);let r=n.filter(t=>typeof t!="string").map(t=>`- Called Tool: ${t.toolName}, Status: ${t.status}`);return{...e,outputMessage:r.join(`
3
- `),summary:r.length?d(r.join(`
4
- `)):"ArcGIS Knowledge Agent did not execute any tools or return any results.",arcgisKnowledgeMessages:[...e.arcgisKnowledgeMessages,...s.messages],arcgisKnowledgeToolResult:n}}catch(s){let n=s instanceof Error?s.message:String(s);return await c({text:`ArcGIS Knowledge Agent tool execution failed: ${n}`},a),{...e,outputMessage:`ArcGIS Knowledge Agent tool execution failed: ${n}`,status:"failed",summary:`ArcGIS Knowledge Agent tool execution failed: ${n}`,arcgisKnowledgeMessages:[...e.arcgisKnowledgeMessages]}}}var D=(e,a)=>E([],"ArcgisKnowledge Agent")(e,a);async function j(e,a){let i=(e.arcgisKnowledgeToolResult??[]).map(h=>({...h,details:void 0})),{knowledgeGraph:s}=await S(a),n=M.getDataModelTypesSummary(s.dataModel),r={assignedTask:e.agentExecutionContext.assignedTask,userRequest:e.agentExecutionContext.userRequest,toolResult:i,dataModelSummary:n},t=await v({promptText:await g("arcgis_knowledge_summarize_result_prompt"),modelTier:"default",inputVariables:r}),o=typeof t=="string"?t:t.content;return{...e,outputMessage:o,status:"success",summary:d(o),arcgisKnowledgeMessages:[...e.arcgisKnowledgeMessages,new x(o)]}}var O=()=>new k(u).addNode("requireArcgisKnowledgeServices",D).addNode("agent",I).addNode("tools",U).addNode("summarizationLLM",j).addEdge(y,"requireArcgisKnowledgeServices").addEdge("requireArcgisKnowledgeServices","agent").addConditionalEdges("agent",e=>(e.arcgisKnowledgeMessages[e.arcgisKnowledgeMessages.length-1]?.tool_calls?.length??0)>0?"tools":l).addConditionalEdges("tools",e=>e.status==="failed"?l:"summarizationLLM").addEdge("summarizationLLM",l),V=String.raw`The purpose of this agent is to work with Knowledge Graph data, a graph database technology that represents and stores data as interconnected entities (nodes) and relationships (edges).
2
+ import b from"./AFLQZIKS.js";import a from"./EBRNMPPO.js";import{a as c,b as k}from"./4RZPOYZ7.js";import{a as w,b as d,j as f,ta as x}from"./CJIV4KJZ.js";import{Z as u}from"./IKEF7ZHH.js";export default $arcgis.t(([,,,,,,{p:_,r:b},{K:y,L:K,M:q,N:S,O:M,P:T,Q:E,R:C,S:G,T:N,U:R,a:v,m:m,n:h,p:A}])=>{var z=[T,E,N,C,M,R,G];async function $(e,a){let o=await m("arcgis_knowledge_tool_prompt"),s=K(a),n={assignedTask:e.agentExecutionContext.assignedTask,userRequest:e.agentExecutionContext.userRequest,priorSteps:e.agentExecutionContext.priorSteps,contextType:s},r=await b({promptText:o,messages:e.arcgisKnowledgeMessages,inputVariables:n,tools:z,config:a}),i=(r.tool_calls?.length??0)>0,t=typeof r.text=="string"?r.text.trim():"",l=t.length>0,p=r.content.toString();return!i&&(s==="map"||s==="knowledgeGraph")?{...e,arcgisKnowledgeMessages:[...e.arcgisKnowledgeMessages,r],outputMessage:s==="map"?"No tools were found for the current view and prompt. Maps do not support changing nonspatial visibility, layout changes, or generation from queries.":"No tools were found for the current prompt and knowledge graph service. A knowledge graph service only supports search and query.",status:"success"}:{...e,arcgisKnowledgeMessages:[...e.arcgisKnowledgeMessages,r],outputMessage:i?p:t,status:i?e.status:l?"success":"failed",summary:p?h(p):"ArcGIS Knowledge Agent tool executed."}}var L={generateCypher:"generated-cypher-query",queryGraphData:"graph-query-result",searchGraphData:"graph-search-result",addRecords:"added-records",applyLayout:"applied-layout",changeNonspatialVisibility:"changed-nonspatial-visibility",createLinkChart:"created-link-chart"};function I(e){return!!e&&e.status==="success"&&!!L[e.toolName]}function D(e){return{type:L[e.toolName],data:e.details}}async function F(e,a){let o=new v(z,{handleToolErrors:!1});try{let s=await o.invoke({messages:e.arcgisKnowledgeMessages},a),n=[];for(let t of s.messages){let l;if(typeof t.content!="string")throw new Error(`Unexpected tool message content type: ${typeof t.content}. Expected string.`);try{l=JSON.parse(t.content)}catch{throw new Error(`Failed to parse tool message content as JSON. Tool: ${t.name??"unknown"}.
3
+
4
+ Original Content: ${t.content}`)}if(!l||typeof l!="object"||!("toolName"in l))throw new Error(`Parsed tool message content does not have expected structure. Parsed content: ${JSON.stringify(l)}`);n.push(l)}await c({text:`Finished executing ArcGIS Knowledge Agent tools: ${s.messages.filter(t=>t.name).map(t=>t.name).join(", ")}`},a);let r=n.filter(t=>typeof t!="string").map(t=>`- Called Tool: ${t.toolName}, Status: ${t.status}`),i=n[0];return i&&I(i)&&await k(D(i),a),{...e,outputMessage:r.join(`
5
+ `),summary:r.length?h(r.join(`
6
+ `)):"ArcGIS Knowledge Agent did not execute any tools or return any results.",arcgisKnowledgeMessages:[...e.arcgisKnowledgeMessages,...s.messages],arcgisKnowledgeToolResult:n}}catch(s){let n=s instanceof Error?s.message:String(s);return await c({text:`ArcGIS Knowledge Agent tool execution failed unexpectedly: ${n}`},a),{...e,outputMessage:`ArcGIS Knowledge Agent tool execution failed unexpectedly: ${n}`,status:"failed",summary:h(`ArcGIS Knowledge Agent tool execution failed unexpectedly: ${n}`),arcgisKnowledgeMessages:[...e.arcgisKnowledgeMessages]}}}var V=(e,a)=>A([],"ArcgisKnowledge Agent")(e,a);async function j(e,a){let o=(e.arcgisKnowledgeToolResult??[]).map(l=>({...l,details:void 0})),{knowledgeGraph:s}=await q(a),n=S.getDataModelTypesSummary(s.dataModel),r={assignedTask:e.agentExecutionContext.assignedTask,userRequest:e.agentExecutionContext.userRequest,toolResult:o,dataModelSummary:n},i=await _({promptText:await m("arcgis_knowledge_summarize_result_prompt"),modelTier:"default",inputVariables:r,config:a}),t=typeof i=="string"?i:i.content;return{...e,outputMessage:t,status:"success",summary:h(t),arcgisKnowledgeMessages:[...e.arcgisKnowledgeMessages,new u(t)]}}async function O(e){let a=e.arcgisKnowledgeToolResult?.[0],o=a?.status==="success"?a.summary:"ArcGIS Knowledge Agent tool execution failed.";return{...e,outputMessage:o,status:"success",summary:h(o),arcgisKnowledgeMessages:[...e.arcgisKnowledgeMessages,new u(o)]}}function g(e){return async(a,o)=>o?.signal?.aborted?(await c({text:"Knowledge Agent execution cancelled"},o),new f({goto:d,update:{outputMessage:"Knowledge Agent execution cancelled",summary:"Knowledge Agent execution cancelled",status:"failed"}})):await e(a,o)}var J=()=>new x(y).addNode("requireArcgisKnowledgeServices",V).addNode("agent",g($)).addNode("tools",g(F)).addNode("summarizationLLM",g(j)).addNode("finalizeToolSummary",g(O)).addEdge(w,"requireArcgisKnowledgeServices").addEdge("requireArcgisKnowledgeServices","agent").addConditionalEdges("agent",e=>(e.arcgisKnowledgeMessages[e.arcgisKnowledgeMessages.length-1]?.tool_calls?.length??0)>0?"tools":d).addConditionalEdges("tools",e=>{if(e.status==="failed")return d;let a=e.arcgisKnowledgeToolResult?.[0];return a?.status==="success"&&["applyLayout","changeNonspatialVisibility"].includes(a.toolName)?"finalizeToolSummary":"summarizationLLM"}).addEdge("summarizationLLM",d).addEdge("finalizeToolSummary",d),P=String.raw`The purpose of this agent is to work with Knowledge Graph data, a graph database technology that represents and stores data as interconnected entities (nodes) and relationships (edges).
5
7
  This agent has two categories of skills: those that work with an active link chart visualization of a subset of the data in the knowledge graph, and those that work with the knowledge graph data more generally against the entire dataset in the service and database.
6
8
  For link charts, the agent enables users to interact with a link chart by adding new entities (also called nodes) or relationships (also called edges), removing existing entities or relationships,
7
9
  expanding the graph from particular entities, finding relationships between specified entities on the link chart and adding them to the link chart, finding all relationships
@@ -39,4 +41,4 @@ _example: "Discover and add all the relationships originating at 'Entity E' to t
39
41
  _example: "Show me all entities with a name similar to 'Smith' and add them to the link chart"_
40
42
  _example: "Find reports in my graph that have a title similar to 'Quarterly Earnings'"_
41
43
  _example: "Find John Smith and all people he has made phone calls to in the last year"_
42
- _example: "What is the average age of all people who work for Esri?"_`,$={id:"arcgisKnowledge",name:"ArcgisKnowledge Agent",description:V,createGraph:O,workspace:u};var m=class extends w{constructor(){super(...arguments),this.agent=$}static{this.properties={referenceElement:1,serviceUrl:3,context:0}}#t;#a;#e;get serviceUrl(){return this.#a}set serviceUrl(a){this.#a=a}async getContext(){let a=this.context?{...this.context,knowledgeGraph:void 0,view:void 0}:{};if(this.#t)return{...a,view:this.#t};if(this.#e)try{let i=await this.#e;return{...a,knowledgeGraph:i}}catch(i){console.error("Failed to load knowledge graph via service URL:",i)}if(!this.context?.knowledgeGraph&&!this.context?.view)throw new Error("arcgis-assistant-knowledge-agent requires either a knowledgeGraph or view in context, and neither were provided");return this.context}willUpdate(a){a.has("serviceUrl")&&this.serviceUrl?this.#e=J(this.serviceUrl):this.#e=void 0}load(){this.#t=A(this)??void 0,b(this)}};f("arcgis-assistant-knowledge-agent",m);return m},"identity/IdentityManager","portal/Portal","core/reactiveUtils","layers/FeatureLayer","request","intl","smartMapping/statistics/summaryStatistics","smartMapping/statistics/uniqueValues","identity/IdentityManager","portal/Portal","core/reactiveUtils","layers/FeatureLayer","request","rest/knowledgeGraphService",a,c)
44
+ _example: "What is the average age of all people who work for Esri?"_`,ie={id:"arcgisKnowledge",name:"ArcgisKnowledge Agent",description:P,createGraph:J,workspace:y};return ie},"identity/IdentityManager","portal/Portal","config","core/reactiveUtils","layers/FeatureLayer","request",a,b)
@@ -0,0 +1,2 @@
1
+ /* COPYRIGHT Esri - https://js.arcgis.com/5.2/LICENSE.txt */
2
+ import{g as i,h as s,v as n,z as o}from"./MAV3DW27.js";import"./ADYIXCSG.js";import"./YIMNOUTF.js";var c=i`:host{display:block}`,e=class extends n{static{this.properties={block:0}}static{this.styles=c}_renderSuggestedPrompts(t){if(t.type!=="suggested-prompts")return null;let r=t.data?.prompts,a=Array.isArray(r)?r.filter(p=>typeof p=="string"):[];return a.length?s`<arcgis-assistant-suggested-prompts .prompts=${a}></arcgis-assistant-suggested-prompts>`:null}_renderBlock(t){switch(t.type){case"suggested-prompts":return this._renderSuggestedPrompts(t);case"text":return s`<arcgis-assistant-message-text .content=${t.data?.content} .parts=${t.data?.parts}></arcgis-assistant-message-text>`;default:return null}}render(){return this.block?this._renderBlock(this.block):null}};o("arcgis-assistant-message-block",e);export{e as ArcgisAssistantMessageBlock};
@@ -0,0 +1,2 @@
1
+ /* COPYRIGHT Esri - https://js.arcgis.com/5.2/LICENSE.txt */
2
+ import{a,b as c,c as o}from"./RX45PCYB.js";import"./PBTINZTK.js";import{g as e,h as t,v as i,z as s}from"./MAV3DW27.js";import"./ADYIXCSG.js";import"./YIMNOUTF.js";var l=e`.container{color:var(--calcite-color-text-1)}.content>*{margin:0}.content>*+*{margin-block-start:var(--calcite-spacing-sm)}.content :is(ol,ul){padding-inline-start:var(--calcite-spacing-lg)}.content>calcite-table{display:block;max-width:100%}.content pre{background-color:var(--calcite-color-foreground-1);padding:var(--calcite-spacing-sm);border-radius:var(--calcite-border-radius);color:var(--calcite-color-text-1);direction:ltr;max-width:100%;overflow:auto}.content pre code{display:block;white-space:pre;font-family:var(--calcite-code-family)}.part{animation:part-reveal calc(3 * var(--calcite-animation-timing)) ease-out}@keyframes part-reveal{0%{opacity:0;transform:translateY(var(--calcite-size-fixed-xxs))}to{opacity:1;transform:translateY(0)}}@media(prefers-reduced-motion:reduce){.part{animation:none}}`,r=class extends i{static{this.properties={content:1,parts:0}}static{this.styles=l}render(){return t`<div class="container"><div class="content">${this.parts?.map(n=>t`<span class="part">${a(o(n))}</span>`)??a(c(this.content))}</div></div>`}};s("arcgis-assistant-message-text",r);export{r as ArcgisAssistantMessageText};
@@ -0,0 +1,2 @@
1
+ /* COPYRIGHT Esri - https://js.arcgis.com/5.2/LICENSE.txt */
2
+ import a from"./WAVKMZA6.js";import"./CVHJMR5X.js";import"./CJIV4KJZ.js";import"./IKEF7ZHH.js";import"./ZEYIBYSF.js";import"./YIMNOUTF.js";export default $arcgis.t(([{property:g,subclass:y},{c:p,d:w}])=>{var b=Object.defineProperty,k=Object.getOwnPropertyDescriptor,v=e=>{throw TypeError(e)},h=(e,t,r,s)=>{for(var n=s>1?void 0:s?k(t,r):t,o=e.length-1,a;o>=0;o--)(a=e[o])&&(n=(s?a(t,r,n):a(n))||n);return s&&n&&b(t,r,n),n},A=(e,t,r)=>t.has(e)||v("Cannot "+r),M=(e,t,r)=>t.has(e)?v("Cannot add the same private member more than once"):t instanceof WeakSet?t.add(e):t.set(e,r),m=(e,t,r)=>(A(e,t,"access private method"),r),c,u,i=class extends w{constructor(e){super(e),M(this,c)}getAgents(){let e=Object.values(this.agentsMap);return this.defaultAgent?e.concat(this.defaultAgent):e}buildNodes(e){let t=super.buildNodes(e);return t[d]=()=>({}),t}buildEdges(e){m(this,c,u).call(this);let t=this.resolver,r=new Map;for(let[o,[a]]of Object.entries(this.agentsMap).entries())r.set(a,p(e[o],o));let{defaultAgent:s}=this,n=s?p(s,e.length-1):void 0;return[{from:d,decide:async(o,a)=>{let l=await Promise.resolve(t(o,a));if(!l)return;let f=r.get(l);if(f)return f;if(s)return n;throw new Error(`SwitchWorkflow resolver returned unknown case: ${l}. Expected one of: ${Object.keys(this.agentsMap).join(", ")||"(none)"}.`)}}]}getEntryNode(){return d}isTerminalAgent(){return!0}validateAgents(e){m(this,c,u).call(this),super.validateAgents(e)}};c=new WeakSet;u=function(){if(!Object.keys(this.agentsMap).length)throw new Error("SwitchWorkflow requires a non-empty agentsMap.")};h([g()],i.prototype,"agentsMap",2);h([g()],i.prototype,"resolver",2);h([g()],i.prototype,"defaultAgent",2);i=h([y("SwitchWorkflow")],i);var d="__switch_decide";return i},"core/accessorSupport/decorators",a)
@@ -0,0 +1,3 @@
1
+ /* COPYRIGHT Esri - https://js.arcgis.com/5.2/LICENSE.txt */
2
+ import{a as E}from"./PBTINZTK.js";import b from"./E7TMP4YV.js";import{a as I}from"./434TAA3J.js";import{a as D}from"./E2HENO3T.js";import"./QSA4T3BU.js";import a from"./EBRNMPPO.js";import{a as R}from"./5W7S2RS4.js";import"./NXKKG5TK.js";import{g as $,h as c,k as C,l as P,n as d,t as _,u as y,v as T,x as k,z as A}from"./MAV3DW27.js";import"./ADYIXCSG.js";import"./4RZPOYZ7.js";import"./6LZ6GOHF.js";import"./CJIV4KJZ.js";import"./IKEF7ZHH.js";import"./WNS5ZUF5.js";import"./ZEYIBYSF.js";import"./YIMNOUTF.js";export default $arcgis.t(([N,{whenOnce:U,watch:B,when:V},j,q,,,H,{property:m,subclass:F},,{b:L}])=>{var G=$`:host{display:block;width:var(--arcgis-internal-panel-width, 100%);height:var(--arcgis-internal-expand-max-height, 100%);--calcite-panel-content-bottom-space: 0}.footer-container{display:flex;flex-direction:column;flex:1 1 0;gap:var(--calcite-spacing-md)}.content-container{display:flex;flex-direction:column;flex:1 1 0;min-height:0;position:relative;overflow:auto}.suggested-prompts-container{display:flex;justify-content:center;width:100%;background:var(--calcite-panel-background-color, var(--calcite-color-background))}.suggested-prompts{display:block;padding:var(--calcite-spacing-md);max-width:100%;box-sizing:border-box}.error-notice{padding:var(--calcite-spacing-sm)}.interrupt-waiting-message{font-style:italic;color:var(--calcite-color-text-2)}`;function S(o){return o.trim()?E.lexer(o).filter(t=>t.type!=="space").map(t=>E.parser([t])):[]}var f=class{constructor(){this._stableParts=[],this._stableText="",this._rawText=""}push(t){return this._rawText+=t,this._advanceStableBoundary(),this.getParts()}finalize(){let t=this._rawText.slice(this._stableText.length);return t.trim()&&(this._stableParts.push(...S(t)),this._stableText=this._rawText),this._stableParts}getParts(){let t=this._trimIncompleteTail(this._rawText.slice(this._stableText.length)),s=t.trim()?S(t):[];return[...this._stableParts,...s]}reset(){this._stableParts=[],this._stableText="",this._rawText=""}_advanceStableBoundary(){let t=this._rawText.slice(this._stableText.length),s=this._lastSafeBoundary(t);if(s<=0)return;let i=t.slice(0,s);this._stableParts.push(...S(i)),this._stableText+=i}_lastSafeBoundary(t){let s=t.split(`
3
+ `),i=!1,e=0,n=0;for(let r of s)/^\s*(```|~~~)/u.test(r)&&(i=!i),n+=r.length+1,r.trim()===""&&!i&&(e=n);return e<t.length?e:0}_trimIncompleteTail(t){let s=t.lastIndexOf("<");if(s!==-1&&!t.includes(">",s))return t.slice(0,s);let i=this._earliestUnclosedTag(t);if(i!==-1)return t.slice(0,i);let e=t.lastIndexOf("[");if(e!==-1){let n=t.slice(e);if(!/\[[^\]]*\]\([^)]*\)/u.test(n))return t.slice(0,e)}return t}_earliestUnclosedTag(t){let s=new Set(["br","img","hr","input","meta","link","area","base","col","embed","source","track","wbr"]),i=/<(\/?)([a-zA-Z][\w-]*)\b[^>]*?(\/?)>/gu,e=[];for(let n=i.exec(t);n;n=i.exec(t)){let[,r,a,l]=n,h=a.toLowerCase();if(!(s.has(h)||l==="/"))if(r==="/"){for(let g=e.length-1;g>=0;g--)if(e[g].name===h){e.splice(g);break}}else e.push({name:h,index:n.index})}return e.length?e[0].index:-1}};function W(o){let t=new f;return t.push(o),t.finalize()}var Y=async o=>await new Promise(t=>setTimeout(t,o));async function*Z(o,{chunkSize:t=15,delay:s=50}={}){let i=new f;for(let e=0;e<o.length;e+=t)yield i.push(o.slice(e,e+t)),await Y(s);yield i.finalize()}var J=Object.defineProperty,K=Object.getOwnPropertyDescriptor,u=(o,t,s,i)=>{for(var e=i>1?void 0:i?K(t,s):t,n=o.length-1,r;n>=0;n--)(r=o[n])&&(e=(i?r(t,s,e):r(e))||e);return i&&e&&J(t,s,e),e},O=o=>!o||typeof o!="object"?!1:o.name==="AbortError";async function*z(o,t,s,i,e=!1){if(e){if(i?.aborted){yield{type:"cancelled",log:s,runId:t};return}yield{type:"block-data",blockType:"text",data:{parts:W(o)},runId:t};return}for await(let n of Z(o)){if(i?.aborted){yield{type:"cancelled",log:s,runId:t};return}yield{type:"block-data",blockType:"text",data:{parts:n},runId:t}}}var p=class extends H{constructor(o){super(o),this.view=null,this.streamingDisabled=!1,this.loading=!1,this.processing=!1,this.processingStep=""}async load(){this._set("loading",!0);try{await this._initialize()}finally{this._set("loading",!1)}}destroy(){this.orchestrator?.dispose(),super.destroy()}async _initialize(){this.removeHandles(),await Promise.all([this.portal.load(),this.view?.when()]),this.view&&await U(()=>!this.view.updating),this._set("orchestrator",await L.init({agents:[...this.agents],view:this.view??void 0})),this.addHandles([B(()=>[this.view,this.agents],()=>{this._initialize()})])}clearChatHistory(){this.orchestrator?.newConversation()}async*ask(o,t){if(!this.orchestrator)throw new Error("Orchestrator not initialized yet.");this._set("processing",!0),this._set("processingStep","");let s=[],i,e="pending";try{let n=this.orchestrator.ask(o);for await(let r of n)switch(e=r.runId,r.type){case"trace":{this._set("processingStep",r.data.text),s.push(r.data.text);break}case"completed":{this._set("processing",!1),this._set("processingStep","");let a=r.result,l=!!a.content.length,h=!!i?.length;if(!l&&!h){yield{type:"completed",error:"No response received.",log:s,runId:e};return}let g=a.content;if(yield{type:"block-start",blockType:"text",runId:e},yield*z(g,e,s,t,this.streamingDisabled),yield{type:"block-end",blockType:"text",runId:e},h)for(let v of i){if(t?.aborted){yield{type:"cancelled",log:s,runId:e};return}let{type:b,data:w}=v;if(yield{type:"block-start",blockType:b,runId:e},b==="text"){let M=typeof w?.content=="string"?w.content:"";yield*z(M,e,s,t,this.streamingDisabled)}else yield{type:"block-data",blockType:b,data:w,runId:e};yield{type:"block-end",blockType:b,runId:e}}yield{type:"completed",response:g,blocks:i,log:s,runId:e};return}case"ux-suggestion":{let a=r.suggestion;i=i?[...i,a]:[a];break}case"interrupt":{let{kind:a,message:l,metadata:h}=r.interrupt,g=Array.isArray(h)?h.filter(b=>typeof b=="string"):[],v=(()=>{switch(a){case"booleanChoice":return{type:"boolean-choice",message:l,options:g};case"singleSelection":return{type:"single-select",message:l,options:g};case"multipleSelection":return{type:"multi-select",message:l,options:g};case"textInput":return{type:"text-input",message:l};default:return{type:a,message:l,options:g}}})();this._set("processingStep","Waiting for user input..."),yield{type:"interrupt",payload:v,runId:e};break}case"cancelled":{yield{type:"cancelled",log:s,runId:e};return}case"error":{if(t?.aborted||O(r.error)){yield{type:"cancelled",log:s,runId:e};return}yield{type:"completed",error:r.error.message,log:s,runId:e};return}default:{console.warn("Unknown event type:",r);break}}}catch(n){if(t?.aborted||O(n)){yield{type:"cancelled",log:s,runId:e};return}console.warn("Error during message processing:",n),yield{type:"completed",error:"An error occurred during message processing.",log:s,runId:"error"};return}finally{this._set("processing",!1)}}cancel(){this.orchestrator?.cancel()}};u([m({readOnly:!0})],p.prototype,"orchestrator",2);u([m()],p.prototype,"agents",2);u([m()],p.prototype,"portal",2);u([m()],p.prototype,"view",2);u([m()],p.prototype,"streamingDisabled",2);u([m({readOnly:!0})],p.prototype,"loading",2);u([m({readOnly:!0})],p.prototype,"processing",2);u([m({readOnly:!0})],p.prototype,"processingStep",2);p=u([F("OrchestratorController")],p);var Q="Embeddings resource 'embeddings-v01.json' not found in the webmap portal item.",X="Embeddings not found for this web map.",tt="https://developers.arcgis.com/javascript/latest/agentic-apps/ai-webmap-setup/#embeddings",x=class extends T{constructor(){super(...arguments),this._messages=D({blocking:!0}),this.#t=_(),this.#l=_(),this.#s=_(),this.#e=null,this.#r=new Map,this.#i=j.getDefault(),this.#a=t=>{t.stopPropagation(),this.cancelInterrupt()},this.#n=t=>{t.stopPropagation();let s=t.detail;this.submitInterrupt(s)},this.#c=t=>{t.stopPropagation(),this.keepSuggestedPrompts||(this.suggestedPrompts=[]);let s=t.detail;this._inputValue="",this.arcgisSubmit.emit(s),this.submitMessage(s)},this.#h=t=>{if(this._canceling=!0,t.stopPropagation(),this.arcgisCancel.emit(),this._interrupt){this.orchestrator?.cancelInterrupt(),this._interrupt=null;return}this._orchestratorController?.cancel(),this.#e?.abort(),this.#e=null},this.#g=t=>{t.stopPropagation();let s=t.detail;this.arcgisFeedback.emit(s)},this.#d=t=>{t.stopPropagation();let s=t.detail;this._inputValue=s.prompt,this.arcgisPromptSelect.emit(s)},this.#p=t=>{this.arcgisSlottableRequest.emit(t.detail)},this._orchestratorController=null,this._interrupt=null,this._interruptDetails=[],this._error=null,this._inputValue="",this._isAnswering=!1,this._canceling=!1,this.messages=new N([]),this.referenceElement=null,this.suggestedPrompts=[],this.feedbackEnabled=!1,this.keepSuggestedPrompts=!1,this.streamingDisabled=!1,this.logEnabled=!1,this.copyEnabled=!1,this.voiceInputEnabled=!1,this.readAloudEnabled=!1,this.assistantAvatarEnabled=!1,this.arcgisCancel=d(),this.arcgisError=d(),this.arcgisFeedback=d(),this.arcgisInterrupt=d(),this.arcgisInterruptCancel=d(),this.arcgisInterruptSubmit=d(),this.arcgisPromptSelect=d(),this.arcgisReady=d(),this.arcgisSubmit=d(),this.arcgisSlottableRequest=d({bubbles:!1,composed:!1}),this.arcgisResponse=d()}static{this.properties={_orchestratorController:16,_interrupt:16,_interruptDetails:16,_error:16,_inputValue:16,_isAnswering:16,_signedInUserId:16,_canceling:16,_isSignedIn:16,_user:16,awaitingResponse:32,awaitingResponseStep:32,interrupt:32,messages:0,orchestrator:32,entryMessage:1,heading:1,description:1,referenceElement:1,suggestedPrompts:0,feedbackEnabled:5,keepSuggestedPrompts:5,streamingDisabled:5,logEnabled:5,copyEnabled:5,voiceInputEnabled:5,readAloudEnabled:5,assistantAvatarEnabled:5}}static{this.styles=G}#t;#l;#s;#e;#r;#i;#a;#n;#c;#h;#g;#d;#p;async#o(){try{let t=R(this.el,this.referenceElement);await t?.componentOnReady();let s=[...this.#r.values()];return s.length?(this._orchestratorController?.destroy(),this._orchestratorController=new p({agents:s,portal:this.#i,streamingDisabled:this.streamingDisabled,view:t?.view}),await this._orchestratorController.load(),!0):(this._error="No agents found.",!1)}catch(t){return this._error=t?.message??"Error initializing orchestrator.",P(this)(t),!1}}get _isSignedIn(){return!!this.#i?.user||!!this._signedInUserId}get _user(){return this.#i?.user?.fullName||this.#i?.user?.username}get awaitingResponse(){return this._orchestratorController?.processing??!1}get awaitingResponseStep(){return this._orchestratorController?.processingStep??""}get interrupt(){return this._interrupt}get orchestrator(){return this._orchestratorController?.orchestrator}async clearChatHistory(){this._reset(),this._orchestratorController?.clearChatHistory()}cancelInterrupt(){this.arcgisInterruptCancel.emit(),this.orchestrator?.cancelInterrupt(),this._interrupt=null}register(t){this.#r.set(t.agent.id,t),this._orchestratorController&&this.#o()}unregister(t){this.#r.delete(t),this._orchestratorController&&this.#o()}async submitMessage(t){let s=t.trim();if(!s||(this.messages.push({id:Date.now().toString(),role:"user",content:s}),!this._orchestratorController))return;this.#e=new AbortController,this._orchestratorController.streamingDisabled=this.streamingDisabled;let i=this._orchestratorController.ask(s,this.#e?.signal);for await(let e of i){let n=e.runId,r=this.messages.at(-1);switch(e.type){case"block-start":{this._isAnswering=!0;let a={type:e.blockType,isPending:!0};if(r?.role==="assistant"&&r.id===n){let l=[...r.blocks??[],a];this.messages.splice(-1,1,{...r,blocks:l})}else this.messages.push({role:"assistant",blocks:[a],id:n,isStreaming:!0,interrupts:this._interruptDetails}),this._interruptDetails=[];break}case"block-data":{if(r?.role!=="assistant"||r?.id!==n)break;let a=[...r.blocks??[]],l=a[a.length-1],{blockType:h,data:g}=e;if(l?.type!==h||!l.isPending)break;h==="text"?a[a.length-1]={...l,data:{...l.data,parts:g?.parts}}:a[a.length-1]={...l,data:{...l.data,...g??{}}},this.messages.splice(-1,1,{...r,blocks:a});break}case"block-end":{if(r?.role!=="assistant"||r?.id!==n)break;let a=[...r.blocks??[]],l=a[a.length-1];if(l?.type!==e.blockType||!l.isPending)break;let h=l;a[a.length-1]={...h,data:{...h.data},isPending:!1},this.messages.splice(-1,1,{...r,blocks:a});break}case"completed":e.error?(this.messages.push({role:"assistant",log:e.log,error:e.error,id:n,interrupts:this._interruptDetails}),this._interruptDetails=[]):r?.role==="assistant"&&r.id===n&&this.messages.splice(-1,1,{...r,content:e.response,blocks:r.blocks?.map(a=>({...a,data:{...a.data},isPending:!1}))??[],isStreaming:!1,log:e.log}),this._isAnswering=!1,this.#e=null,this._canceling=!1;break;case"interrupt":this._interrupt={...e.payload,id:n},this.arcgisInterrupt.emit(this._interrupt);break;case"cancelled":r?.role==="assistant"&&r.id===n?this.messages.splice(-1,1,{...r,blocks:r.blocks?.filter(a=>a.type==="text"||!a.isPending)??[],isStreaming:!1,log:e.log,error:"(Stopped by user)"}):(this.messages.push({role:"assistant",log:e.log,error:"(Stopped by user)",id:n,interrupts:this._interruptDetails}),this._interruptDetails=[]),this._isAnswering=!1,this.#e=null,this._canceling=!1;break}}}submitInterrupt(t){this.arcgisInterruptSubmit.emit(t),this._interrupt&&(this._interruptDetails=[...this._interruptDetails,{interrupt:this._interrupt,response:t}]),this.orchestrator?.resumeInterrupt(t),this._interrupt=null}load(){this.manager.onLifecycle(this._reset.bind(this))}loaded(){this.manager.onLifecycle(()=>{this.#t.value?.addEventListener("arcgisPromptSelect",this.#d),this.#t.value?.addEventListener("arcgisSubmit",this.#c),this.#t.value?.addEventListener("arcgisCancel",this.#h),this.#t.value?.addEventListener("arcgisFeedback",this.#g);let t=V(()=>!!this._interrupt&&!!this.#s.value,()=>{let i=this.#s.value;i.removeEventListener("arcgisSubmit",this.#n),i.removeEventListener("arcgisCancel",this.#a),i.addEventListener("arcgisSubmit",this.#n,{once:!0}),i.addEventListener("arcgisCancel",this.#a,{once:!0})}),s=this.messages.on("after-add",i=>{let e=i.item;e.role==="assistant"&&(e.error||e.content)&&this.arcgisResponse.emit(e)});return queueMicrotask(()=>{this.#o().then(i=>{i?this.arcgisReady.emit():this._error&&this.arcgisError.emit(new Error(this._error))})}),()=>{t.remove(),s.remove(),this.#t.value?.removeEventListener("arcgisPromptSelect",this.#d),this.#s.value?.removeEventListener("arcgisSubmit",this.#n),this.#s.value?.removeEventListener("arcgisCancel",this.#a),this.#t.value?.removeEventListener("arcgisSubmit",this.#c),this.#t.value?.removeEventListener("arcgisCancel",this.#h),this.#t.value?.removeEventListener("arcgisFeedback",this.#g),this._orchestratorController?.destroy(),this._orchestratorController=null}})}_reset(){this._orchestratorController?.cancel(),this.#e?.abort(),this._interrupt=null,this.messages.removeAll(),this._error=null,this._inputValue="",this._signedInUserId=void 0}_renderEntryMessage(){return this._isSignedIn?this._error?this._renderErrorNotice():this.entryMessage?this.messages.length>0?null:c`<calcite-notice open kind=brand closable icon width=full><div slot=message>${this.entryMessage}</div></calcite-notice>`:c`<slot name=entry-message></slot>`:this._renderSignInNotice()}_renderSignInNotice(){let t=this.#i;return c`<calcite-notice slot=entry-message open kind=brand icon width=full><div slot=message>You need to sign in to use the assistant chat.</div>${t?c`<calcite-link slot=link @click=${async()=>{try{let s=await q.getCredential(`${t.url}/sharing`);this._signedInUserId=s.userId,this._error=null,this.requestUpdate(),await this.#o()?this.arcgisReady.emit():this._error&&this.arcgisError.emit(new Error(this._error))}catch(s){this._error=s?.message??"Error signing in.",this.arcgisError.emit(new Error(this._error)),C("error",this,"Error signing in:",{detail:{error:s}})}}} target=_blank title="Sign in to ArcGIS Online">Sign in</calcite-link>`:c`<div slot=link>No portal information available</div>`}</calcite-notice>`}_renderErrorNotice(){return this._error?c`<calcite-notice slot=entry-message open kind=brand icon width=full>${this._error===Q?c`<div slot=message>${X}</div><calcite-link slot=link .href=${tt} target=_blank title="Learn about web map embeddings">Read more</calcite-link>`:c`<div slot=message>${this._error}</div>`}</calcite-notice>`:null}render(){return c`<calcite-panel .loading=${!this._orchestratorController&&!this._error||this._orchestratorController?.loading} .heading=${this.heading??this._messages.assistantLabel} .description=${this.description} ${y(this.#t)}><slot name=header-actions-start slot=header-actions-start></slot><slot name=header-actions-end slot=header-actions-end></slot><div class="content-container"><arcgis-assistant-chat .loading=${this.awaitingResponse} .messages=${this.messages} .interrupt=${this._interrupt}><slot name=message-starter slot=message-starter></slot><slot name=messages slot=messages>${this.messages.map(t=>t.role==="assistant"?c`<arcgis-assistant-message .message=${t} .feedbackEnabled=${this.feedbackEnabled} .logEnabled=${this.logEnabled} .copyEnabled=${this.copyEnabled} .readAloudEnabled=${this.readAloudEnabled} @arcgisSlottableRequest=${this.#p} .assistantAvatarEnabled=${this.assistantAvatarEnabled}>${t.blocks?.map((s,i)=>c`<slot name=${I(t.id,i)??k} slot=${I(t.id,i)??k}><arcgis-assistant-message-block .block=${s}></arcgis-assistant-message-block></slot>`)}</arcgis-assistant-message>`:c`<arcgis-assistant-user-message .message=${t} .user=${this._user}></arcgis-assistant-user-message>`)}</slot>${this._interrupt?c`<div slot=message-loading><div class="interrupt-waiting-message">waiting for user input...</div></div>`:c`<slot name=message-loading slot=message-loading><arcgis-assistant-message-loading .loading=${this.awaitingResponse} .loadingMessage=${this.awaitingResponseStep} .assistantAvatarEnabled=${this.assistantAvatarEnabled} .interrupts=${this._interruptDetails}></arcgis-assistant-message-loading></slot>`}</arcgis-assistant-chat></div>${this._interrupt?c`<slot name=interrupt><arcgis-assistant-interrupt slot=content-bottom .type=${this._interrupt.type} .message=${this._interrupt.message} .options=${this._interrupt.options} ${y(this.#s)}></arcgis-assistant-interrupt></slot>`:this.suggestedPrompts?.length?c`<div class="suggested-prompts-container" slot=content-bottom><arcgis-assistant-suggested-prompts class="suggested-prompts" .prompts=${this.suggestedPrompts}></arcgis-assistant-suggested-prompts></div>`:null}<div class="footer-container" slot=footer>${this._renderEntryMessage()}<slot name=chat-entry><arcgis-assistant-chat-entry .awaitingResponse=${this.awaitingResponse||this._isAnswering} .inputValue=${this._inputValue} .messages=${this.messages} .voiceInputEnabled=${this.voiceInputEnabled} .disabled=${this._canceling||!this._isSignedIn||!!this._interrupt} ${y(this.#l)}><slot name=entry-actions-start slot=entry-actions-start></slot><slot name=entry-actions-end slot=entry-actions-end><calcite-button .iconStart=${this.awaitingResponse||this._isAnswering?"circle-stop":"send"} @click=${()=>{this.#l.value?.submitMessage()}} round>${this.awaitingResponse||this._isAnswering?this._messages.stopButtonLabel:this._messages.askButtonLabel}</calcite-button></slot></arcgis-assistant-chat-entry></slot><slot name=footer-content></slot></div></calcite-panel>`}};A("arcgis-assistant",x);return x},"core/Collection","core/reactiveUtils","portal/Portal","identity/IdentityManager","config","layers/FeatureLayer","core/Accessor","core/accessorSupport/decorators",a,b)