@arcgis/ai-components 5.2.0-next.114 → 5.2.0-next.116

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 (71) hide show
  1. package/dist/agent-utils/types.d.ts +13 -3
  2. package/dist/cdn/{HXEAVHLM.js → 23CPLCYW.js} +1 -1
  3. package/dist/cdn/{64IWQ7A4.js → 2NODROJN.js} +1 -1
  4. package/dist/cdn/{6P44KOKX.js → 4WYNWR6R.js} +1 -1
  5. package/dist/cdn/{6OOZSZRJ.js → 5QXGQW2N.js} +1 -1
  6. package/dist/cdn/{TGYRNH5D.js → 6KSMVYBS.js} +1 -1
  7. package/dist/cdn/{H5DD7DRB.js → 6XZYQ74A.js} +1 -1
  8. package/dist/cdn/{TAWMLPK2.js → 6YRLY5TX.js} +1 -1
  9. package/dist/cdn/{WSWB3B7B.js → 7ELUGB4X.js} +1 -1
  10. package/dist/cdn/{QXOOEBIR.js → BJNYJCS5.js} +1 -1
  11. package/dist/cdn/{Q5WITJ3L.js → BKAXFQIS.js} +1 -1
  12. package/dist/cdn/{JO7U7E24.js → BN7CIVBD.js} +1 -1
  13. package/dist/cdn/{V6HOUZPZ.js → C7P6MHMZ.js} +1 -1
  14. package/dist/cdn/{PMILRLSD.js → CESQ3SFP.js} +1 -1
  15. package/dist/cdn/{L3K457Y6.js → CLTV27HJ.js} +1 -1
  16. package/dist/cdn/{F5NIRETW.js → CSTXLFCP.js} +1 -1
  17. package/dist/cdn/{HHQTKKYE.js → CVAVY7R2.js} +1 -1
  18. package/dist/cdn/{AKOLZ4JN.js → CZIAU7PC.js} +1 -1
  19. package/dist/cdn/{J3D2JL4H.js → DEPD7PJL.js} +1 -1
  20. package/dist/cdn/{C2RSZ3VK.js → H4N7VNL5.js} +1 -1
  21. package/dist/cdn/{XOULSLM7.js → HAHL6K4X.js} +1 -1
  22. package/dist/cdn/{H4BVWDNV.js → HFHRMM6Q.js} +1 -1
  23. package/dist/cdn/{TAMMDFVT.js → HSILCMAR.js} +1 -1
  24. package/dist/cdn/{4XTSGMV7.js → ITCZC2VY.js} +1 -1
  25. package/dist/cdn/{U7SYNCYR.js → JTEY4E7E.js} +1 -1
  26. package/dist/cdn/{3UEKINYC.js → JTKVVKZK.js} +1 -1
  27. package/dist/cdn/{O4NVW75A.js → K5FWDMTV.js} +1 -1
  28. package/dist/cdn/{EYOWRGDP.js → KPJHQ424.js} +1 -1
  29. package/dist/cdn/{MXTXJKFE.js → KQGC2FCP.js} +1 -1
  30. package/dist/cdn/{YYDZAPJP.js → LDIUJUI7.js} +1 -1
  31. package/dist/cdn/NR2O3AP2.js +2 -0
  32. package/dist/cdn/NWJQ7KTC.js +2 -0
  33. package/dist/cdn/{YR7EYQ4X.js → PGVLC374.js} +1 -1
  34. package/dist/cdn/{SXM4NUT5.js → PQRE67OM.js} +1 -1
  35. package/dist/cdn/QZL4SAYR.js +6 -0
  36. package/dist/cdn/{2642ADON.js → SLD4ZVT6.js} +1 -1
  37. package/dist/cdn/{Y5O6VNSQ.js → UZ6OAU3F.js} +2 -2
  38. package/dist/cdn/{RMLCWLJC.js → VBEZDXBV.js} +1 -1
  39. package/dist/cdn/VJRJ2HAM.js +3 -0
  40. package/dist/cdn/{UDRKUVZP.js → VYOIFJVE.js} +1 -1
  41. package/dist/cdn/{ZGQ27DU2.js → XUYARLRP.js} +1 -1
  42. package/dist/cdn/{CLRFKSAT.js → ZA2WIUWH.js} +1 -1
  43. package/dist/cdn/{LUYP76B7.js → ZCFYGCCV.js} +1 -1
  44. package/dist/cdn/{Y27GVWWU.js → ZGZX7GR5.js} +1 -1
  45. package/dist/cdn/agent-utils/index.js +1 -1
  46. package/dist/cdn/assets/assistant/t9n/messages.en.json +1 -1
  47. package/dist/cdn/assets/assistant-chat-entry/t9n/messages.en.json +1 -1
  48. package/dist/cdn/index.js +1 -1
  49. package/dist/chunks/baseAgentState.js +7 -6
  50. package/dist/chunks/orchestrator.js +9 -6
  51. package/dist/components/arcgis-assistant/customElement.d.ts +23 -3
  52. package/dist/components/arcgis-assistant/customElement.js +213 -187
  53. package/dist/components/arcgis-assistant/types.d.ts +108 -0
  54. package/dist/components/arcgis-assistant-chat-entry/customElement.d.ts +15 -4
  55. package/dist/components/arcgis-assistant-chat-entry/customElement.js +344 -45
  56. package/dist/components/arcgis-assistant-chat-entry/index.js +3 -0
  57. package/dist/docs/api.json +1 -1
  58. package/dist/docs/docs.json +1 -1
  59. package/dist/docs/vscode.html-custom-data.json +1 -1
  60. package/dist/docs/web-types.json +1 -1
  61. package/dist/loader.js +2 -2
  62. package/dist/types/lumina.d.ts +2 -2
  63. package/dist/types/preact.d.ts +2 -2
  64. package/dist/types/react.d.ts +2 -2
  65. package/dist/types/stencil.d.ts +2 -2
  66. package/dist/utils/index.d.ts +20 -0
  67. package/package.json +5 -5
  68. package/dist/cdn/2O4DON37.js +0 -2
  69. package/dist/cdn/AXY6RA5N.js +0 -3
  70. package/dist/cdn/FS7GXTTQ.js +0 -6
  71. package/dist/cdn/RLEHNAIA.js +0 -2
@@ -1,2 +1,2 @@
1
1
  /* COPYRIGHT Esri - https://js.arcgis.com/5.2/LICENSE.txt */
2
- import a from"./H4BVWDNV.js";import"./CLRFKSAT.js";import"./FS7GXTTQ.js";import"./LOQ2PKV5.js";import"./IYLFJCJ2.js";import"./MWYBF3F3.js";import"./UZLQALHY.js";export default $arcgis.t(([{property:l,subclass:w},{c:p,d:d}])=>{var y=Object.defineProperty,m=Object.getOwnPropertyDescriptor,f=e=>{throw TypeError(e)},h=(e,t,o,n)=>{for(var r=n>1?void 0:n?m(t,o):t,s=e.length-1,g;s>=0;s--)(g=e[s])&&(r=(n?g(t,o,r):g(r))||r);return n&&r&&y(t,o,r),r},k=(e,t,o)=>t.has(e)||f("Cannot "+o),b=(e,t,o)=>t.has(e)?f("Cannot add the same private member more than once"):t instanceof WeakSet?t.add(e):t.set(e,o),c=(e,t,o)=>(k(e,t,"access private method"),o),a,i,u=class extends d{constructor(e){super(e),b(this,a)}getAgents(){return c(this,a,i).call(this),[this.routerAgent,...Object.values(this.agentsMap)]}buildEdges(e){c(this,a,i).call(this);let t=p(this.routerAgent,0),o=new Map;for(let[n,[r]]of Object.entries(this.agentsMap).entries())o.set(r,p(e[n+1],n+1));return[{from:t,decide:n=>{let r=n[this.routerOutputKey];if(typeof r!="string"||!r)throw new Error("RouterWorkflow decideRoute could not determine next agent from state.");let s=o.get(r);if(!s)throw new Error(`RouterWorkflow decideRoute returned unknown agent: ${r}. Expected one of: ${Object.keys(this.agentsMap).join(", ")||"(none)"}.`);return s}}]}getEntryNode(){return c(this,a,i).call(this),p(this.routerAgent,0)}isTerminalAgent(e,t){return t>0}validateAgents(e){c(this,a,i).call(this),super.validateAgents(e)}};a=new WeakSet;i=function(){if(!Object.keys(this.agentsMap).length)throw new Error("RouterWorkflow requires a non-empty agentsMap.")};h([l()],u.prototype,"agentsMap",2);h([l()],u.prototype,"routerAgent",2);h([l()],u.prototype,"routerOutputKey",2);u=h([w("RouterWorkflow")],u);return u},"core/accessorSupport/decorators",a)
2
+ import a from"./HFHRMM6Q.js";import"./ZA2WIUWH.js";import"./QZL4SAYR.js";import"./LOQ2PKV5.js";import"./IYLFJCJ2.js";import"./MWYBF3F3.js";import"./UZLQALHY.js";export default $arcgis.t(([{property:l,subclass:w},{c:p,d:d}])=>{var y=Object.defineProperty,m=Object.getOwnPropertyDescriptor,f=e=>{throw TypeError(e)},h=(e,t,o,n)=>{for(var r=n>1?void 0:n?m(t,o):t,s=e.length-1,g;s>=0;s--)(g=e[s])&&(r=(n?g(t,o,r):g(r))||r);return n&&r&&y(t,o,r),r},k=(e,t,o)=>t.has(e)||f("Cannot "+o),b=(e,t,o)=>t.has(e)?f("Cannot add the same private member more than once"):t instanceof WeakSet?t.add(e):t.set(e,o),c=(e,t,o)=>(k(e,t,"access private method"),o),a,i,u=class extends d{constructor(e){super(e),b(this,a)}getAgents(){return c(this,a,i).call(this),[this.routerAgent,...Object.values(this.agentsMap)]}buildEdges(e){c(this,a,i).call(this);let t=p(this.routerAgent,0),o=new Map;for(let[n,[r]]of Object.entries(this.agentsMap).entries())o.set(r,p(e[n+1],n+1));return[{from:t,decide:n=>{let r=n[this.routerOutputKey];if(typeof r!="string"||!r)throw new Error("RouterWorkflow decideRoute could not determine next agent from state.");let s=o.get(r);if(!s)throw new Error(`RouterWorkflow decideRoute returned unknown agent: ${r}. Expected one of: ${Object.keys(this.agentsMap).join(", ")||"(none)"}.`);return s}}]}getEntryNode(){return c(this,a,i).call(this),p(this.routerAgent,0)}isTerminalAgent(e,t){return t>0}validateAgents(e){c(this,a,i).call(this),super.validateAgents(e)}};a=new WeakSet;i=function(){if(!Object.keys(this.agentsMap).length)throw new Error("RouterWorkflow requires a non-empty agentsMap.")};h([l()],u.prototype,"agentsMap",2);h([l()],u.prototype,"routerAgent",2);h([l()],u.prototype,"routerOutputKey",2);u=h([w("RouterWorkflow")],u);return u},"core/accessorSupport/decorators",a)
@@ -0,0 +1,2 @@
1
+ /* COPYRIGHT Esri - https://js.arcgis.com/5.2/LICENSE.txt */
2
+ import{b as $}from"./5QXGQW2N.js";import"./NWJQ7KTC.js";import{g as b,h as u,n as v,t as m,u as f,v as w,w as _,z as S}from"./COH3QXWG.js";import"./R74ZHFA6.js";import"./UZLQALHY.js";export default $arcgis.t(([q])=>{var R=b`:host{--calcite-text-area-border-color: var(--calcite-color-border-1);--calcite-text-area-divider-color: var(--calcite-color-border-1);--calcite-text-area-corner-radius: var(--calcite-border-radius)}.input-container{display:flex;flex-direction:column}.footer-start{display:flex;gap:var(--calcite-spacing-md);flex-wrap:wrap;align-items:center}.footer-end{display:flex;gap:var(--calcite-spacing-md);align-items:center}.focused{--calcite-text-area-shadow: var(--calcite-shadow-sm)}.suggestions-loading{padding:var(--calcite-spacing-sm)}`,P={suggestions:[],loading:!1,selectedIndex:0};function I(c){return c.filter(({trigger:t})=>t!==""&&t!=="/").sort((t,e)=>e.trigger.length-t.trigger.length)}var y=class{constructor(t){this._onStateChange=t}#t=null;#o;#e=P;get state(){return this.#e}get activeSuggestion(){return this.#o}get selectedSuggestion(){return this.#e.suggestions[this.#e.selectedIndex]}moveSelection(t){this.#a({selectedIndex:Math.max(0,Math.min(this.#e.selectedIndex+t,this.#e.suggestions.length-1))})}async update(t,e,i){this.#t?.abort();let s=this.#i(t,e,i);if(!s){this.close();return}let n=new AbortController;this.#t=n,this.#o=s,this.#a({suggestions:[],loading:!0,selectedIndex:0});try{let r=await s.provider.getSuggestions(s.query,n.signal);if(n.signal.aborted||this.#t!==n)return;this.#a({suggestions:r,loading:!1,selectedIndex:0})}catch{n.signal.aborted||this.close()}}async resolveTypedInputs(t,e,i,s){let n=await this.#s(t,e.commandProvider,i,s);return s.aborted?[]:(n.push(...await this.#r(t,e.entityProviders,i,s)),n)}close(){this.#t?.abort(),this.#t=null,this.#o=void 0,this.#a({suggestions:[],loading:!1,selectedIndex:0})}#i(t,e,i){if(e==null)return;let s=t.slice(0,e),n=s.slice(1);if(i.commandProvider&&s.startsWith("/")&&!/\s/u.test(n))return{kind:"command",provider:i.commandProvider,start:0,end:e,query:n};let r=I(i.entityProviders);for(let a of r){let l=s.lastIndexOf(a.trigger),o=s.slice(l+a.trigger.length);if(l!==-1&&a.trigger&&!/\s/u.test(o)&&(l===0||/\s/u.test(s[l-1]??"")))return{kind:"entity",provider:a,start:l,end:e,query:o}}}async#s(t,e,i,s){let n=/^\/([^\s]+)/u.exec(t);if(!n||!e)return[];let[r,a]=n;if(i.some(h=>h.start===0&&h.end===r.length))return[];let l=await e.getSuggestions(a,s);if(s.aborted)return[];let o=l.find(h=>h.id===a);return o?[{start:0,end:r.length,part:{kind:"command",id:o.id,label:o.label,agentId:o.agentId,requiresText:o.requiresText||void 0,data:o.data}}]:[]}async#r(t,e,i,s){let n=I(e),r=[];for(let a of t.matchAll(/(?:^|\s)(\S+)/gu)){let l=a[1],o=n.find(g=>l.startsWith(g.trigger));if(!o)continue;let h=a.index+a[0].length-l.length;if(i.some(g=>g.start===h&&g.end===h+l.length))continue;let d=l.slice(o.trigger.length);if(!d)continue;let k=await o.getSuggestions(d,s);if(s.aborted)return[];let p=k.find(g=>g.id===d);p&&r.push({start:h,end:h+l.length,part:{kind:"entity",providerId:o.id,trigger:o.trigger,id:p.id,label:p.label,data:p.data}})}return r}#a(t){this.#e={...this.#e,...t},this._onStateChange(this.#e)}};function V(c,t,e,i){if(c===t&&!i)return[...e];let s=0,n=Math.min(c.length,t.length,i?.start??c.length);for(;s<n&&c[s]===t[s];)s+=1;let r=c.length,a=t.length,l=Math.max(s,i?.end??s);for(;r>l&&a>s&&c[r-1]===t[a-1];)r-=1,a-=1;let o=a-r;return e.flatMap(h=>{let d=h.end<=s?h:h.start>=r?{...h,start:h.start+o,end:h.end+o}:void 0;return d&&(d.part.kind!=="command"||d.start===0)&&(d.start===0||/\s/u.test(t[d.start-1]))&&(d.end===t.length||/\s/u.test(t[d.end]))?[d]:[]})}function D(c,t){for(let e of[...t].reverse())e.part.kind==="command"&&(c=c.slice(0,e.start)+c.slice(e.end).replace(/^[\t ]+/u,""));return c.trim()}function E(c,t){let e=0;return t.flatMap(i=>{let s=i.kind==="command"?`/${i.id}`:`${i.trigger}${i.id}`,n=c.indexOf(s,e);return n===-1?[]:(e=n+s.length,[{start:n,end:e,part:i}])})}var x=class extends w{constructor(){super(...arguments),this.#t=m(),this.#o=m(),this.#i=new y(t=>this._suggestionState=t),this.#s=[],this.#r="",this.#a="",this.#d=()=>{let t=this.#t.value?.shadowRoot?.querySelector("textarea");this.#l=t?{start:t.selectionStart,end:t.selectionEnd}:void 0},this.#c=t=>{t.stopPropagation();let e=t.detail;this._setDraftValue(e.value),e.focusInput&&this.#t.value&&this.#t.value.setFocus()},this.#u=t=>{let e=t.target.value??"",i=this.#l;this.#l=void 0,this.#h(e,i),this.inputValue=e;let s=this.#t.value?.shadowRoot?.querySelector("textarea")?.selectionStart;this.#i.update(e,s,{commandProvider:this.commandProvider,entityProviders:this.entityProviders??[]})},this.#g=async t=>{if(!(t.altKey||t.ctrlKey||t.metaKey||t.shiftKey||this.keyboardShortcutsDisabled)){if(this._suggestionState.suggestions.length>0){if(t.key==="ArrowDown"){t.preventDefault(),this.#i.moveSelection(1);return}if(t.key==="ArrowUp"){t.preventDefault(),this.#i.moveSelection(-1);return}if(t.key==="Enter"){t.preventDefault(),await this.#f(this.#i.selectedSuggestion);return}if(t.key==="Escape"){t.preventDefault(),this.#i.close();return}}switch(t.key){case"Enter":t.preventDefault(),await this.submitMessage();break;case"ArrowUp":await this._navigateHistory("up",t);break;case"ArrowDown":await this._navigateHistory("down",t);break}}},this._messages=$({blocking:!0}),this._inFocus=!1,this._suggestionState=this.#i.state,this._textRequired=!1,this.keyboardShortcutsDisabled=!1,this.awaitingResponse=!1,this.voiceInputEnabled=!1,this.messages=new q([]),this.disabled=!1,this.entityProviders=[],this.arcgisCancel=v(),this.arcgisSubmit=v({cancelable:!0})}static{this.properties={_inFocus:16,_suggestionState:16,_textRequired:16,keyboardShortcutsDisabled:5,entryPlaceholder:1,awaitingResponse:5,inputValue:1,status:1,voiceInputEnabled:5,messages:0,disabled:5,commandProvider:0,entityProviders:0}}static{this.styles=R}#t;#o;#e;#i;#s;#r;#a;#n;#l;#d;#c;#u;#g;get inputValue(){return this.#a}set inputValue(t){t!==this.#a&&(this.#a=t,this.#n?.abort(),this.#n=void 0)}async submitMessage(){if(this.awaitingResponse){this.#n?.abort(),this.#n=void 0,this.arcgisCancel.emit();return}let t=this.inputValue;this.#h(t),this.#n?.abort();let e=new AbortController;this.#n=e;let i;try{if(i=await this.#i.resolveTypedInputs(t,{commandProvider:this.commandProvider,entityProviders:this.entityProviders??[]},this.#s,e.signal),e.signal.aborted||this.#n!==e)return}catch(a){if(e.signal.aborted)return;throw a}finally{this.#n===e&&(this.#n=void 0)}this.#s.push(...i.filter(a=>!this.#s.some(l=>l.start===a.start&&l.end===a.end)));let s=D(t,this.#s);if(this._textRequired=!s&&this.#s.some(a=>a.part.kind==="command"&&(a.part.requiresText??!1)),this._textRequired){await this.#t.value?.setFocus();return}let n=this.#p();if(!s&&n.length===0)return;let r={prompt:s,displayText:t.trim(),parts:n};this.arcgisSubmit.emit(r.parts.length?r:s).defaultPrevented||(this.inputValue="",this.#s=[],this.#r="",this.#e=void 0,this.#i.close(),this.#o.value?.clearDraftSession(),this.#t.value&&await this.#t.value.setFocus())}loaded(){this.manager.onLifecycle(()=>(this.el.addEventListener("arcgisVoiceInputDraftChange",this.#c),{remove:()=>{this.el.removeEventListener("arcgisVoiceInputDraftChange",this.#c)}}))}async _navigateHistory(t,e){let i=this.#t.value;if(!i)return;let s=this.messages.toArray().filter(h=>h.role==="user");if(s.length===0)return;let n=i.value??"",r=i.shadowRoot?.querySelector("textarea"),a=r?.selectionStart,l=r?.selectionEnd;if(a==null||l==null||a!==l||t==="up"&&a!==0||t==="down"&&a!==n.length)return;if(t==="up"){this.#e?this.#e.index=Math.max(0,this.#e.index-1):this.#e={index:s.length-1,draft:this.#y()},this.#v(s[this.#e.index]),e.preventDefault();return}let o=this.#e;o&&(o.index<s.length-1?(o.index+=1,this.#v(s[o.index])):(this.#e=void 0,this.#m(o.draft)),e.preventDefault())}#y(){return this.#h(this.inputValue),{value:this.inputValue,parts:this.#p()}}#p(){return this.#s.map(t=>t.part)}#v(t){let e=t.parts??[];this.#m({value:t.content,parts:e})}#m(t){this.inputValue=t.value,this.#r=t.value,this.#s=E(t.value,t.parts),this.#l=void 0,this._textRequired=!1,this.#i.close()}_setDraftValue(t){this.#i.close(),this.#s=[],this.#r=t,this.#l=void 0,this._textRequired=!1,this.inputValue=t,this.#e=void 0}#h(t,e){this._textRequired=!1,this.#s=V(this.#r,t,this.#s,e),this.#r=t}async#f(t){let e=this.#i.activeSuggestion;if(!t||!e)return;let i=`${e.kind==="command"?"/":e.provider.trigger}${t.id}`,s=`${this.inputValue.slice(0,e.start)}${i} ${this.inputValue.slice(e.end)}`;this.#h(s),this.#s.push({start:e.start,end:e.start+i.length,part:e.kind==="command"?{kind:"command",id:t.id,label:t.label,agentId:"agentId"in t?t.agentId:void 0,requiresText:"requiresText"in t&&t.requiresText||void 0,data:t.data}:{kind:"entity",providerId:e.provider.id,trigger:e.provider.trigger,id:t.id,label:t.label,data:t.data}}),this.#s.sort((a,l)=>a.start-l.start),this.inputValue=s,this.#e=void 0;let n=e.start+i.length+1;this.#i.close(),await this.updateComplete,await this.#t.value?.setFocus();let r=this.#t.value?.shadowRoot?.querySelector("textarea");r&&(r.selectionStart=n,r.selectionEnd=n)}_onFocusIn(){this._inFocus=!0}_onFocusOut(){this._inFocus=!1}#x(t){return t?u`<calcite-popover .open=${this._suggestionState.suggestions.length>0||this._suggestionState.loading} placement=top-start .label=${this._messages.suggestions} .referenceElement=${t} trigger-disabled pointer-disabled focus-trap-disabled><calcite-list .label=${this._messages.suggestions} selection-appearance=highlight selection-mode=single-persist .loading=${this._suggestionState.loading}>${this._suggestionState.loading?null:this._suggestionState.suggestions.map((e,i)=>u`<calcite-list-item .label=${e.label} .description=${e.description} .selected=${i===this._suggestionState.selectedIndex} @click=${()=>{this.#f(e)}}></calcite-list-item>`)}</calcite-list>${this._suggestionState.loading?u`<div class="suggestions-loading" role=status>${this._messages.loadingSuggestions}</div>`:null}</calcite-popover>`:null}render(){let t=this.#t.value;return u`<div class="input-container">${this._textRequired?u`<div role=alert>${this._messages.textRequired}</div>`:null}<calcite-text-area class=${_({focused:this._inFocus})} .value=${this.inputValue} .placeholder=${this.entryPlaceholder??this._messages.entryPlaceholder} resize=vertical @calciteTextAreaInput=${this.#u} @beforeinput=${this.#d} .status=${this._textRequired?"invalid":"idle"} .disabled=${this.disabled} @keydown=${this.#g} @focusin=${this._onFocusIn} @focusout=${this._onFocusOut} ${f(this.#t)}><div slot=footer-start class="footer-start"><slot name=entry-actions-start></slot></div><div slot=footer-end class="footer-end">${this.voiceInputEnabled?u`<arcgis-assistant-speech-input .awaitingResponse=${this.awaitingResponse} .inputValue=${this.inputValue} ${f(this.#o)}></arcgis-assistant-speech-input>`:null}<slot name=entry-actions-end></slot></div></calcite-text-area>${this.#x(t)}</div>`}};S("arcgis-assistant-chat-entry",x);return x},"core/Collection")
@@ -0,0 +1,2 @@
1
+ /* COPYRIGHT Esri - https://js.arcgis.com/5.2/LICENSE.txt */
2
+ var d=(s,t)=>{let e=s;for(;e;){if(e===t)return!0;if(!e.parentNode)return!1;e.parentNode instanceof ShadowRoot?e=e.parentNode.host:e=e.parentNode}return!1},u=(s,t,e)=>{let n=g(t).subscribe;return n(o=>{o.some(a=>d(s,a.target))&&e()})},l={},g=s=>{let t=s.join(","),e=l[t];if(e!==void 0)return e;let n=new Set,o=new MutationObserver(a=>n.forEach(c=>c(a)));globalThis.document&&o.observe(document.documentElement,{attributes:!0,attributeFilter:s,subtree:!0});let r={subscribe:a=>(n.add(a),()=>{n.delete(a),n.size===0&&(o.disconnect(),l[t]=void 0)})};return l[t]=r,r},i=(s,t)=>{let e=s;for(;e;){let n=e.closest?.(t);if(n)return n;let o=e.getRootNode?.();if(o===globalThis.document)return;e=o?.host}};var m=(s,t,e)=>i(s,`[${t}]`)?.getAttribute(t)??e;export{u as a,i as b,m as c};
@@ -1,2 +1,2 @@
1
1
  /* COPYRIGHT Esri - https://js.arcgis.com/5.2/LICENSE.txt */
2
- import n from"./TGYRNH5D.js";import m from"./XOULSLM7.js";import{a as o,c as p}from"./V6HOUZPZ.js";import"./4PKMJMND.js";import l from"./VWP2B4LB.js";import"./5Q2XRQS6.js";import k from"./K7YQIJFT.js";import j from"./UT6JA4TK.js";import h from"./CA3RNGPN.js";import g from"./ES54NWOB.js";import f from"./CCC6LBMY.js";import"./34O57OGV.js";import"./LXPGQNXQ.js";import"./FDOMMK2M.js";import e from"./WVP73XWD.js";import"./Z5XQLSYH.js";import"./OZAZ277H.js";import d from"./AVRS6UCQ.js";import"./K5JVB6FU.js";import"./FCI6M62J.js";import"./BFZ5S7NF.js";import"./3UEKINYC.js";import"./RLEHNAIA.js";import c from"./64IWQ7A4.js";import"./FS7GXTTQ.js";import"./WXQ26G5Q.js";import"./MJSIYEWN.js";import b from"./JNOH4PD5.js";import a from"./KA3S22NQ.js";import"./ONQ6JSBJ.js";import{v as i,z as r}from"./COH3QXWG.js";import"./R74ZHFA6.js";import"./V7Y22FRP.js";import"./AXTQU5YL.js";import"./LOQ2PKV5.js";import"./IYLFJCJ2.js";import"./VXFQANGJ.js";import"./MWYBF3F3.js";import"./UZLQALHY.js";export default $arcgis.t(([,,,,,,,,,,,,,,,,,,,,,,m])=>{var t=class extends i{constructor(){super(...arguments),this.agent=m}static{this.properties={referenceElement:1}}#t;#i;getContext(){if(!this.#t)throw new Error("arcgis-assistant-data-exploration-agent requires a mapView");return{mapView:this.#t}}load(){this.#t=o(this,"arcgis-assistant-data-exploration-agent"),this.#i=p(this)}disconnectedCallback(){this.#i?.unregister(this.agent.id),super.disconnectedCallback()}};r("arcgis-assistant-data-exploration-agent",t);return t},"identity/IdentityManager","portal/Portal","request","config","core/reactiveUtils","layers/FeatureLayer","intl","smartMapping/statistics/summaryStatistics","smartMapping/statistics/uniqueValues","rest/knowledgeGraphService",a,b,c,d,e,f,g,h,j,k,l,m,n)
2
+ import n from"./6KSMVYBS.js";import m from"./HAHL6K4X.js";import{a as o,c as p}from"./C7P6MHMZ.js";import"./4PKMJMND.js";import l from"./VWP2B4LB.js";import"./5Q2XRQS6.js";import k from"./K7YQIJFT.js";import j from"./UT6JA4TK.js";import h from"./CA3RNGPN.js";import g from"./ES54NWOB.js";import f from"./CCC6LBMY.js";import"./34O57OGV.js";import"./LXPGQNXQ.js";import"./FDOMMK2M.js";import e from"./WVP73XWD.js";import"./Z5XQLSYH.js";import"./OZAZ277H.js";import d from"./AVRS6UCQ.js";import"./K5JVB6FU.js";import"./FCI6M62J.js";import"./BFZ5S7NF.js";import"./JTKVVKZK.js";import"./NWJQ7KTC.js";import c from"./2NODROJN.js";import"./QZL4SAYR.js";import"./WXQ26G5Q.js";import"./MJSIYEWN.js";import b from"./JNOH4PD5.js";import a from"./KA3S22NQ.js";import"./ONQ6JSBJ.js";import{v as i,z as r}from"./COH3QXWG.js";import"./R74ZHFA6.js";import"./V7Y22FRP.js";import"./AXTQU5YL.js";import"./LOQ2PKV5.js";import"./IYLFJCJ2.js";import"./VXFQANGJ.js";import"./MWYBF3F3.js";import"./UZLQALHY.js";export default $arcgis.t(([,,,,,,,,,,,,,,,,,,,,,,m])=>{var t=class extends i{constructor(){super(...arguments),this.agent=m}static{this.properties={referenceElement:1}}#t;#i;getContext(){if(!this.#t)throw new Error("arcgis-assistant-data-exploration-agent requires a mapView");return{mapView:this.#t}}load(){this.#t=o(this,"arcgis-assistant-data-exploration-agent"),this.#i=p(this)}disconnectedCallback(){this.#i?.unregister(this.agent.id),super.disconnectedCallback()}};r("arcgis-assistant-data-exploration-agent",t);return t},"identity/IdentityManager","portal/Portal","request","config","core/reactiveUtils","layers/FeatureLayer","intl","smartMapping/statistics/summaryStatistics","smartMapping/statistics/uniqueValues","rest/knowledgeGraphService",a,b,c,d,e,f,g,h,j,k,l,m,n)
@@ -1,2 +1,2 @@
1
1
  /* COPYRIGHT Esri - https://js.arcgis.com/5.2/LICENSE.txt */
2
- import{b as c}from"./6OOZSZRJ.js";import"./RLEHNAIA.js";import{g as i,h as s,n as r,v as a,z as p}from"./COH3QXWG.js";import"./R74ZHFA6.js";import"./UZLQALHY.js";var l=i`:host{display:block;max-width:100%}.group{max-width:100%}.prompt{max-width:100%;overflow:hidden;text-overflow:ellipsis;white-space:nowrap;font-style:normal;cursor:pointer;font-weight:var(--calcite-font-weight-regular)}calcite-chip{max-width:100%}`,e=class extends a{constructor(){super(...arguments),this._messages=c({blocking:!0}),this.prompts=[],this.arcgisPromptSelect=r()}static{this.properties={label:1,prompts:0}}static{this.styles=l}_emitPromptSelect(t){this.arcgisPromptSelect.emit({prompt:t})}render(){return this.prompts.length?s`<calcite-chip-group class="group" .label=${this.label??this._messages.suggestedPromptsLabel}>${this.prompts.map(t=>s`<calcite-chip .value=${t} .label=${t} appearance=outline-fill kind=brand @calciteChipSelect=${()=>this._emitPromptSelect(t)}><div class="prompt">${t}</div></calcite-chip>`)}</calcite-chip-group>`:null}};p("arcgis-assistant-suggested-prompts",e);export{e as ArcgisAssistantSuggestedPrompts};
2
+ import{b as c}from"./5QXGQW2N.js";import"./NWJQ7KTC.js";import{g as i,h as s,n as r,v as a,z as p}from"./COH3QXWG.js";import"./R74ZHFA6.js";import"./UZLQALHY.js";var l=i`:host{display:block;max-width:100%}.group{max-width:100%}.prompt{max-width:100%;overflow:hidden;text-overflow:ellipsis;white-space:nowrap;font-style:normal;cursor:pointer;font-weight:var(--calcite-font-weight-regular)}calcite-chip{max-width:100%}`,e=class extends a{constructor(){super(...arguments),this._messages=c({blocking:!0}),this.prompts=[],this.arcgisPromptSelect=r()}static{this.properties={label:1,prompts:0}}static{this.styles=l}_emitPromptSelect(t){this.arcgisPromptSelect.emit({prompt:t})}render(){return this.prompts.length?s`<calcite-chip-group class="group" .label=${this.label??this._messages.suggestedPromptsLabel}>${this.prompts.map(t=>s`<calcite-chip .value=${t} .label=${t} appearance=outline-fill kind=brand @calciteChipSelect=${()=>this._emitPromptSelect(t)}><div class="prompt">${t}</div></calcite-chip>`)}</calcite-chip-group>`:null}};p("arcgis-assistant-suggested-prompts",e);export{e as ArcgisAssistantSuggestedPrompts};
@@ -0,0 +1,6 @@
1
+ /* COPYRIGHT Esri - https://js.arcgis.com/5.2/LICENSE.txt */
2
+ import{ka as r}from"./LOQ2PKV5.js";var a=(e,t)=>t,d=(e,t)=>({...e,...t}),o=(e="",t)=>{let s=typeof t=="string"?t.trim():"";if(!s)return e;let u=e.trim();if(!u)return s;if(u===s)return e;let n=u.split(`
3
+
4
+ `);return n[n.length-1]?.trim()===s?e:`${e}
5
+
6
+ ${s}`},i=()=>({userRequest:"",inputParts:[],assignedTask:"",messages:[],priorSteps:[],sharedState:{},sharedResources:[]}),c=()=>({agentExecutionContext:r({reducer:d,default:i}),outputMessage:r({reducer:o,default:()=>""}),summary:r({reducer:a,default:()=>""}),status:r({reducer:a}),sharedStatePatch:r({reducer:a}),sharedResourceAdditions:r({reducer:a})}),f=()=>c();export{a,d as b,o as c,i as d,c as e,f};
@@ -1,2 +1,2 @@
1
1
  /* COPYRIGHT Esri - https://js.arcgis.com/5.2/LICENSE.txt */
2
- import{a as u,b as g,c as S}from"./P4XZMBU5.js";import a from"./LUYP76B7.js";import{d as m,e as f}from"./CLRFKSAT.js";import"./FS7GXTTQ.js";import{P as p}from"./LOQ2PKV5.js";import"./IYLFJCJ2.js";import"./MWYBF3F3.js";import"./UZLQALHY.js";export default $arcgis.t(([{property:h,subclass:l},{watch:w},d])=>{var v=Object.defineProperty,y=Object.getOwnPropertyDescriptor,o=(t,e,s,r)=>{for(var i=r>1?void 0:r?y(e,s):e,a=t.length-1,c;a>=0;a--)(c=t[a])&&(i=(r?c(e,s,i):c(i))||i);return r&&i&&v(e,s,i),i},n=class extends d{constructor(t){super(t)}initialize(){this.addHandles(w(()=>[this.name,this.description,this.inputSchema,this.outputSchema,this.execute],()=>{this.generate()},{initial:!0,sync:!0}))}getSchemas(){return[this.inputSchema,this.outputSchema].filter(Boolean)}generate(){let t=m(this.getSchemas());this._set("workspace",t);let e=`${this.id}-execute`,s={[e]:this._invokeExecuteNode.bind(this)},r=[{from:e,decide:()=>{}}];this._set("createGraph",()=>f(s,r,t,{agent:this,entryNode:e,middlewares:this.middlewares}))}async _invokeExecuteNode(t,e){try{return this.outputSchema?await this._invokeStructured(t,e):await this._invokeUnstructured(t,e)}catch(s){if(p(s))throw s;let r=s instanceof Error?s.message:String(s);return u({outputMessage:r},"failed",r)}}async _invokeStructured(t,e){if(!this.outputSchema)throw new Error("Output schema is required for structured invocation.");let s=this._validateInputState(t),r=await this.execute(s,e);if(typeof r=="string")throw new Error("Expected execute function to return an object matching the output schema, but received a string.");return g(r,this.outputSchema,t.agentExecutionContext.messages)}async _invokeUnstructured(t,e){let s=this._validateInputState(t),r=await this.execute(s,e),i=typeof r=="string"?r:JSON.stringify(r),a=i.trim()||"FunctionAgent completed.";return u({outputMessage:i},"success",a)}_validateInputState(t){if(!this.inputSchema)return t;let e=this.inputSchema.safeParse(S(t,this.inputSchema));if(!e.success)throw new Error(`FunctionAgent input schema validation failed: ${e.error.message}`);return{...t,...e.data}}};o([h()],n.prototype,"inputSchema",2);o([h()],n.prototype,"outputSchema",2);o([h()],n.prototype,"execute",2);n=o([l("FunctionAgent")],n);return n},"core/accessorSupport/decorators","core/reactiveUtils",a)
2
+ import{a as u,b as g,c as S}from"./P4XZMBU5.js";import a from"./ZCFYGCCV.js";import{d as m,e as f}from"./ZA2WIUWH.js";import"./QZL4SAYR.js";import{P as p}from"./LOQ2PKV5.js";import"./IYLFJCJ2.js";import"./MWYBF3F3.js";import"./UZLQALHY.js";export default $arcgis.t(([{property:h,subclass:l},{watch:w},d])=>{var v=Object.defineProperty,y=Object.getOwnPropertyDescriptor,o=(t,e,s,r)=>{for(var i=r>1?void 0:r?y(e,s):e,a=t.length-1,c;a>=0;a--)(c=t[a])&&(i=(r?c(e,s,i):c(i))||i);return r&&i&&v(e,s,i),i},n=class extends d{constructor(t){super(t)}initialize(){this.addHandles(w(()=>[this.name,this.description,this.inputSchema,this.outputSchema,this.execute],()=>{this.generate()},{initial:!0,sync:!0}))}getSchemas(){return[this.inputSchema,this.outputSchema].filter(Boolean)}generate(){let t=m(this.getSchemas());this._set("workspace",t);let e=`${this.id}-execute`,s={[e]:this._invokeExecuteNode.bind(this)},r=[{from:e,decide:()=>{}}];this._set("createGraph",()=>f(s,r,t,{agent:this,entryNode:e,middlewares:this.middlewares}))}async _invokeExecuteNode(t,e){try{return this.outputSchema?await this._invokeStructured(t,e):await this._invokeUnstructured(t,e)}catch(s){if(p(s))throw s;let r=s instanceof Error?s.message:String(s);return u({outputMessage:r},"failed",r)}}async _invokeStructured(t,e){if(!this.outputSchema)throw new Error("Output schema is required for structured invocation.");let s=this._validateInputState(t),r=await this.execute(s,e);if(typeof r=="string")throw new Error("Expected execute function to return an object matching the output schema, but received a string.");return g(r,this.outputSchema,t.agentExecutionContext.messages)}async _invokeUnstructured(t,e){let s=this._validateInputState(t),r=await this.execute(s,e),i=typeof r=="string"?r:JSON.stringify(r),a=i.trim()||"FunctionAgent completed.";return u({outputMessage:i},"success",a)}_validateInputState(t){if(!this.inputSchema)return t;let e=this.inputSchema.safeParse(S(t,this.inputSchema));if(!e.success)throw new Error(`FunctionAgent input schema validation failed: ${e.error.message}`);return{...t,...e.data}}};o([h()],n.prototype,"inputSchema",2);o([h()],n.prototype,"outputSchema",2);o([h()],n.prototype,"execute",2);n=o([l("FunctionAgent")],n);return n},"core/accessorSupport/decorators","core/reactiveUtils",a)
@@ -1,3 +1,3 @@
1
1
  /* COPYRIGHT Esri - https://js.arcgis.com/5.2/LICENSE.txt */
2
- import a from"./64IWQ7A4.js";import{b as E}from"./R74ZHFA6.js";import{a as p}from"./V7Y22FRP.js";import{P as M,Ya as D,ea as _,r as k,s as $}from"./LOQ2PKV5.js";import{Ia as S,ca as I,ta as b}from"./IYLFJCJ2.js";export default $arcgis.t(([N,P,T,G,z,{a:C,c:A,d:W,e:R,f:L,m:q}])=>{var B=async e=>{let t=await Q(),n=await C("default"),s=P.getDefault(),r=(await N.getCredential(`${s.url}/sharing`)).token,a={type:"generateEmbeddings",webmapEmbeddings:e,auth:{apiUrl:n,token:r}};return t.postMessage(a),await new Promise((i,o)=>{let d=u=>{u.data==="completed"&&(t.removeEventListener("message",d),i())},c=u=>{t.removeEventListener("message",d),o(u instanceof Error?u:new Error("Embeddings worker error"))};t.addEventListener("message",d),t.addEventListener("error",c,{once:!0})}),t},Q=async()=>{{let e=(await import("./OKVLGJAG.js")).default;return new e}},J=e=>{e.currentIntent="none"},K=async(e,t)=>{let n=R(t);if(e.agentExecutionContext.userRequest){let r=new I(e.agentExecutionContext.userRequest.trim());e.agentExecutionContext.messages=[...e.agentExecutionContext.messages,r],J(e)}let s=n?.services.agentRegistry.list().map(r=>r.agent.id)??[];return await p({text:`Available agents: ${[...s].join(", ")}`},t),await p({text:"Analyzing user input"},t),e},V=async(e,t)=>(await p({text:"Exiting..."},t),e),F=e=>typeof e=="object"&&e!==null&&!Array.isArray(e),X=(e,t)=>{if(!F(e)){e!==void 0&&console.warn(`Agent "${t}" returned invalid sharedStatePatch. Ignoring it.`);return}let n={};for(let[s,r]of Object.entries(e)){if(!F(r)||!("value"in r)){console.warn(`Agent "${t}" returned invalid sharedStatePatch entry for key "${s}". Ignoring that entry.`);continue}n[s]={value:r.value}}return n},Y=e=>{let{previousSharedState:t,patch:n,agentId:s}=e;if(!n)return t;let r=Date.now(),a={...t};for(let[i,o]of Object.entries(n))o?.value!==void 0&&(a[i]={value:o.value,meta:{updatedByAgentId:s,updatedAt:r}});return a},Z=256,ee=new Set(["point","polyline","polygon","extent","custom"]),te=e=>typeof e=="object"&&e!==null&&!Array.isArray(e),re=(e,t)=>{if(e===void 0)return;if(!Array.isArray(e)){console.warn(`Agent "${t}" returned invalid sharedResourceAdditions. Ignoring it.`);return}let n=[];for(let[s,r]of e.entries()){if(!te(r)||typeof r.kind!="string"||!ee.has(r.kind)||typeof r.description!="string"||!r.description.trim()||!("payload"in r)||r.payload===void 0){console.warn(`Agent "${t}" returned invalid sharedResourceAdditions entry at index ${s}. Ignoring that entry.`);continue}let a;try{a=structuredClone(r.payload)}catch{console.warn(`Agent "${t}" returned invalid sharedResourceAdditions entry at index ${s}. Ignoring that entry.`);continue}n.push({kind:r.kind,description:r.description.trim().slice(0,Z),payload:a})}return n.length?n:void 0},ne=e=>{let{previousSharedResources:t,additions:n,agentId:s}=e;if(!n?.length)return t;let r=Date.now(),a=n.map(i=>({...i,id:E(),meta:{createdByAgentId:s,createdAt:r}}));return[...t,...a].slice(-50)},H=e=>typeof e!="string"?void 0:e.trim()||void 0,se=e=>{switch(e){case"failed":return"Agent failed without a summary.";case"unknown":return"Agent returned with unknown status.";case"success":return"Agent completed without a summary.";default:return"Agent completed without a summary."}},ae=(e,t)=>{let n=H(t?.outputMessage),s=H(t?.summary),r=t?.status,a=r==="success"||r==="failed"?r:"unknown";a==="unknown"&&console.warn(`Agent "${e}" returned missing/invalid status. Defaulting to "unknown".`);let i=X(t?.sharedStatePatch,e),o=re(t?.sharedResourceAdditions,e);return{outputMessage:n,summary:s??n??se(a),status:a,sharedStatePatch:i,sharedResourceAdditions:o}},j=4e3,ie=async(e,t)=>{let n=R(t);if(t?.signal?.aborted)return await p({text:"Run cancelled; skipping agent execution"},t),{...e,currentIntent:"none",requiresFollowUp:!1};let{agentRegistry:s}=n?.services??{},r=s?.get(e.currentIntent);if(!r)return console.warn(`No agent found for intent: ${e.currentIntent}`),e;await p({text:`Executing registered agent: ${r.agent.name}`},t);let a={...t??{},metadata:{...t?.metadata,agentId:r.agent.id},configurable:{...n??{},agentId:r.agent.id,context:r.getContext?await r.getContext():void 0}},i;try{let c=await r.agent.createGraph().compile().invoke({agentExecutionContext:{...e.agentExecutionContext,messages:[...e.agentExecutionContext.messages],priorSteps:structuredClone(e.agentExecutionContext.priorSteps??[]),sharedState:structuredClone(e.agentExecutionContext.sharedState??{}),sharedResources:structuredClone(e.agentExecutionContext.sharedResources??[])}},a);i=ae(r.agent.name,c),await p({text:`Finished executing registered agent: ${r.agent.name}`},t)}catch(c){if(M(c)||t?.signal?.aborted||c instanceof Error&&c.name==="AbortError")throw c;let u=c instanceof Error?c.message:String(c);console.error(`Agent "${r.agent.name}" failed:`,c),await p({text:`Registered agent failed: ${r.agent.name}. ${u}`},t),i={status:"failed",outputMessage:`Agent execution failed: ${u}`,summary:`Agent execution failed: ${u}`}}let o=i.outputMessage,d=[...e.agentExecutionContext.messages];if(o){let c=o.length>j?`${o.slice(0,j-14)}
3
- [truncated]`:o;d.push(new b(c))}return{...e,stepCount:e.stepCount+1,lastExecutedAgent:r.agent.id,requiresFollowUp:i.status==="failed"?!0:e.requiresFollowUp,finalOutputMessage:o??"",agentExecutionContext:{...e.agentExecutionContext,messages:d,priorSteps:[...e.agentExecutionContext.priorSteps??[],{agentId:r.agent.id,assignedTask:e.agentExecutionContext.assignedTask,summary:i?.summary||"No summary provided.",status:i?.status||"unknown"}],sharedState:Y({previousSharedState:e.agentExecutionContext.sharedState,patch:i.sharedStatePatch,agentId:r.agent.id}),sharedResources:ne({previousSharedResources:e.agentExecutionContext.sharedResources,additions:i.sharedResourceAdditions,agentId:r.agent.id})}}},oe=async(e,t)=>{if(e.routing.mode!=="direct")throw new Error("Direct agent assignment requires direct routing.");return await p({text:`Doing a direct route to agent: ${e.routing.agentId}`},t),{...e,currentIntent:e.routing.agentId,requiresFollowUp:!1,agentExecutionContext:{...e.agentExecutionContext,assignedTask:e.agentExecutionContext.userRequest}}},de=3,ce=e=>e.routing.mode==="direct"?"assignDirectAgent":"intentLLM",ue=e=>e.routing.mode==="direct"||e.stepCount>=de||!e.requiresFollowUp?"exit":"intentLLM",ge=()=>new D(W).addNode("ingestInput",K).addNode("assignDirectAgent",oe).addNode("intentLLM",L).addNode("executeRegisteredAgent",ie).addNode("exit",V).addEdge(k,"ingestInput").addConditionalEdges("ingestInput",ce).addEdge("assignDirectAgent","executeRegisteredAgent").addConditionalEdges("intentLLM",e=>e.currentIntent==="none"||e.currentIntent===e.lastExecutedAgent?"exit":"executeRegisteredAgent").addConditionalEdges("executeRegisteredAgent",ue).addEdge("exit",$),le=(e,t)=>{let n=e.output?.usage_metadata??t.usage_metadata,s=e.output?.llmOutput?.tokenUsage,r=n?.input_tokens??s?.promptTokens,a=n?.output_tokens??s?.completionTokens,i=n?.total_tokens??s?.totalTokens;if(r===void 0||a===void 0||i===void 0)return;let o=n?.input_token_details?.cache_read,d=n?.output_token_details?.reasoning;return{input:r,output:a,total:i,...o!==void 0&&{cacheRead:o},...d!==void 0&&{reasoning:d}}},he=(e,t,n,s)=>{switch(e){case"chat_model":case"llm":return"model";case"tool":case"retriever":return e;case"chain":return!s||t==="LangGraph"?"workflow":n===t?"node":"chain";default:return}},pe=e=>{if(e instanceof Error)return{message:e.message,name:e.name};let t=e,n=typeof t?.message=="string"?t.message:String(e??"Unknown runtime error"),s=typeof t?.name=="string"?t.name:void 0;return{message:n,...s&&{name:s}}},me=({event:e,runId:t,parentSpanId:n,timestamp:s})=>{let r=/^on_(.+)_(start|end|error)$/u.exec(e.event);if(!r)return;let[,a,i]=r,o=e.metadata??{},d=o.langgraph_node,c=he(a,e.name,d,n);if(!c)return;let u=o.agentId,m=o.model??o.ls_model_name,l=e.data,g=i==="end"&&c==="model"?le(l,o):void 0,y=e.tags?.includes("langsmith:hidden")||d==="__start__",h={...m&&{model:m},...g&&{tokenUsage:g},...y&&{internal:!0}},w={id:e.run_id,...n&&{parentId:n},label:e.name,type:c,...Object.keys(h).length&&{metadata:h}},v={runId:t,timestamp:s,type:"runtime",...u&&{agentId:u}};switch(i){case"start":return{...v,phase:"started",span:{...w,...l?.input!==void 0&&{input:l.input}}};case"end":return{...v,phase:"completed",span:{...w,...l?.output!==void 0&&{output:l.output}}};case"error":return{...v,phase:"failed",span:{...w,error:pe(l?.error)}};default:return}},f=class{constructor(){this.agentRegistry=new Map}register(t){let{agent:n}=t;if(this.agentRegistry.has(n.id))throw new Error(`Duplicate agent id: ${n.id}`);this.agentRegistry.set(n.id,t)}get(t){return this.agentRegistry.get(t)}list(){return[...this.agentRegistry.values()]}},x=class{constructor(t,n){this.graph=t,this.config={...n}}async waitForUser(){return await new Promise((t,n)=>{this.resolveWait=t,this.rejectWait=n})}handle(t,n){try{let s={agentId:t.agentId,id:t.id,payload:n},r=this.graph.streamEvents(null,{...this.config,configurable:{...this.config.configurable,hitlResponse:s},subgraphs:!0,version:"v2"});this.resolveWait?.(r)}catch(s){this.rejectWait?.(s)}finally{this.resolveWait=void 0,this.rejectWait=void 0}}cancel(){this.rejectWait&&(this.rejectWait(new Error("Request cancelled by user.")),this.resolveWait=void 0,this.rejectWait=void 0)}},ye=async e=>{try{return await(await A()).embedDocuments(e)}catch(t){throw console.error("Failed to generate embeddings:",t),t}},U=async(e,t)=>{let n=t.get(e);if(n)return n;let s=await ye([e]);return t.set(e,s[0]),s[0]};async function we(e,t,n,s){let r=`req-${Date.now()}`,a={type:"layerSearch",precomputedEmbedding:s?await U(e,s):void 0,requestId:r,minScore:n};return await new Promise(i=>{let o=d=>{d.data.requestId===r&&i(d.data.results)};t.addEventListener("message",o,{once:!0}),t.postMessage(a)})}function fe(e){let{worker:t}=e;return{async searchLayers({text:n,minScore:s,embeddingCache:r}){return await we(n,t,s,r)}}}var ve=async({combinedQuery:e,layerIds:t,embeddingsWorker:n,minScore:s,topResults:r,embeddingCache:a})=>{let i=`req-${Date.now()}`,o=a?await U(e,a):void 0,d={type:"fieldSearch",layerIdForFieldsSearch:t,precomputedEmbedding:o,requestId:i,minScore:s,topResults:r};return await new Promise(c=>{let u=m=>{if(m.data.requestId!==i)return;let l=m.data.results.map(({layerId:g,results:y})=>({layerId:g,results:y}));c(l)};n.addEventListener("message",u,{once:!0}),n.postMessage(d)})};function Ee(e){let{worker:t}=e;return{async searchFields({text:n,layerIds:s,minScore:r,topResults:a,embeddingCache:i}){return await ve({combinedQuery:n,layerIds:s,embeddingsWorker:t,minScore:r,topResults:a,embeddingCache:i})}}}var Re=e=>{let t=q.safeParse(e);if(!t.success)throw new Error("Embeddings response validation failed. Regenerate embeddings.");return t.data},xe=(e,t)=>{let n=new Map,s=new Map;if(t.allLayers.forEach(r=>{r instanceof G&&s.set(r.id,r)}),e.length!==s.size)throw new Error("Layer count mismatch during registry restoration. Regenerate embeddings.");for(let r of e){let a=s.get(r.id);if(!a)throw new Error(`Layer with ID ${r.id} not found in the original map during registry restoration. Regenerate embeddings.`);if(r.fields.length!==a.fields.length)throw new Error(`Field count mismatch for layer ID ${r.id} during registry restoration. Regenerate embeddings.`);let i={name:r.name,title:r.title,description:r.description},o=new Map;for(let d of r.fields){let c=a.fieldsIndex.get(d.name);if(!c)throw new Error(`Field with name ${d.name} not found in the original layer ${r.id} during registry restoration. Regenerate embeddings.`);o.set(d.name,{name:d.name,alias:a.getFieldAlias(d.name)??d.alias,description:d.description,type:c.type||"unknown",valueType:c.valueType||"unknown",domain:a.getFieldDomain(d.name)??void 0})}n.set(r.id,{layerItem:i,fieldRegistry:o})}return n},Ie=async e=>{try{return(await z(e,{responseType:"json"})).data}catch(t){throw new Error(`Failed to fetch data from ${e}: ${String(t)}`)}},be=async e=>{let t=e.map;if(!t?.portalItem)throw new Error("WebMap portal item is missing.");let{resources:n}=await t.portalItem.fetchResources(),s=n.find(a=>a.resource.path==="embeddings-v01.json");if(!s?.resource.url)throw new Error("Embeddings resource 'embeddings-v01.json' not found in the webmap portal item.");let r=await Ie(s.resource.url);return Re(r)},O=class e{constructor(){this.orchestratorReady=!1,this.chatHistory=[],this.priorSteps=[],this.sharedState={},this.sharedResources=[],this.agentRegistry=new f,this.activeRunId="",this.cancelledRunIds=new Set,this.parentRunIds=new Map,this.activeRuntimeSpans=new Map,this.runtimeEventsEnabled=!1,this.streamEpoch=0}static async init(t){let n=new e;n.runtimeEventsEnabled=t.runtimeEventsEnabled??!1;try{if(t.view?.map){await T.whenOnce(()=>t.view.ready);let s=await be(t.view),r=xe(s.layers,t.view.map);n.layersAndFieldsRegistry=r,n.embeddingsWorker=await B(s)}return t.agents?.forEach(s=>{n.agentRegistry.register(s)}),n.orchestratorReady=!0,n}catch(s){throw console.error("Orchestrator initialization failed:",s),s}}async*ask(t,n={}){if(!this.orchestratorReady)throw new Error("Orchestrator is not ready yet.");if(!this.agentRegistry.list().length)throw new Error("Orchestrator has no registered agents.");let s=this.createRequestAgentRegistry(n);if(!s.list().length)throw new Error("Orchestrator has no agents selected for this request.");if(++this.streamEpoch,!t.trim())return;let r=E();this.parentRunIds.clear(),this.activeRuntimeSpans.clear(),this.activeRunId=r,this.activeAbortController=new AbortController,this.graph||(this.graph=ge().compile({checkpointer:new _}));let a=this.embeddingsWorker?fe({worker:this.embeddingsWorker}):void 0,i=this.embeddingsWorker?Ee({worker:this.embeddingsWorker}):void 0,o=new Map,d=n.routing==="direct"?{mode:"direct",agentId:n.agentId}:{mode:"auto"},c={thread_id:r,hitlResponse:null,services:{layerSearch:a,fieldSearch:i,layersAndFieldsRegistry:this.layersAndFieldsRegistry,agentRegistry:s,embeddingCache:o}},u={version:"v2",streamMode:"custom",signal:this.activeAbortController.signal,...this.runtimeEventsEnabled&&{callbacks:[this.createHierarchyCallback()]},configurable:c,subgraphs:!0},m=this.graph?.streamEvents({routing:d,agentExecutionContext:{userRequest:t,messages:this.chatHistory,priorSteps:this.priorSteps,sharedState:this.sharedState,sharedResources:this.sharedResources}},u),l=++this.streamEpoch;if(yield*this.pipeStream(m,l,r),this.isRunCancelled(r)){yield*this.createCancellationEvents(r);return}for(;;){if(this.isRunCancelled(r)){yield*this.createCancellationEvents(r);return}let y=(await this.graph.getState(u,{subgraphs:!0})).tasks.find(h=>h.interrupts.length>0)?.interrupts[0]?.value;if(!y)break;this.currentInterrupt=y,this.interruptHandler=new x(this.graph,u),yield*this.closeActiveRuntimeSpans(r,"interrupted"),yield{runId:r,timestamp:Date.now(),type:"interrupt",interrupt:y};try{let h=await this.interruptHandler.waitForUser(),w=++this.streamEpoch;yield*this.pipeStream(h,w,r)}catch(h){if(this.isRunCancelled(r)){yield*this.createCancellationEvents(r);return}if(h){yield{runId:r,timestamp:Date.now(),type:"error",error:{message:h?.message}};return}}}if(this.isRunCancelled(r)){yield*this.createCancellationEvents(r);return}let g=(await this.graph.getState(u,{subgraphs:!0})).values;if(this.isRunCancelled(r)){yield*this.createCancellationEvents(r);return}this.chatHistory=g.agentExecutionContext.messages.length?g.agentExecutionContext.messages:this.chatHistory,this.priorSteps=g.agentExecutionContext.priorSteps?.slice(-5)??[],this.sharedState=g.agentExecutionContext.sharedState??{},this.sharedResources=g.agentExecutionContext.sharedResources??[],yield{runId:r,timestamp:Date.now(),type:"completed",result:{content:g.finalOutputMessage}}}newConversation(){this.chatHistory=[],this.priorSteps=[],this.sharedState={},this.sharedResources=[]}resumeInterrupt(t){if(!this.currentInterrupt||!this.interruptHandler)throw new Error("No pending interrupt to resume.");this.interruptHandler.handle(this.currentInterrupt,t)}cancelInterrupt(){this.interruptHandler&&this.interruptHandler.cancel()}cancel(){this.activeRunId&&(this.cancelledRunIds.add(this.activeRunId),this.activeAbortController?.abort(),++this.streamEpoch,this.interruptHandler?.cancel())}async*pipeStream(t,n,s){try{for await(let r of t){if(this.isRunCancelled(s)||n!==this.streamEpoch)break;if(this.runtimeEventsEnabled){let a=me({event:r,runId:s,parentSpanId:this.parentRunIds.get(r.run_id),timestamp:Date.now()});a&&(a.phase==="started"?this.activeRuntimeSpans.set(a.span.id,a):this.activeRuntimeSpans.delete(a.span.id),yield a)}r.event==="on_custom_event"&&r.name==="trace_message"?yield{runId:s,timestamp:Date.now(),type:"trace",data:r.data}:r.name==="graph_ux_suggestion"&&(yield{runId:s,timestamp:Date.now(),type:"ux-suggestion",suggestion:r.data})}}catch(r){if(!this.isRunCancelled(s))throw r}}*createCancellationEvents(t){yield*this.closeActiveRuntimeSpans(t,"cancelled"),yield{runId:t,timestamp:Date.now(),type:"cancelled",reason:"user"}}*closeActiveRuntimeSpans(t,n){let s=Date.now(),r=[...this.activeRuntimeSpans.values()].reverse();this.activeRuntimeSpans.clear();for(let a of r){let{input:i,...o}=a.span;yield{type:"runtime",phase:n,runId:t,timestamp:s,...a.agentId&&{agentId:a.agentId},span:o}}}createHierarchyCallback(){let t=(n,s)=>{s&&this.parentRunIds.set(n,s)};return S.fromMethods({handleLLMStart:(n,s,r,a)=>t(r,a),handleChatModelStart:(n,s,r,a)=>t(r,a),handleChainStart:(n,s,r,a)=>t(r,a),handleToolStart:(n,s,r,a)=>t(r,a),handleRetrieverStart:(n,s,r,a)=>t(r,a)})}isRunCancelled(t){return this.cancelledRunIds.has(t)}createRequestAgentRegistry(t){let n=t.routing==="direct"?[t.agentId]:t.agentIds,s=n?n.map(a=>{let i=this.agentRegistry.get(a);if(!i)throw new Error(`Agent is not registered: ${a}`);return i}):this.agentRegistry.list(),r=new f;return s.forEach(a=>r.register(a)),r}dispose(){this.sharedResources=[],this.embeddingsWorker&&(this.embeddingsWorker.terminate(),this.embeddingsWorker=void 0),this.orchestratorReady=!1}};return{a:ye,b:O}},"identity/IdentityManager","portal/Portal","core/reactiveUtils","layers/FeatureLayer","request",a)
2
+ import a from"./2NODROJN.js";import{b as E}from"./R74ZHFA6.js";import{a as p}from"./V7Y22FRP.js";import{P as M,Ya as D,ea as _,r as k,s as $}from"./LOQ2PKV5.js";import{Ia as S,ca as I,ta as b}from"./IYLFJCJ2.js";export default $arcgis.t(([U,N,O,G,z,{a:C,c:A,d:q,e:R,f:W,m:L}])=>{var B=async e=>{let t=await Q(),n=await C("default"),s=N.getDefault(),r=(await U.getCredential(`${s.url}/sharing`)).token,a={type:"generateEmbeddings",webmapEmbeddings:e,auth:{apiUrl:n,token:r}};return t.postMessage(a),await new Promise((i,o)=>{let d=u=>{u.data==="completed"&&(t.removeEventListener("message",d),i())},c=u=>{t.removeEventListener("message",d),o(u instanceof Error?u:new Error("Embeddings worker error"))};t.addEventListener("message",d),t.addEventListener("error",c,{once:!0})}),t},Q=async()=>{{let e=(await import("./OKVLGJAG.js")).default;return new e}},J=e=>{e.currentIntent="none"},K=async(e,t)=>{let n=R(t);if(e.agentExecutionContext.userRequest){let r=new I(e.agentExecutionContext.userRequest.trim());e.agentExecutionContext.messages=[...e.agentExecutionContext.messages,r],J(e)}let s=n?.services.agentRegistry.list().map(r=>r.agent.id)??[];return await p({text:`Available agents: ${[...s].join(", ")}`},t),await p({text:"Analyzing user input"},t),e},V=async(e,t)=>(await p({text:"Exiting..."},t),e),F=e=>typeof e=="object"&&e!==null&&!Array.isArray(e),X=(e,t)=>{if(!F(e)){e!==void 0&&console.warn(`Agent "${t}" returned invalid sharedStatePatch. Ignoring it.`);return}let n={};for(let[s,r]of Object.entries(e)){if(!F(r)||!("value"in r)){console.warn(`Agent "${t}" returned invalid sharedStatePatch entry for key "${s}". Ignoring that entry.`);continue}n[s]={value:r.value}}return n},Y=e=>{let{previousSharedState:t,patch:n,agentId:s}=e;if(!n)return t;let r=Date.now(),a={...t};for(let[i,o]of Object.entries(n))o?.value!==void 0&&(a[i]={value:o.value,meta:{updatedByAgentId:s,updatedAt:r}});return a},Z=256,ee=new Set(["point","polyline","polygon","extent","custom"]),te=e=>typeof e=="object"&&e!==null&&!Array.isArray(e),re=(e,t)=>{if(e===void 0)return;if(!Array.isArray(e)){console.warn(`Agent "${t}" returned invalid sharedResourceAdditions. Ignoring it.`);return}let n=[];for(let[s,r]of e.entries()){if(!te(r)||typeof r.kind!="string"||!ee.has(r.kind)||typeof r.description!="string"||!r.description.trim()||!("payload"in r)||r.payload===void 0){console.warn(`Agent "${t}" returned invalid sharedResourceAdditions entry at index ${s}. Ignoring that entry.`);continue}let a;try{a=structuredClone(r.payload)}catch{console.warn(`Agent "${t}" returned invalid sharedResourceAdditions entry at index ${s}. Ignoring that entry.`);continue}n.push({kind:r.kind,description:r.description.trim().slice(0,Z),payload:a})}return n.length?n:void 0},ne=e=>{let{previousSharedResources:t,additions:n,agentId:s}=e;if(!n?.length)return t;let r=Date.now(),a=n.map(i=>({...i,id:E(),meta:{createdByAgentId:s,createdAt:r}}));return[...t,...a].slice(-50)},H=e=>typeof e!="string"?void 0:e.trim()||void 0,se=e=>{switch(e){case"failed":return"Agent failed without a summary.";case"unknown":return"Agent returned with unknown status.";case"success":return"Agent completed without a summary.";default:return"Agent completed without a summary."}},ae=(e,t)=>{let n=H(t?.outputMessage),s=H(t?.summary),r=t?.status,a=r==="success"||r==="failed"?r:"unknown";a==="unknown"&&console.warn(`Agent "${e}" returned missing/invalid status. Defaulting to "unknown".`);let i=X(t?.sharedStatePatch,e),o=re(t?.sharedResourceAdditions,e);return{outputMessage:n,summary:s??n??se(a),status:a,sharedStatePatch:i,sharedResourceAdditions:o}},j=4e3,ie=async(e,t)=>{let n=R(t);if(t?.signal?.aborted)return await p({text:"Run cancelled; skipping agent execution"},t),{...e,currentIntent:"none",requiresFollowUp:!1};let{agentRegistry:s}=n?.services??{},r=s?.get(e.currentIntent);if(!r)return console.warn(`No agent found for intent: ${e.currentIntent}`),e;await p({text:`Executing registered agent: ${r.agent.name}`},t);let a={...t??{},metadata:{...t?.metadata,agentId:r.agent.id},configurable:{...n??{},agentId:r.agent.id,context:r.getContext?await r.getContext():void 0}},i;try{let c=await r.agent.createGraph().compile().invoke({agentExecutionContext:{...e.agentExecutionContext,messages:[...e.agentExecutionContext.messages],priorSteps:structuredClone(e.agentExecutionContext.priorSteps??[]),sharedState:structuredClone(e.agentExecutionContext.sharedState??{}),sharedResources:structuredClone(e.agentExecutionContext.sharedResources??[])}},a);i=ae(r.agent.name,c),await p({text:`Finished executing registered agent: ${r.agent.name}`},t)}catch(c){if(M(c)||t?.signal?.aborted||c instanceof Error&&c.name==="AbortError")throw c;let u=c instanceof Error?c.message:String(c);console.error(`Agent "${r.agent.name}" failed:`,c),await p({text:`Registered agent failed: ${r.agent.name}. ${u}`},t),i={status:"failed",outputMessage:`Agent execution failed: ${u}`,summary:`Agent execution failed: ${u}`}}let o=i.outputMessage,d=[...e.agentExecutionContext.messages];if(o){let c=o.length>j?`${o.slice(0,j-14)}
3
+ [truncated]`:o;d.push(new b(c))}return{...e,stepCount:e.stepCount+1,lastExecutedAgent:r.agent.id,requiresFollowUp:i.status==="failed"?!0:e.requiresFollowUp,finalOutputMessage:o??"",agentExecutionContext:{...e.agentExecutionContext,messages:d,priorSteps:[...e.agentExecutionContext.priorSteps??[],{agentId:r.agent.id,assignedTask:e.agentExecutionContext.assignedTask,summary:i?.summary||"No summary provided.",status:i?.status||"unknown"}],sharedState:Y({previousSharedState:e.agentExecutionContext.sharedState,patch:i.sharedStatePatch,agentId:r.agent.id}),sharedResources:ne({previousSharedResources:e.agentExecutionContext.sharedResources,additions:i.sharedResourceAdditions,agentId:r.agent.id})}}},oe=async(e,t)=>{if(e.routing.mode!=="direct")throw new Error("Direct agent assignment requires direct routing.");return await p({text:`Doing a direct route to agent: ${e.routing.agentId}`},t),{...e,currentIntent:e.routing.agentId,requiresFollowUp:!1,agentExecutionContext:{...e.agentExecutionContext,assignedTask:e.agentExecutionContext.userRequest}}},de=3,ce=e=>e.routing.mode==="direct"?"assignDirectAgent":"intentLLM",ue=e=>e.routing.mode==="direct"||e.stepCount>=de||!e.requiresFollowUp?"exit":"intentLLM",ge=()=>new D(q).addNode("ingestInput",K).addNode("assignDirectAgent",oe).addNode("intentLLM",W).addNode("executeRegisteredAgent",ie).addNode("exit",V).addEdge(k,"ingestInput").addConditionalEdges("ingestInput",ce).addEdge("assignDirectAgent","executeRegisteredAgent").addConditionalEdges("intentLLM",e=>e.currentIntent==="none"||e.currentIntent===e.lastExecutedAgent?"exit":"executeRegisteredAgent").addConditionalEdges("executeRegisteredAgent",ue).addEdge("exit",$),le=(e,t)=>{let n=e.output?.usage_metadata??t.usage_metadata,s=e.output?.llmOutput?.tokenUsage,r=n?.input_tokens??s?.promptTokens,a=n?.output_tokens??s?.completionTokens,i=n?.total_tokens??s?.totalTokens;if(r===void 0||a===void 0||i===void 0)return;let o=n?.input_token_details?.cache_read,d=n?.output_token_details?.reasoning;return{input:r,output:a,total:i,...o!==void 0&&{cacheRead:o},...d!==void 0&&{reasoning:d}}},he=(e,t,n,s)=>{switch(e){case"chat_model":case"llm":return"model";case"tool":case"retriever":return e;case"chain":return!s||t==="LangGraph"?"workflow":n===t?"node":"chain";default:return}},pe=e=>{if(e instanceof Error)return{message:e.message,name:e.name};let t=e,n=typeof t?.message=="string"?t.message:String(e??"Unknown runtime error"),s=typeof t?.name=="string"?t.name:void 0;return{message:n,...s&&{name:s}}},me=({event:e,runId:t,parentSpanId:n,timestamp:s})=>{let r=/^on_(.+)_(start|end|error)$/u.exec(e.event);if(!r)return;let[,a,i]=r,o=e.metadata??{},d=o.langgraph_node,c=he(a,e.name,d,n);if(!c)return;let u=o.agentId,m=o.model??o.ls_model_name,l=e.data,g=i==="end"&&c==="model"?le(l,o):void 0,y=e.tags?.includes("langsmith:hidden")||d==="__start__",h={...m&&{model:m},...g&&{tokenUsage:g},...y&&{internal:!0}},w={id:e.run_id,...n&&{parentId:n},label:e.name,type:c,...Object.keys(h).length&&{metadata:h}},v={runId:t,timestamp:s,type:"runtime",...u&&{agentId:u}};switch(i){case"start":return{...v,phase:"started",span:{...w,...l?.input!==void 0&&{input:l.input}}};case"end":return{...v,phase:"completed",span:{...w,...l?.output!==void 0&&{output:l.output}}};case"error":return{...v,phase:"failed",span:{...w,error:pe(l?.error)}};default:return}},f=class{constructor(){this.agentRegistry=new Map}register(t){let{agent:n}=t;if(this.agentRegistry.has(n.id))throw new Error(`Duplicate agent id: ${n.id}`);this.agentRegistry.set(n.id,t)}get(t){return this.agentRegistry.get(t)}list(){return[...this.agentRegistry.values()]}},x=class{constructor(t,n){this.graph=t,this.config={...n}}async waitForUser(){return await new Promise((t,n)=>{this.resolveWait=t,this.rejectWait=n})}handle(t,n){try{let s={agentId:t.agentId,id:t.id,payload:n},r=this.graph.streamEvents(null,{...this.config,configurable:{...this.config.configurable,hitlResponse:s},subgraphs:!0,version:"v2"});this.resolveWait?.(r)}catch(s){this.rejectWait?.(s)}finally{this.resolveWait=void 0,this.rejectWait=void 0}}cancel(){this.rejectWait&&(this.rejectWait(new Error("Request cancelled by user.")),this.resolveWait=void 0,this.rejectWait=void 0)}},ye=async e=>{try{return await(await A()).embedDocuments(e)}catch(t){throw console.error("Failed to generate embeddings:",t),t}},T=async(e,t)=>{let n=t.get(e);if(n)return n;let s=await ye([e]);return t.set(e,s[0]),s[0]};async function we(e,t,n,s){let r=`req-${Date.now()}`,a={type:"layerSearch",precomputedEmbedding:s?await T(e,s):void 0,requestId:r,minScore:n};return await new Promise(i=>{let o=d=>{d.data.requestId===r&&i(d.data.results)};t.addEventListener("message",o,{once:!0}),t.postMessage(a)})}function fe(e){let{worker:t}=e;return{async searchLayers({text:n,minScore:s,embeddingCache:r}){return await we(n,t,s,r)}}}var ve=async({combinedQuery:e,layerIds:t,embeddingsWorker:n,minScore:s,topResults:r,embeddingCache:a})=>{let i=`req-${Date.now()}`,o=a?await T(e,a):void 0,d={type:"fieldSearch",layerIdForFieldsSearch:t,precomputedEmbedding:o,requestId:i,minScore:s,topResults:r};return await new Promise(c=>{let u=m=>{if(m.data.requestId!==i)return;let l=m.data.results.map(({layerId:g,results:y})=>({layerId:g,results:y}));c(l)};n.addEventListener("message",u,{once:!0}),n.postMessage(d)})};function Ee(e){let{worker:t}=e;return{async searchFields({text:n,layerIds:s,minScore:r,topResults:a,embeddingCache:i}){return await ve({combinedQuery:n,layerIds:s,embeddingsWorker:t,minScore:r,topResults:a,embeddingCache:i})}}}var Re=e=>{let t=L.safeParse(e);if(!t.success)throw new Error("Embeddings response validation failed. Regenerate embeddings.");return t.data},xe=(e,t)=>{let n=new Map,s=new Map;if(t.allLayers.forEach(r=>{r instanceof G&&s.set(r.id,r)}),e.length!==s.size)throw new Error("Layer count mismatch during registry restoration. Regenerate embeddings.");for(let r of e){let a=s.get(r.id);if(!a)throw new Error(`Layer with ID ${r.id} not found in the original map during registry restoration. Regenerate embeddings.`);if(r.fields.length!==a.fields.length)throw new Error(`Field count mismatch for layer ID ${r.id} during registry restoration. Regenerate embeddings.`);let i={name:r.name,title:r.title,description:r.description},o=new Map;for(let d of r.fields){let c=a.fieldsIndex.get(d.name);if(!c)throw new Error(`Field with name ${d.name} not found in the original layer ${r.id} during registry restoration. Regenerate embeddings.`);o.set(d.name,{name:d.name,alias:a.getFieldAlias(d.name)??d.alias,description:d.description,type:c.type||"unknown",valueType:c.valueType||"unknown",domain:a.getFieldDomain(d.name)??void 0})}n.set(r.id,{layerItem:i,fieldRegistry:o})}return n},Ie=async e=>{try{return(await z(e,{responseType:"json"})).data}catch(t){throw new Error(`Failed to fetch data from ${e}: ${String(t)}`)}},be=async e=>{let t=e.map;if(!t?.portalItem)throw new Error("WebMap portal item is missing.");let{resources:n}=await t.portalItem.fetchResources(),s=n.find(a=>a.resource.path==="embeddings-v01.json");if(!s?.resource.url)throw new Error("Embeddings resource 'embeddings-v01.json' not found in the webmap portal item.");let r=await Ie(s.resource.url);return Re(r)},P=class e{constructor(){this.orchestratorReady=!1,this.chatHistory=[],this.priorSteps=[],this.sharedState={},this.sharedResources=[],this.agentRegistry=new f,this.activeRunId="",this.cancelledRunIds=new Set,this.parentRunIds=new Map,this.activeRuntimeSpans=new Map,this.runtimeEventsEnabled=!1,this.streamEpoch=0}static async init(t){let n=new e;n.runtimeEventsEnabled=t.runtimeEventsEnabled??!1;try{if(t.view?.map){await O.whenOnce(()=>t.view.ready);let s=await be(t.view),r=xe(s.layers,t.view.map);n.layersAndFieldsRegistry=r,n.embeddingsWorker=await B(s)}return t.agents?.forEach(s=>{n.agentRegistry.register(s)}),n.orchestratorReady=!0,n}catch(s){throw console.error("Orchestrator initialization failed:",s),s}}async*ask(t,n={}){if(!this.orchestratorReady)throw new Error("Orchestrator is not ready yet.");if(!this.agentRegistry.list().length)throw new Error("Orchestrator has no registered agents.");let s=this.createRequestAgentRegistry(n);if(!s.list().length)throw new Error("Orchestrator has no agents selected for this request.");if(++this.streamEpoch,!t.trim()&&!n.inputParts?.length)return;if(!t.trim()&&n.routing!=="direct")throw new Error("Requests containing only structured input require direct agent routing.");let r=E();this.parentRunIds.clear(),this.activeRuntimeSpans.clear(),this.activeRunId=r,this.activeAbortController=new AbortController,this.graph||(this.graph=ge().compile({checkpointer:new _}));let a=this.embeddingsWorker?fe({worker:this.embeddingsWorker}):void 0,i=this.embeddingsWorker?Ee({worker:this.embeddingsWorker}):void 0,o=new Map,d=n.routing==="direct"?{mode:"direct",agentId:n.agentId}:{mode:"auto"},c={thread_id:r,hitlResponse:null,services:{layerSearch:a,fieldSearch:i,layersAndFieldsRegistry:this.layersAndFieldsRegistry,agentRegistry:s,embeddingCache:o}},u={version:"v2",streamMode:"custom",signal:this.activeAbortController.signal,...this.runtimeEventsEnabled&&{callbacks:[this.createHierarchyCallback()]},configurable:c,subgraphs:!0},m=this.graph?.streamEvents({routing:d,agentExecutionContext:{userRequest:t,inputParts:[...n.inputParts??[]],messages:this.chatHistory,priorSteps:this.priorSteps,sharedState:this.sharedState,sharedResources:this.sharedResources}},u),l=++this.streamEpoch;if(yield*this.pipeStream(m,l,r),this.isRunCancelled(r)){yield*this.createCancellationEvents(r);return}for(;;){if(this.isRunCancelled(r)){yield*this.createCancellationEvents(r);return}let y=(await this.graph.getState(u,{subgraphs:!0})).tasks.find(h=>h.interrupts.length>0)?.interrupts[0]?.value;if(!y)break;this.currentInterrupt=y,this.interruptHandler=new x(this.graph,u),yield*this.closeActiveRuntimeSpans(r,"interrupted"),yield{runId:r,timestamp:Date.now(),type:"interrupt",interrupt:y};try{let h=await this.interruptHandler.waitForUser(),w=++this.streamEpoch;yield*this.pipeStream(h,w,r)}catch(h){if(this.isRunCancelled(r)){yield*this.createCancellationEvents(r);return}if(h){yield{runId:r,timestamp:Date.now(),type:"error",error:{message:h?.message}};return}}}if(this.isRunCancelled(r)){yield*this.createCancellationEvents(r);return}let g=(await this.graph.getState(u,{subgraphs:!0})).values;if(this.isRunCancelled(r)){yield*this.createCancellationEvents(r);return}this.chatHistory=g.agentExecutionContext.messages.length?g.agentExecutionContext.messages:this.chatHistory,this.priorSteps=g.agentExecutionContext.priorSteps?.slice(-5)??[],this.sharedState=g.agentExecutionContext.sharedState??{},this.sharedResources=g.agentExecutionContext.sharedResources??[],yield{runId:r,timestamp:Date.now(),type:"completed",result:{content:g.finalOutputMessage}}}newConversation(){this.chatHistory=[],this.priorSteps=[],this.sharedState={},this.sharedResources=[]}resumeInterrupt(t){if(!this.currentInterrupt||!this.interruptHandler)throw new Error("No pending interrupt to resume.");this.interruptHandler.handle(this.currentInterrupt,t)}cancelInterrupt(){this.interruptHandler&&this.interruptHandler.cancel()}cancel(){this.activeRunId&&(this.cancelledRunIds.add(this.activeRunId),this.activeAbortController?.abort(),++this.streamEpoch,this.interruptHandler?.cancel())}async*pipeStream(t,n,s){try{for await(let r of t){if(this.isRunCancelled(s)||n!==this.streamEpoch)break;if(this.runtimeEventsEnabled){let a=me({event:r,runId:s,parentSpanId:this.parentRunIds.get(r.run_id),timestamp:Date.now()});a&&(a.phase==="started"?this.activeRuntimeSpans.set(a.span.id,a):this.activeRuntimeSpans.delete(a.span.id),yield a)}r.event==="on_custom_event"&&r.name==="trace_message"?yield{runId:s,timestamp:Date.now(),type:"trace",data:r.data}:r.name==="graph_ux_suggestion"&&(yield{runId:s,timestamp:Date.now(),type:"ux-suggestion",suggestion:r.data})}}catch(r){if(!this.isRunCancelled(s))throw r}}*createCancellationEvents(t){yield*this.closeActiveRuntimeSpans(t,"cancelled"),yield{runId:t,timestamp:Date.now(),type:"cancelled",reason:"user"}}*closeActiveRuntimeSpans(t,n){let s=Date.now(),r=[...this.activeRuntimeSpans.values()].reverse();this.activeRuntimeSpans.clear();for(let a of r){let{input:i,...o}=a.span;yield{type:"runtime",phase:n,runId:t,timestamp:s,...a.agentId&&{agentId:a.agentId},span:o}}}createHierarchyCallback(){let t=(n,s)=>{s&&this.parentRunIds.set(n,s)};return S.fromMethods({handleLLMStart:(n,s,r,a)=>t(r,a),handleChatModelStart:(n,s,r,a)=>t(r,a),handleChainStart:(n,s,r,a)=>t(r,a),handleToolStart:(n,s,r,a)=>t(r,a),handleRetrieverStart:(n,s,r,a)=>t(r,a)})}isRunCancelled(t){return this.cancelledRunIds.has(t)}createRequestAgentRegistry(t){let n=t.routing==="direct"?[t.agentId]:t.agentIds,s=n?n.map(a=>{let i=this.agentRegistry.get(a);if(!i)throw new Error(`Agent is not registered: ${a}`);return i}):this.agentRegistry.list(),r=new f;return s.forEach(a=>r.register(a)),r}dispose(){this.sharedResources=[],this.embeddingsWorker&&(this.embeddingsWorker.terminate(),this.embeddingsWorker=void 0),this.orchestratorReady=!1}};return{a:ye,b:P}},"identity/IdentityManager","portal/Portal","core/reactiveUtils","layers/FeatureLayer","request",a)
@@ -1,5 +1,5 @@
1
1
  /* COPYRIGHT Esri - https://js.arcgis.com/5.2/LICENSE.txt */
2
- import{a as R}from"./XQ3NBBQ3.js";import b from"./XOULSLM7.js";import a from"./64IWQ7A4.js";import{a as c,b as k}from"./V7Y22FRP.js";import{A as f,Ya as x,r as w,s as d}from"./LOQ2PKV5.js";import{ta as u}from"./IYLFJCJ2.js";export default $arcgis.t(([,,,,,,{n:_,p:b},{A:S,B:M,C:T,D:E,E:C,F:G,G:N,b:v,d:m,e:h,w:y,x:A,y:K,z:q}])=>{var z=[M,T,G,E,S,N,C];async function $(e,a){let o=await m("arcgis_knowledge_tool_prompt"),s=A(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.text;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"}.
2
+ import{a as R}from"./XQ3NBBQ3.js";import b from"./HAHL6K4X.js";import a from"./2NODROJN.js";import{a as c,b as k}from"./V7Y22FRP.js";import{A as f,Ya as x,r as w,s as d}from"./LOQ2PKV5.js";import{ta as u}from"./IYLFJCJ2.js";export default $arcgis.t(([,,,,,,{n:_,p:b},{A:S,B:M,C:T,D:E,E:C,F:G,G:N,b:v,d:m,e:h,w:y,x:A,y:K,z:q}])=>{var z=[M,T,G,E,S,N,C];async function $(e,a){let o=await m("arcgis_knowledge_tool_prompt"),s=A(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.text;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
3
 
4
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
5
  `),summary:r.length?h(r.join(`
@@ -0,0 +1,3 @@
1
+ /* COPYRIGHT Esri - https://js.arcgis.com/5.2/LICENSE.txt */
2
+ import{a as I}from"./5BBXNT75.js";import b from"./UZ6OAU3F.js";import{a as $}from"./434TAA3J.js";import{b as D}from"./5QXGQW2N.js";import{a as M}from"./JTKVVKZK.js";import"./NWJQ7KTC.js";import a from"./2NODROJN.js";import"./QZL4SAYR.js";import{g as P,h,k as A,l as C,n as u,t as w,u as E,v as T,x as v,z as L}from"./COH3QXWG.js";import"./R74ZHFA6.js";import"./V7Y22FRP.js";import"./AXTQU5YL.js";import"./LOQ2PKV5.js";import"./IYLFJCJ2.js";import"./VXFQANGJ.js";import"./MWYBF3F3.js";import"./UZLQALHY.js";export default $arcgis.t(([q,{whenOnce:B,watch:F,when:j},V,,O,,,H,{property:y,subclass:W},,{b:R}])=>{var G=P`: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(l){return l.trim()?I.lexer(l).filter(t=>t.type!=="space").map(t=>I.parser([t])):[]}var k=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)),e=t.trim()?S(t):[];return[...this._stableParts,...e]}reset(){this._stableParts=[],this._stableText="",this._rawText=""}_advanceStableBoundary(){let t=this._rawText.slice(this._stableText.length),e=this._lastSafeBoundary(t);if(e<=0)return;let s=t.slice(0,e);this._stableParts.push(...S(s)),this._stableText+=s}_lastSafeBoundary(t){let e=t.split(`
3
+ `),s=!1,i=0,r=0;for(let d of e)/^\s*(```|~~~)/u.test(d)&&(s=!s),r+=d.length+1,d.trim()===""&&!s&&(i=r);return i<t.length?i:0}_trimIncompleteTail(t){let e=t.lastIndexOf("<");if(e!==-1&&!t.includes(">",e))return t.slice(0,e);let s=this._earliestUnclosedTag(t);if(s!==-1)return t.slice(0,s);let i=t.lastIndexOf("[");if(i!==-1){let r=t.slice(i);if(!/\[[^\]]*\]\([^)]*\)/u.test(r))return t.slice(0,i)}return t}_earliestUnclosedTag(t){let e=new Set(["br","img","hr","input","meta","link","area","base","col","embed","source","track","wbr"]),s=/<(\/?)([a-zA-Z][\w-]*)\b[^>]*?(\/?)>/gu,i=[];for(let r=s.exec(t);r;r=s.exec(t)){let[,d,p,o]=r,c=p.toLowerCase();if(!(e.has(c)||o==="/"))if(d==="/"){for(let a=i.length-1;a>=0;a--)if(i[a].name===c){i.splice(a);break}}else i.push({name:c,index:r.index})}return i.length?i[0].index:-1}};function Z(l){let t=new k;return t.push(l),t.finalize()}var J=async l=>await new Promise(t=>setTimeout(t,l));async function*K(l,{chunkSize:t=15,delay:e=50}={}){let s=new k;for(let i=0;i<l.length;i+=t)yield s.push(l.slice(i,i+t)),await J(e);yield s.finalize()}var Q=Object.defineProperty,X=Object.getOwnPropertyDescriptor,_=(l,t,e,s)=>{for(var i=s>1?void 0:s?X(t,e):t,r=l.length-1,d;r>=0;r--)(d=l[r])&&(i=(s?d(t,e,i):d(i))||i);return s&&i&&Q(t,e,i),i},U=l=>!l||typeof l!="object"?!1:l.name==="AbortError";async function*z(l,t,e,s,i=!1){if(i){if(s?.aborted){yield{type:"cancelled",log:e,runId:t};return}yield{type:"block-data",blockType:"text",data:{parts:Z(l)},runId:t};return}for await(let r of K(l)){if(s?.aborted){yield{type:"cancelled",log:e,runId:t};return}yield{type:"block-data",blockType:"text",data:{parts:r},runId:t}}}var b=class extends H{constructor(l){super(l),this.view=null,this.streamingDisabled=!1,this.runtimeEventsEnabled=!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 B(()=>!this.view.updating),this._set("orchestrator",await R.init({agents:[...this.agents],runtimeEventsEnabled:this.runtimeEventsEnabled,view:this.view??void 0})),this.addHandles([F(()=>[this.view,this.agents],()=>{this._initialize()})])}clearChatHistory(){this.orchestrator?.newConversation()}async*ask(l,t,e){if(!this.orchestrator)throw new Error("Orchestrator not initialized yet.");this._set("processing",!0),this._set("processingStep","");let s=[],i,r="pending";try{let d=this.orchestrator.ask(l,t);for await(let p of d)switch(r=p.runId,p.type){case"runtime":{yield{type:"runtime",event:p,runId:r};break}case"trace":{this._set("processingStep",p.data.text),s.push(p.data.text);break}case"completed":{this._set("processing",!1),this._set("processingStep","");let o=p.result,c=!!o.content.length,a=!!i?.length;if(!c&&!a){yield{type:"completed",error:"No response received.",log:s,runId:r};return}let n=o.content;if(yield{type:"block-start",blockType:"text",runId:r},yield*z(n,r,s,e,this.streamingDisabled),yield{type:"block-end",blockType:"text",runId:r},a)for(let g of i){if(e?.aborted){yield{type:"cancelled",log:s,runId:r};return}let{type:m,data:f}=g;if(yield{type:"block-start",blockType:m,runId:r},m==="text"){let N=typeof f?.content=="string"?f.content:"";yield*z(N,r,s,e,this.streamingDisabled)}else yield{type:"block-data",blockType:m,data:f,runId:r};yield{type:"block-end",blockType:m,runId:r}}yield{type:"completed",response:n,blocks:i,log:s,runId:r};return}case"ux-suggestion":{let o=p.suggestion;i=i?[...i,o]:[o];break}case"interrupt":{let{kind:o,message:c,metadata:a}=p.interrupt,n=Array.isArray(a)?a.filter(m=>typeof m=="string"):[],g=(()=>{switch(o){case"booleanChoice":return{type:"boolean-choice",message:c,options:n};case"singleSelection":return{type:"single-select",message:c,options:n};case"multipleSelection":return{type:"multi-select",message:c,options:n};case"textInput":return{type:"text-input",message:c};default:return{type:o,message:c,options:n}}})();this._set("processingStep","Waiting for user input..."),yield{type:"interrupt",payload:g,runId:r};break}case"cancelled":{yield{type:"cancelled",log:s,runId:r};return}case"error":{if(e?.aborted||U(p.error)){yield{type:"cancelled",log:s,runId:r};return}yield{type:"completed",error:p.error.message,log:s,runId:r};return}default:{console.warn("Unknown event type:",p);break}}}catch(d){if(e?.aborted||U(d)){yield{type:"cancelled",log:s,runId:r};return}console.warn("Error during message processing:",d),yield{type:"completed",error:"An error occurred during message processing.",log:s,runId:"error"};return}finally{this._set("processing",!1)}}cancel(){this.orchestrator?.cancel()}};_([y({readOnly:!0})],b.prototype,"orchestrator",2);_([y()],b.prototype,"agents",2);_([y()],b.prototype,"portal",2);_([y()],b.prototype,"view",2);_([y()],b.prototype,"streamingDisabled",2);_([y()],b.prototype,"runtimeEventsEnabled",2);_([y({readOnly:!0})],b.prototype,"loading",2);_([y({readOnly:!0})],b.prototype,"processing",2);_([y({readOnly:!0})],b.prototype,"processingStep",2);b=_([W("OrchestratorController")],b);var Y="Embeddings resource 'embeddings-v01.json' not found in the webmap portal item.",tt="Embeddings not found for this web map.",et="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=w(),this.#o=w(),this.#i=w(),this.#e=null,this.#r=new Map,this.#s=V.getDefault(),this.#a=t=>{t.stopPropagation(),this.cancelInterrupt()},this.#n=t=>{t.stopPropagation();let e=t.detail;this.submitInterrupt(e)},this.#l=t=>{if(t.stopPropagation(),t.defaultPrevented)return;let e=t.detail,s=typeof e=="string"?e:e.prompt,i=typeof e=="string"?void 0:{displayText:e.displayText,parts:e.parts};if(!this.#b(s,i?.parts??[])){t.preventDefault();return}if(this.arcgisSubmit.emit(e).defaultPrevented){t.preventDefault();return}this.keepSuggestedPrompts||(this.suggestedPrompts=[]),this._inputValue="",this.submitMessage(s,i)},this.#c=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.#h=t=>{t.stopPropagation();let e=t.detail;this.arcgisFeedback.emit(e)},this.#d=t=>{t.stopPropagation();let e=t.detail;this._inputValue=e.prompt,this.arcgisPromptSelect.emit(e)},this.#u=t=>{this.arcgisSlottableRequest.emit(t.detail)},this._orchestratorController=null,this._interrupt=null,this._interruptDetails=[],this._error=null,this._submissionError=null,this._inputValue="",this._isAnswering=!1,this._canceling=!1,this.messages=new q([]),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=u(),this.arcgisError=u(),this.arcgisFeedback=u(),this.arcgisInterrupt=u(),this.arcgisInterruptCancel=u(),this.arcgisInterruptSubmit=u(),this.arcgisPromptSelect=u(),this.arcgisReady=u(),this.arcgisResponse=u(),this.arcgisRuntime=u({bubbles:!1,composed:!1}),this.arcgisSlottableRequest=u({bubbles:!1,composed:!1}),this.arcgisSubmit=u({cancelable:!0})}static{this.properties={_orchestratorController:16,_interrupt:16,_interruptDetails:16,_error:16,_submissionError: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,commandProvider:0,entityProviders:0,suggestedPrompts:0,feedbackEnabled:5,keepSuggestedPrompts:5,streamingDisabled:5,runtimeEventsEnabled:5,logEnabled:5,copyEnabled:5,voiceInputEnabled:5,readAloudEnabled:5,assistantAvatarEnabled:5,userAvatarEnabled:5}}static{this.styles=G}#t;#o;#i;#e;#r;#s;#a;#n;#l;#c;#h;#d;#u;get _isSignedIn(){return!!this.#s?.user||!!this._signedInUserId}get _user(){return this.#s?.user?.fullName||this.#s?.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}cancelInterrupt(){this.arcgisInterruptCancel.emit(),this.orchestrator?.cancelInterrupt(),this._interrupt=null}async clearChatHistory(){this._reset(),this._orchestratorController?.clearChatHistory()}register(t){this.#r.set(t.agent.id,t),this._orchestratorController&&this.#g()}submitInterrupt(t){this.arcgisInterruptSubmit.emit(t),this._interrupt&&(this._interruptDetails=[...this._interruptDetails,{interrupt:this._interrupt,response:t}]),this.orchestrator?.resumeInterrupt(t),this._interrupt=null}async submitMessage(t,e){let s=t.trim(),i=e?.parts??[];if(!s&&!i.length||!this.#b(s,i)||(this.messages.push({id:Date.now().toString(),role:"user",content:e?.displayText?.trim()||s||i.map(o=>this.#_(o)).join(" "),parts:i}),!this._orchestratorController))return;this.#e=new AbortController,this._orchestratorController.streamingDisabled=this.streamingDisabled;let r=this.#m(i),d={...e?.parts?{inputParts:e.parts}:{},...r?{routing:"direct",agentId:r}:{routing:"auto",agentIds:this.allowedAgentIds}},p=this._orchestratorController.ask(s,d,this.#e?.signal);for await(let o of p){let c=o.runId,a=this.messages.at(-1);switch(o.type){case"runtime":this.arcgisRuntime.emit(o.event);break;case"block-start":{this._isAnswering=!0;let n={type:o.blockType,isPending:!0};if(a?.role==="assistant"&&a.id===c){let g=[...a.blocks??[],n];this.messages.splice(-1,1,{...a,blocks:g})}else this.messages.push({role:"assistant",blocks:[n],id:c,isStreaming:!0,interrupts:this._interruptDetails}),this._interruptDetails=[];break}case"block-data":{if(a?.role!=="assistant"||a?.id!==c)break;let n=[...a.blocks??[]],g=n[n.length-1],{blockType:m,data:f}=o;if(g?.type!==m||!g.isPending)break;m==="text"?n[n.length-1]={...g,data:{...g.data,parts:f?.parts}}:n[n.length-1]={...g,data:{...g.data,...f??{}}},this.messages.splice(-1,1,{...a,blocks:n});break}case"block-end":{if(a?.role!=="assistant"||a?.id!==c)break;let n=[...a.blocks??[]],g=n[n.length-1];if(g?.type!==o.blockType||!g.isPending)break;let m=g;n[n.length-1]={...m,data:{...m.data},isPending:!1},this.messages.splice(-1,1,{...a,blocks:n});break}case"completed":o.error?(this.messages.push({role:"assistant",log:o.log,error:o.error,id:c,interrupts:this._interruptDetails}),this._interruptDetails=[]):a?.role==="assistant"&&a.id===c&&this.messages.splice(-1,1,{...a,content:o.response,blocks:a.blocks?.map(n=>({...n,data:{...n.data},isPending:!1}))??[],isStreaming:!1,log:o.log}),this._isAnswering=!1,this.#e=null,this._canceling=!1;break;case"interrupt":this._interrupt={...o.payload,id:c},this.arcgisInterrupt.emit(this._interrupt);break;case"cancelled":a?.role==="assistant"&&a.id===c?this.messages.splice(-1,1,{...a,blocks:a.blocks?.filter(n=>n.type==="text"||!n.isPending)??[],isStreaming:!1,log:o.log,error:`(${this._messages.stoppedByUserLabel})`}):(this.messages.push({role:"assistant",log:o.log,error:`(${this._messages.stoppedByUserLabel})`,id:c,interrupts:this._interruptDetails}),this._interruptDetails=[]),this._isAnswering=!1,this.#e=null,this._canceling=!1;break}}}unregister(t){this.#r.delete(t),this._orchestratorController&&this.#g()}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.#l),this.#t.value?.addEventListener("arcgisCancel",this.#c),this.#t.value?.addEventListener("arcgisFeedback",this.#h);let t=j(()=>!!this._interrupt&&!!this.#i.value,()=>{let s=this.#i.value;s.removeEventListener("arcgisSubmit",this.#n),s.removeEventListener("arcgisCancel",this.#a),s.addEventListener("arcgisSubmit",this.#n,{once:!0}),s.addEventListener("arcgisCancel",this.#a,{once:!0})}),e=this.messages.on("after-add",s=>{let i=s.item;i.role==="assistant"&&(i.error||i.content)&&this.arcgisResponse.emit(i)});return queueMicrotask(()=>{this.#p()}),()=>{t.remove(),e.remove(),this.#t.value?.removeEventListener("arcgisPromptSelect",this.#d),this.#i.value?.removeEventListener("arcgisSubmit",this.#n),this.#i.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}})}willUpdate(t){this.hasUpdated&&t.has("runtimeEventsEnabled")&&this._orchestratorController&&(this._orchestratorController.destroy(),this._orchestratorController=null,this.#p())}#_(t){return t.kind==="command"?`/${t.id}`:`${t.trigger}${t.id}`}#m(t){for(let e of t)if(e.kind==="command"&&e.agentId)return e.agentId;return this.alwaysUseAgentId}#b(t,e){let s=e.filter(i=>i.kind==="command").length>1;return this._submissionError=s?this._messages.multipleCommands:!t.trim()&&e.length>0&&!this.#m(e)?this._messages.partsOnlyRequiresAgent:null,this._submissionError?(this.arcgisError.emit(new Error(this._submissionError)),!1):!0}async#y(){await O.checkSignInStatus(this.#s.url);let t=await this.#s.load();if(!t.helperServices?.aiAssistantServices?.url)throw new Error(this._messages.serviceUrlNotAvailableMessage);let e=!1,s=await t.fetchSettings();if(s.aiConfig?e=s.aiConfig.aiForOrg?.enabled===!0&&s.aiConfig.aiForOrg?.aiCapabilities?.aiAgents?.enabled===!0:e=s.aiAssistantsEnabled===!0,!e)throw new Error(this._messages.aiAssistantsNotEnabledMessage);if(!t.isPortal&&t?.user?.privileges?.includes("portal:user:useAIAssistants")!==!0)throw new Error(this._messages.userPrivilegesNotSufficientMessage)}async#g(){try{this._error=null;let t=M(this.el,this.referenceElement);await t?.componentOnReady();let e=[...this.#r.values()];return e.length?(await this.#y(),this._orchestratorController?.destroy(),this._orchestratorController=new b({agents:e,portal:this.#s,runtimeEventsEnabled:this.runtimeEventsEnabled,streamingDisabled:this.streamingDisabled,view:t?.view}),await this._orchestratorController.load(),this.requestUpdate(),!0):(this._error=this._messages.noAgentsFoundMessage,!1)}catch(t){return this._error=t?.message??this._messages.orchestratorInitializationErrorMessage,C(this)(t),!1}}async#p(){await this.#g()?this.arcgisReady.emit():this._error&&this.arcgisError.emit(new Error(this._error))}_reset(){this._orchestratorController?.cancel(),this.#e?.abort(),this._interrupt=null,this.messages.removeAll(),this._error=null,this._submissionError=null,this._inputValue="",this._signedInUserId=void 0}_renderEntryMessage(){return this._isSignedIn?this._error?this._renderErrorNotice():this.entryMessage?this.messages.length>0?null:h`<calcite-notice open kind=brand closable icon width=full><div slot=message>${this.entryMessage}</div></calcite-notice>`:h`<slot name=entry-message></slot>`:this._renderSignInNotice()}_renderSignInNotice(){let t=this.#s;return h`<calcite-notice slot=entry-message open kind=brand icon width=full><div slot=message>${this._messages.signInRequiredMessage}</div>${t?h`<calcite-link slot=link @click=${async()=>{try{let e=await O.getCredential(`${t.url}/sharing`);this._signedInUserId=e.userId,this._error=null,this.requestUpdate(),await this.#p()}catch(e){this._error=e?.message??this._messages.signInErrorMessage,this.arcgisError.emit(new Error(this._error)),A("error",this,"Error signing in:",{detail:{error:e}})}}} target=_blank title=${this._messages.signInToArcGISOnlineLabel??v}>${this._messages.signInLabel}</calcite-link>`:h`<div slot=link>${this._messages.noPortalInformationMessage}</div>`}</calcite-notice>`}_renderErrorNotice(){return this._error?h`<calcite-notice slot=entry-message open kind=brand icon width=full>${this._error===Y?h`<div slot=message>${tt}</div><calcite-link slot=link .href=${et} target=_blank title=${this._messages.learnAboutWebMapEmbeddingsLabel??v}>${this._messages.readMoreLabel}</calcite-link>`:h`<div slot=message>${this._error}</div>`}</calcite-notice>`:null}render(){return h`<calcite-panel .loading=${!this._orchestratorController&&!this._error||this._orchestratorController?.loading} .heading=${this.heading??this._messages.assistantLabel} .description=${this.description} ${E(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"?h`<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,s)=>h`<slot name=${$(t.id,s)??v} slot=${$(t.id,s)??v}><arcgis-assistant-message-block .block=${e}></arcgis-assistant-message-block></slot>`)}</arcgis-assistant-message>`:h`<arcgis-assistant-user-message .message=${t} .user=${this._user} .userAvatarEnabled=${this.userAvatarEnabled}></arcgis-assistant-user-message>`)}</slot>${this._interrupt?h`<div slot=message-loading><div class="interrupt-waiting-message">${this._messages.waitingForUserInputMessage}</div></div>`:h`<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?h`<slot name=interrupt><arcgis-assistant-interrupt slot=content-bottom .type=${this._interrupt.type} .message=${this._interrupt.message} .options=${this._interrupt.options} ${E(this.#i)}></arcgis-assistant-interrupt></slot>`:this.suggestedPrompts?.length?h`<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()}${this._submissionError?h`<div role=alert>${this._submissionError}</div>`:null}<slot name=chat-entry><arcgis-assistant-chat-entry .awaitingResponse=${this.awaitingResponse||this._isAnswering} .commandProvider=${this.commandProvider} .entityProviders=${this.entityProviders} .inputValue=${this._inputValue} .messages=${this.messages} .voiceInputEnabled=${this.voiceInputEnabled} .disabled=${this._canceling||!this._isSignedIn||!!this._interrupt||!!this._error} ${E(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=${()=>{this.#o.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>`}};L("arcgis-assistant",x);return x},"core/Collection","core/reactiveUtils","portal/Portal","request","identity/IdentityManager","config","layers/FeatureLayer","core/Accessor","core/accessorSupport/decorators",a,b)
@@ -1,2 +1,2 @@
1
1
  /* COPYRIGHT Esri - https://js.arcgis.com/5.2/LICENSE.txt */
2
- import{b as n}from"./6OOZSZRJ.js";import"./RLEHNAIA.js";import{g as e,h as i,v as r,z as a}from"./COH3QXWG.js";import"./R74ZHFA6.js";import"./UZLQALHY.js";var c=e`.interrupt-details{word-wrap:break-word}.interrupt-details ul{margin-block:var(--calcite-spacing-xxs) 0;padding-inline-start:var(--calcite-spacing-xxl)}.interrupt-details li{margin-block:0}.interrupts-container{display:flex;flex-direction:column;gap:var(--calcite-spacing-lg)}`,t=class extends r{constructor(){super(...arguments),this._messages=n({blocking:!0})}static{this.properties={interrupts:0}}static{this.styles=c}render(){return this.interrupts?.length?i`<calcite-block expandable expanded .heading=${this._messages.assistantQuestions}><div class="interrupts-container">${this.interrupts?.map(({interrupt:l,response:s})=>i`<div class="interrupt-details"><div>Q: ${l.message}</div><ul>${Array.isArray(s)?s.length?s.map(p=>i`<li>${p}</li>`):i`<li>${this._messages.questionSkipped}</li>`:i`<li>${s!=null?String(s):this._messages.questionSkipped}</li>`}</ul></div>`)}</div></calcite-block>`:null}};a("arcgis-assistant-interrupt-preview",t);export{t as ArcgisAssistantInterruptPreview};
2
+ import{b as n}from"./5QXGQW2N.js";import"./NWJQ7KTC.js";import{g as e,h as i,v as r,z as a}from"./COH3QXWG.js";import"./R74ZHFA6.js";import"./UZLQALHY.js";var c=e`.interrupt-details{word-wrap:break-word}.interrupt-details ul{margin-block:var(--calcite-spacing-xxs) 0;padding-inline-start:var(--calcite-spacing-xxl)}.interrupt-details li{margin-block:0}.interrupts-container{display:flex;flex-direction:column;gap:var(--calcite-spacing-lg)}`,t=class extends r{constructor(){super(...arguments),this._messages=n({blocking:!0})}static{this.properties={interrupts:0}}static{this.styles=c}render(){return this.interrupts?.length?i`<calcite-block expandable expanded .heading=${this._messages.assistantQuestions}><div class="interrupts-container">${this.interrupts?.map(({interrupt:l,response:s})=>i`<div class="interrupt-details"><div>Q: ${l.message}</div><ul>${Array.isArray(s)?s.length?s.map(p=>i`<li>${p}</li>`):i`<li>${this._messages.questionSkipped}</li>`:i`<li>${s!=null?String(s):this._messages.questionSkipped}</li>`}</ul></div>`)}</div></calcite-block>`:null}};a("arcgis-assistant-interrupt-preview",t);export{t as ArcgisAssistantInterruptPreview};
@@ -1,2 +1,2 @@
1
1
  /* COPYRIGHT Esri - https://js.arcgis.com/5.2/LICENSE.txt */
2
- import c from"./Y27GVWWU.js";import"./P4XZMBU5.js";import b from"./LUYP76B7.js";import"./CLRFKSAT.js";import a from"./64IWQ7A4.js";import"./FS7GXTTQ.js";import"./R74ZHFA6.js";import"./V7Y22FRP.js";import"./QRMRID2M.js";import"./AXTQU5YL.js";import"./LOQ2PKV5.js";import"./IYLFJCJ2.js";import"./VXFQANGJ.js";import"./MWYBF3F3.js";import"./UZLQALHY.js";export default $arcgis.t(([,,a])=>{return a},a,b,c)
2
+ import c from"./ZGZX7GR5.js";import"./P4XZMBU5.js";import b from"./ZCFYGCCV.js";import"./ZA2WIUWH.js";import a from"./2NODROJN.js";import"./QZL4SAYR.js";import"./R74ZHFA6.js";import"./V7Y22FRP.js";import"./QRMRID2M.js";import"./AXTQU5YL.js";import"./LOQ2PKV5.js";import"./IYLFJCJ2.js";import"./VXFQANGJ.js";import"./MWYBF3F3.js";import"./UZLQALHY.js";export default $arcgis.t(([,,a])=>{return a},a,b,c)
@@ -1,2 +1,2 @@
1
1
  /* COPYRIGHT Esri - https://js.arcgis.com/5.2/LICENSE.txt */
2
- import{d as b}from"./FS7GXTTQ.js";import{Ya as G,ka as u,r as E,s as y}from"./LOQ2PKV5.js";var x=new Set(["agentExecutionContext","outputMessage","summary","status","sharedResourceAdditions"]);function O(r){let o=[...new Set([...r].filter(t=>x.has(t)))];if(o.length!==0)throw new Error(`custom state cannot define reserved runtime fields: ${o.join(", ")}.`)}function $(r){let o=Object.entries(r);return Object.fromEntries(o.map(([t,n])=>[t,u({reducer:(s,h)=>h,default:()=>n})]))}function S(r={}){O(Object.keys(r));let o=$(r);return u.Root({...o,agentExecutionContext:u({reducer:(t,n)=>({...t,...n}),default:b}),outputMessage:u({reducer:(t="",n)=>typeof n=="string"&&n.trim()?n:t,default:()=>""}),summary:u({reducer:(t="",n)=>typeof n=="string"?n:t,default:()=>""}),status:u({reducer:(t,n)=>n??t,default:()=>{}}),sharedResourceAdditions:u({reducer:(t,n)=>n,default:()=>{}})})}function M(r,o=[]){let t=new Set(o);for(let s of r)for(let h of Object.keys(s.shape??{}))t.add(h);let n=Object.fromEntries([...t].map(s=>[s,void 0]));return S(n)}function P(r,o,t,n={}){let{agent:s,entryNode:h,middlewares:f=[]}=n,i=new G(t);if(Object.keys(r).length===0)throw new Error("Graph requires at least one node.");if(o.length===0)throw new Error("Graph requires at least one edge.");if(f.length>0&&!s)throw new Error("Graph middleware requires agent metadata.");let a=new Set(Object.keys(r)),l=new Map,g=new Map;for(let e of a)l.set(e,0),g.set(e,0);for(let e of o)"to"in e?(a.has(e.from)&&g.set(e.from,(g.get(e.from)??0)+1),a.has(e.to)&&l.set(e.to,(l.get(e.to)??0)+1)):a.has(e.from)&&g.set(e.from,(g.get(e.from)??0)+1);for(let[e,d]of Object.entries(r)){let w=N(s,e,f,async(c,p)=>await Promise.resolve(d(c,p))),m=async(c,p)=>await w(c,p);i=i.addNode(e,m)}for(let e of o)if("to"in e){let d=e.from,w=e.to;if(!a.has(d))throw new Error(`Graph edge references unknown from-node: ${d}`);if(!a.has(w))throw new Error(`Graph edge references unknown to-node: ${w}`);i.addEdge(d,w)}else{let d=e.from;if(!a.has(d))throw new Error(`Graph conditional edge references unknown from-node: ${d}`);i.addConditionalEdges(d,async(w,m)=>{let c=await e.decide(w,m);if(!c)return y;if(!a.has(c))throw new Error(`Graph conditional edge returned unknown node: ${c}`);return c})}let k=R(a,l,h);i.addEdge(E,k);let j=[...a].filter(e=>(g.get(e)??0)===0);for(let e of j)i.addEdge(e,y);return i}function N(r,o,t,n){return!t.length||!r?n:async(s,h)=>await t.reduceRight((f,i)=>async a=>await i.handler(a,f),async f=>{let i=await n(f.state,f.config);return{...f.state,...i}})({agent:r,config:h,nodeName:o,state:s})}function R(r,o,t){if(t){if(!r.has(t))throw new Error(`Graph entry node references unknown node: ${t}`);return t}let n=[...r].filter(s=>(o.get(s)??0)===0);if(n.length!==1)throw new Error(`Graph could not infer a single entry node (found ${n.length}). Provide an explicit entryNode or ensure exactly one node has no incoming edges.`);return n[0]}export{O as a,$ as b,S as c,M as d,P as e};
2
+ import{d as b}from"./QZL4SAYR.js";import{Ya as G,ka as u,r as E,s as y}from"./LOQ2PKV5.js";var x=new Set(["agentExecutionContext","outputMessage","summary","status","sharedResourceAdditions"]);function O(r){let o=[...new Set([...r].filter(t=>x.has(t)))];if(o.length!==0)throw new Error(`custom state cannot define reserved runtime fields: ${o.join(", ")}.`)}function $(r){let o=Object.entries(r);return Object.fromEntries(o.map(([t,n])=>[t,u({reducer:(s,h)=>h,default:()=>n})]))}function S(r={}){O(Object.keys(r));let o=$(r);return u.Root({...o,agentExecutionContext:u({reducer:(t,n)=>({...t,...n}),default:b}),outputMessage:u({reducer:(t="",n)=>typeof n=="string"&&n.trim()?n:t,default:()=>""}),summary:u({reducer:(t="",n)=>typeof n=="string"?n:t,default:()=>""}),status:u({reducer:(t,n)=>n??t,default:()=>{}}),sharedResourceAdditions:u({reducer:(t,n)=>n,default:()=>{}})})}function M(r,o=[]){let t=new Set(o);for(let s of r)for(let h of Object.keys(s.shape??{}))t.add(h);let n=Object.fromEntries([...t].map(s=>[s,void 0]));return S(n)}function P(r,o,t,n={}){let{agent:s,entryNode:h,middlewares:f=[]}=n,i=new G(t);if(Object.keys(r).length===0)throw new Error("Graph requires at least one node.");if(o.length===0)throw new Error("Graph requires at least one edge.");if(f.length>0&&!s)throw new Error("Graph middleware requires agent metadata.");let a=new Set(Object.keys(r)),l=new Map,g=new Map;for(let e of a)l.set(e,0),g.set(e,0);for(let e of o)"to"in e?(a.has(e.from)&&g.set(e.from,(g.get(e.from)??0)+1),a.has(e.to)&&l.set(e.to,(l.get(e.to)??0)+1)):a.has(e.from)&&g.set(e.from,(g.get(e.from)??0)+1);for(let[e,d]of Object.entries(r)){let w=N(s,e,f,async(c,p)=>await Promise.resolve(d(c,p))),m=async(c,p)=>await w(c,p);i=i.addNode(e,m)}for(let e of o)if("to"in e){let d=e.from,w=e.to;if(!a.has(d))throw new Error(`Graph edge references unknown from-node: ${d}`);if(!a.has(w))throw new Error(`Graph edge references unknown to-node: ${w}`);i.addEdge(d,w)}else{let d=e.from;if(!a.has(d))throw new Error(`Graph conditional edge references unknown from-node: ${d}`);i.addConditionalEdges(d,async(w,m)=>{let c=await e.decide(w,m);if(!c)return y;if(!a.has(c))throw new Error(`Graph conditional edge returned unknown node: ${c}`);return c})}let k=R(a,l,h);i.addEdge(E,k);let j=[...a].filter(e=>(g.get(e)??0)===0);for(let e of j)i.addEdge(e,y);return i}function N(r,o,t,n){return!t.length||!r?n:async(s,h)=>await t.reduceRight((f,i)=>async a=>await i.handler(a,f),async f=>{let i=await n(f.state,f.config);return{...f.state,...i}})({agent:r,config:h,nodeName:o,state:s})}function R(r,o,t){if(t){if(!r.has(t))throw new Error(`Graph entry node references unknown node: ${t}`);return t}let n=[...r].filter(s=>(o.get(s)??0)===0);if(n.length!==1)throw new Error(`Graph could not infer a single entry node (found ${n.length}). Provide an explicit entryNode or ensure exactly one node has no incoming edges.`);return n[0]}export{O as a,$ as b,S as c,M as d,P as e};
@@ -1,2 +1,2 @@
1
1
  /* COPYRIGHT Esri - https://js.arcgis.com/5.2/LICENSE.txt */
2
- import{c}from"./CLRFKSAT.js";export default $arcgis.t(([l,{property:i,subclass:y},{watch:d}])=>{var w=Object.defineProperty,g=Object.getOwnPropertyDescriptor,t=(s,a,p,o)=>{for(var r=o>1?void 0:o?g(a,p):a,h=s.length-1,n;h>=0;h--)(n=s[h])&&(r=(o?n(a,p,r):n(r))||r);return o&&r&&w(a,p,r),r},m=()=>{throw new Error("createGraph method not implemented.")},e=class extends l{constructor(){super(...arguments),this.description="",this.middlewares=[],this.createGraph=m,this.workspace=c()}initialize(){this.addHandles([d(()=>[this.name,this.description],()=>this.generate(),{initial:!0,sync:!0}),d(()=>this.createGraph,()=>this._compiledGraph=void 0)])}get id(){return this.name.replace(/\s+/gu,"-").toLowerCase()}get registration(){return{id:this.id,name:this.name,description:this.description,createGraph:this.createGraph,workspace:this.workspace}}async run(s={},a){return this.createGraph===m&&this.generate(),this._compiledGraph=this._compiledGraph??this.createGraph().compile(),await this._compiledGraph.invoke(s,a)}};t([i({readOnly:!0})],e.prototype,"id",1);t([i()],e.prototype,"name",2);t([i()],e.prototype,"description",2);t([i()],e.prototype,"middlewares",2);t([i({readOnly:!0})],e.prototype,"createGraph",2);t([i({readOnly:!0})],e.prototype,"workspace",2);t([i({readOnly:!0})],e.prototype,"registration",1);e=t([y("BaseAgent")],e);return e},"core/Accessor","core/accessorSupport/decorators","core/reactiveUtils")
2
+ import{c}from"./ZA2WIUWH.js";export default $arcgis.t(([l,{property:i,subclass:y},{watch:d}])=>{var w=Object.defineProperty,g=Object.getOwnPropertyDescriptor,t=(s,a,p,o)=>{for(var r=o>1?void 0:o?g(a,p):a,h=s.length-1,n;h>=0;h--)(n=s[h])&&(r=(o?n(a,p,r):n(r))||r);return o&&r&&w(a,p,r),r},m=()=>{throw new Error("createGraph method not implemented.")},e=class extends l{constructor(){super(...arguments),this.description="",this.middlewares=[],this.createGraph=m,this.workspace=c()}initialize(){this.addHandles([d(()=>[this.name,this.description],()=>this.generate(),{initial:!0,sync:!0}),d(()=>this.createGraph,()=>this._compiledGraph=void 0)])}get id(){return this.name.replace(/\s+/gu,"-").toLowerCase()}get registration(){return{id:this.id,name:this.name,description:this.description,createGraph:this.createGraph,workspace:this.workspace}}async run(s={},a){return this.createGraph===m&&this.generate(),this._compiledGraph=this._compiledGraph??this.createGraph().compile(),await this._compiledGraph.invoke(s,a)}};t([i({readOnly:!0})],e.prototype,"id",1);t([i()],e.prototype,"name",2);t([i()],e.prototype,"description",2);t([i()],e.prototype,"middlewares",2);t([i({readOnly:!0})],e.prototype,"createGraph",2);t([i({readOnly:!0})],e.prototype,"workspace",2);t([i({readOnly:!0})],e.prototype,"registration",1);e=t([y("BaseAgent")],e);return e},"core/Accessor","core/accessorSupport/decorators","core/reactiveUtils")
@@ -1,2 +1,2 @@
1
1
  /* COPYRIGHT Esri - https://js.arcgis.com/5.2/LICENSE.txt */
2
- import{a as l,b as S}from"./P4XZMBU5.js";import b from"./LUYP76B7.js";import{d as y,e as v}from"./CLRFKSAT.js";import a from"./64IWQ7A4.js";import{c as d}from"./QRMRID2M.js";import{a as w,c as h}from"./AXTQU5YL.js";import{P as f,aa as u}from"./LOQ2PKV5.js";import{O as g}from"./IYLFJCJ2.js";export default $arcgis.t(([,,,{watch:A},,{property:m,subclass:k},{b:c},T])=>{var x=Object.defineProperty,b=Object.getOwnPropertyDescriptor,n=(e,r,t,o)=>{for(var s=o>1?void 0:o?b(r,t):r,i=e.length-1,p;i>=0;i--)(p=e[i])&&(s=(o?p(r,t,s):p(s))||s);return o&&s&&x(r,t,s),s},a=class extends T{constructor(e){super(e),this.modelTier="default"}initialize(){this.addHandles(A(()=>[this.description,this.inputSchema,this.modelTier,this.name,this.outputSchema,this.prompt,this.tools],()=>{this.generate()},{initial:!0,sync:!0}))}getSchemas(){return[this.inputSchema,this.outputSchema].filter(Boolean)}generate(){let e=this.prompt?u.fromTemplate(this.prompt).inputVariables:[],r=y(this.getSchemas(),e);this._set("workspace",r);let t=this.id,o={[t]:this._invoke.bind(this)},s=[{from:t,decide:()=>{}}];this._set("createGraph",()=>v(o,s,r,{agent:this,entryNode:t,middlewares:this.middlewares}))}async _invoke(e,r){try{return this.outputSchema?await this._invokeStructured(e,r):await this._invokeUnstructured(e,r)}catch(t){if(f(t))throw t;let o=t instanceof Error?t.message:String(t);return l({outputMessage:o},"failed",o)}}async _invokeStructured(e,r){if(!this.outputSchema)throw new Error("Output schema is required for structured invocation.");let t=await h({model:await c({modelTier:this.modelTier}),systemPrompt:await this._getPromptWithInputVariables(e),tools:this._getTools(),checkpointer:!0,middleware:d(this.middlewares),responseFormat:w(this.outputSchema)}).invoke({messages:e.agentExecutionContext.messages},r);if(!("structuredResponse"in t)||t.structuredResponse===void 0)throw new Error("LLMAgent did not receive structured output from createAgent.");return{...S(t.structuredResponse,this.outputSchema,t.messages),sharedResourceAdditions:_(t.messages)}}async _invokeUnstructured(e,r){let t=(await h({model:await c({modelTier:this.modelTier}),systemPrompt:await this._getPromptWithInputVariables(e),tools:this._getTools(),checkpointer:!0,middleware:d(this.middlewares)}).invoke({messages:e.agentExecutionContext.messages},r)).messages,o=t.at(-1)?.text??"",s=o.trim()||"LLMAgent completed.";return l({agentExecutionContext:{...e.agentExecutionContext,messages:t},outputMessage:o,sharedResourceAdditions:_(t)},"success",s)}async _getPromptWithInputVariables(e){return await u.fromTemplate(this.prompt).format(e)}_getTools(){return this.tools?.map(e=>"getTool"in e?e.getTool():e)??[]}};n([m()],a.prototype,"prompt",2);n([m()],a.prototype,"tools",2);n([m()],a.prototype,"inputSchema",2);n([m()],a.prototype,"outputSchema",2);n([m()],a.prototype,"modelTier",2);a=n([k("LLMAgent")],a);function _(e){let r=[];for(let t of e)if(g.isInstance(t)&&t.status!=="error"){let o=t.artifact;if(typeof o=="object"&&o!==null&&"sharedResourceAdditions"in o){let s=o.sharedResourceAdditions;if(Array.isArray(s))for(let i of s)r.push({kind:i.kind,description:i.description,payload:i.payload})}}return r}return a},"identity/IdentityManager","portal/Portal","request","core/reactiveUtils","layers/FeatureLayer","core/accessorSupport/decorators",a,b)
2
+ import{a as l,b as S}from"./P4XZMBU5.js";import b from"./ZCFYGCCV.js";import{d as y,e as v}from"./ZA2WIUWH.js";import a from"./2NODROJN.js";import{c as d}from"./QRMRID2M.js";import{a as w,c as h}from"./AXTQU5YL.js";import{P as f,aa as u}from"./LOQ2PKV5.js";import{O as g}from"./IYLFJCJ2.js";export default $arcgis.t(([,,,{watch:A},,{property:m,subclass:k},{b:c},T])=>{var x=Object.defineProperty,b=Object.getOwnPropertyDescriptor,n=(e,r,t,o)=>{for(var s=o>1?void 0:o?b(r,t):r,i=e.length-1,p;i>=0;i--)(p=e[i])&&(s=(o?p(r,t,s):p(s))||s);return o&&s&&x(r,t,s),s},a=class extends T{constructor(e){super(e),this.modelTier="default"}initialize(){this.addHandles(A(()=>[this.description,this.inputSchema,this.modelTier,this.name,this.outputSchema,this.prompt,this.tools],()=>{this.generate()},{initial:!0,sync:!0}))}getSchemas(){return[this.inputSchema,this.outputSchema].filter(Boolean)}generate(){let e=this.prompt?u.fromTemplate(this.prompt).inputVariables:[],r=y(this.getSchemas(),e);this._set("workspace",r);let t=this.id,o={[t]:this._invoke.bind(this)},s=[{from:t,decide:()=>{}}];this._set("createGraph",()=>v(o,s,r,{agent:this,entryNode:t,middlewares:this.middlewares}))}async _invoke(e,r){try{return this.outputSchema?await this._invokeStructured(e,r):await this._invokeUnstructured(e,r)}catch(t){if(f(t))throw t;let o=t instanceof Error?t.message:String(t);return l({outputMessage:o},"failed",o)}}async _invokeStructured(e,r){if(!this.outputSchema)throw new Error("Output schema is required for structured invocation.");let t=await h({model:await c({modelTier:this.modelTier}),systemPrompt:await this._getPromptWithInputVariables(e),tools:this._getTools(),checkpointer:!0,middleware:d(this.middlewares),responseFormat:w(this.outputSchema)}).invoke({messages:e.agentExecutionContext.messages},r);if(!("structuredResponse"in t)||t.structuredResponse===void 0)throw new Error("LLMAgent did not receive structured output from createAgent.");return{...S(t.structuredResponse,this.outputSchema,t.messages),sharedResourceAdditions:_(t.messages)}}async _invokeUnstructured(e,r){let t=(await h({model:await c({modelTier:this.modelTier}),systemPrompt:await this._getPromptWithInputVariables(e),tools:this._getTools(),checkpointer:!0,middleware:d(this.middlewares)}).invoke({messages:e.agentExecutionContext.messages},r)).messages,o=t.at(-1)?.text??"",s=o.trim()||"LLMAgent completed.";return l({agentExecutionContext:{...e.agentExecutionContext,messages:t},outputMessage:o,sharedResourceAdditions:_(t)},"success",s)}async _getPromptWithInputVariables(e){return await u.fromTemplate(this.prompt).format(e)}_getTools(){return this.tools?.map(e=>"getTool"in e?e.getTool():e)??[]}};n([m()],a.prototype,"prompt",2);n([m()],a.prototype,"tools",2);n([m()],a.prototype,"inputSchema",2);n([m()],a.prototype,"outputSchema",2);n([m()],a.prototype,"modelTier",2);a=n([k("LLMAgent")],a);function _(e){let r=[];for(let t of e)if(g.isInstance(t)&&t.status!=="error"){let o=t.artifact;if(typeof o=="object"&&o!==null&&"sharedResourceAdditions"in o){let s=o.sharedResourceAdditions;if(Array.isArray(s))for(let i of s)r.push({kind:i.kind,description:i.description,payload:i.payload})}}return r}return a},"identity/IdentityManager","portal/Portal","request","core/reactiveUtils","layers/FeatureLayer","core/accessorSupport/decorators",a,b)
@@ -1,2 +1,2 @@
1
1
  /* COPYRIGHT Esri - https://js.arcgis.com/5.2/LICENSE.txt */
2
- import"../UZLQALHY.js";var e,a,i,c,u,s,w,l,f,m,p,y;async function r(n,t){if(t in n)return n[t];if("default"in n){let o=await n.default;return typeof o=="object"&&o!==null&&t in o?o[t]:o}throw new Error(`Unable to resolve ${String(t)} from module.`)}function W(n,t){let o={};for(let[b,k]of Object.entries(t))o[b]=h(n,k);return o}function d(n,t){return n.object(W(n,t))}function h(n,t){let o=g(n,t);return t.required===!0?o:o.optional()}function g(n,t){let o=T(n,t);return t.description!==void 0&&(o=o.describe(t.description)),o}function S(n,t){switch(t){case"string":return n.string();case"number":return n.number();case"boolean":return n.boolean()}}function A(n){return n==="string"||n==="number"||n==="boolean"}function T(n,t){switch(t.type){case"string":{if(t.enum!=null){if(t.enum.length===0)throw new Error("String schema field enum must include at least one value.");return n.enum(t.enum)}return n.string()}case"number":return n.number();case"boolean":return n.boolean();case"array":{if(t.itemType==null)throw new Error("Array schema field requires an itemType definition.");return n.array(A(t.itemType)?S(n,t.itemType):g(n,t.itemType))}case"object":{if(t.fields==null)throw new Error("Object schema field requires a fields definition.");return d(n,t.fields)}}}async function L(n){p??=import("../APFZY4PI.js");let t=await p;return d(t.z,n)}async function j(n,t){y??=import("../PMILRLSD.js");let o=await y;return await(await r(o,"sendUXSuggestion"))(n,t)}async function q(n){e??=import("../2642ADON.js");let t=await e,o=await r(t,"FunctionAgent");return new o(n)}async function E(n){a??=import("../YHWYTHID.js");let t=await a,o=await r(t,"FunctionTool");return new o(n)}async function F(n){i??=import("../ZGQ27DU2.js");let t=await i,o=await r(t,"LLMAgent");return new o(n)}async function v(n){c??=import("../4XTSGMV7.js");let t=await c,o=await r(t,"WorkflowAgent");return new o(n)}async function U(n){u??=import("../TAMMDFVT.js");let t=await u,o=await r(t,"ConditionalWorkflow");return new o(n)}async function M(n){s??=import("../U7SYNCYR.js");let t=await s,o=await r(t,"LoopWorkflow");return new o(n)}async function P(n){w??=import("../H5DD7DRB.js");let t=await w,o=await r(t,"ParallelWorkflow");return new o(n)}async function R(n){l??=import("../YYDZAPJP.js");let t=await l,o=await r(t,"RouterWorkflow");return new o(n)}async function X(n){f??=import("../JO7U7E24.js");let t=await f,o=await r(t,"SequentialWorkflow");return new o(n)}async function x(n){m??=import("../L3K457Y6.js");let t=await m,o=await r(t,"SwitchWorkflow");return new o(n)}export{U as createConditionalWorkflow,q as createFunctionAgent,E as createFunctionTool,F as createLLMAgent,M as createLoopWorkflow,P as createParallelWorkflow,R as createRouterWorkflow,L as createSchema,X as createSequentialWorkflow,x as createSwitchWorkflow,v as createWorkflowAgent,j as sendUXSuggestion};
2
+ import"../UZLQALHY.js";var e,a,i,c,u,s,w,l,f,m,p,y;async function r(n,t){if(t in n)return n[t];if("default"in n){let o=await n.default;return typeof o=="object"&&o!==null&&t in o?o[t]:o}throw new Error(`Unable to resolve ${String(t)} from module.`)}function W(n,t){let o={};for(let[b,k]of Object.entries(t))o[b]=h(n,k);return o}function d(n,t){return n.object(W(n,t))}function h(n,t){let o=g(n,t);return t.required===!0?o:o.optional()}function g(n,t){let o=T(n,t);return t.description!==void 0&&(o=o.describe(t.description)),o}function S(n,t){switch(t){case"string":return n.string();case"number":return n.number();case"boolean":return n.boolean()}}function A(n){return n==="string"||n==="number"||n==="boolean"}function T(n,t){switch(t.type){case"string":{if(t.enum!=null){if(t.enum.length===0)throw new Error("String schema field enum must include at least one value.");return n.enum(t.enum)}return n.string()}case"number":return n.number();case"boolean":return n.boolean();case"array":{if(t.itemType==null)throw new Error("Array schema field requires an itemType definition.");return n.array(A(t.itemType)?S(n,t.itemType):g(n,t.itemType))}case"object":{if(t.fields==null)throw new Error("Object schema field requires a fields definition.");return d(n,t.fields)}}}async function L(n){p??=import("../APFZY4PI.js");let t=await p;return d(t.z,n)}async function j(n,t){y??=import("../CESQ3SFP.js");let o=await y;return await(await r(o,"sendUXSuggestion"))(n,t)}async function q(n){e??=import("../SLD4ZVT6.js");let t=await e,o=await r(t,"FunctionAgent");return new o(n)}async function E(n){a??=import("../YHWYTHID.js");let t=await a,o=await r(t,"FunctionTool");return new o(n)}async function F(n){i??=import("../XUYARLRP.js");let t=await i,o=await r(t,"LLMAgent");return new o(n)}async function v(n){c??=import("../ITCZC2VY.js");let t=await c,o=await r(t,"WorkflowAgent");return new o(n)}async function U(n){u??=import("../HSILCMAR.js");let t=await u,o=await r(t,"ConditionalWorkflow");return new o(n)}async function M(n){s??=import("../JTEY4E7E.js");let t=await s,o=await r(t,"LoopWorkflow");return new o(n)}async function P(n){w??=import("../6XZYQ74A.js");let t=await w,o=await r(t,"ParallelWorkflow");return new o(n)}async function R(n){l??=import("../LDIUJUI7.js");let t=await l,o=await r(t,"RouterWorkflow");return new o(n)}async function X(n){f??=import("../BN7CIVBD.js");let t=await f,o=await r(t,"SequentialWorkflow");return new o(n)}async function x(n){m??=import("../CLTV27HJ.js");let t=await m,o=await r(t,"SwitchWorkflow");return new o(n)}export{U as createConditionalWorkflow,q as createFunctionAgent,E as createFunctionTool,F as createLLMAgent,M as createLoopWorkflow,P as createParallelWorkflow,R as createRouterWorkflow,L as createSchema,X as createSequentialWorkflow,x as createSwitchWorkflow,v as createWorkflowAgent,j as sendUXSuggestion};
@@ -1 +1 @@
1
- {"assistantLabel":"Assistant","stopButtonLabel":"Stop","askButtonLabel":"Ask","stoppedByUserLabel":"Stopped by user","noAgentsFoundMessage":"No agents found.","orchestratorInitializationErrorMessage":"Error initializing orchestrator.","signInErrorMessage":"Error signing in.","signInRequiredMessage":"You need to sign in to use the assistant chat.","signInLabel":"Sign in","signInToArcGISOnlineLabel":"Sign in to ArcGIS Online","noPortalInformationMessage":"No portal information available","readMoreLabel":"Read more","learnAboutWebMapEmbeddingsLabel":"Learn about web map embeddings","waitingForUserInputMessage":"Waiting for user input...","aiAssistantsNotEnabledMessage":"To chat here, AI features and AI agents must be enabled for your organization.","serviceUrlNotAvailableMessage":"The AI Assistant Service URL setting for your organization is missing or incorrect.","userPrivilegesNotSufficientMessage":"To chat here, AI features and AI agents must be enabled for your organization and your role privilege needs to allow you to use AI agents."}
1
+ {"assistantLabel":"Assistant","multipleCommands":"Submit only one command at a time.","partsOnlyRequiresAgent":"Enter a message or select an agent before submitting structured input.","stopButtonLabel":"Stop","askButtonLabel":"Ask","stoppedByUserLabel":"Stopped by user","noAgentsFoundMessage":"No agents found.","orchestratorInitializationErrorMessage":"Error initializing orchestrator.","signInErrorMessage":"Error signing in.","signInRequiredMessage":"You need to sign in to use the assistant chat.","signInLabel":"Sign in","signInToArcGISOnlineLabel":"Sign in to ArcGIS Online","noPortalInformationMessage":"No portal information available","readMoreLabel":"Read more","learnAboutWebMapEmbeddingsLabel":"Learn about web map embeddings","waitingForUserInputMessage":"Waiting for user input...","aiAssistantsNotEnabledMessage":"To chat here, AI features and AI agents must be enabled for your organization.","serviceUrlNotAvailableMessage":"The AI Assistant Service URL setting for your organization is missing or incorrect.","userPrivilegesNotSufficientMessage":"To chat here, AI features and AI agents must be enabled for your organization and your role privilege needs to allow you to use AI agents."}
@@ -1 +1 @@
1
- {"entryPlaceholder":"Type your message here..."}
1
+ {"entryPlaceholder":"Type your message here...","loadingSuggestions":"Loading suggestions...","textRequired":"Enter a message for the selected command.","suggestions":"Suggestions"}
package/dist/cdn/index.js CHANGED
@@ -1,2 +1,2 @@
1
1
  /* COPYRIGHT Esri - https://js.arcgis.com/5.2/LICENSE.txt */
2
- import{p as s,y as e}from"./COH3QXWG.js";import"./R74ZHFA6.js";import"./UZLQALHY.js";var a=s(e,{"arcgis-assistant":[()=>import("./AXY6RA5N.js"),"_messages:,allowedAgentIds:,alwaysUseAgentId,assistantAvatarEnabled,awaitingResponse:,awaitingResponseStep:,copyEnabled,description,entryMessage,feedbackEnabled,heading,interrupt:,keepSuggestedPrompts,logEnabled,messages:,orchestrator:,readAloudEnabled,referenceElement,runtimeEventsEnabled,streamingDisabled,suggestedPrompts:,userAvatarEnabled,voiceInputEnabled;clearChatHistory,submitMessage;cancelInterrupt,register,submitInterrupt,unregister"],"arcgis-assistant-agent":[()=>import("./TAWMLPK2.js"),"agent:,context:,itemId,workflow:;getContext"],"arcgis-assistant-data-exploration-agent":[()=>import("./YR7EYQ4X.js"),"referenceElement;;getContext"],"arcgis-assistant-help-agent":[()=>import("./QXOOEBIR.js"),"referenceElement;;getContext"],"arcgis-assistant-knowledge-agent":[()=>import("./HXEAVHLM.js"),"context:,referenceElement,serviceUrl;getContext"],"arcgis-assistant-layer-styling-agent":[()=>import("./J3D2JL4H.js"),"referenceElement;;getContext"],"arcgis-assistant-navigation-agent":[()=>import("./C2RSZ3VK.js"),"referenceElement;;getContext"],"arcgis-assistant-chat":[()=>import("./6ECRQVHY.js"),"interrupt:,loading,messages:"],"arcgis-assistant-chat-entry":[()=>import("./2O4DON37.js"),"_messages:,awaitingResponse,disabled,entryPlaceholder,inputValue,keyboardShortcutsDisabled,messages:,status,voiceInputEnabled;submitMessage"],"arcgis-assistant-interrupt":[()=>import("./F5NIRETW.js"),"_messages:,message,options:,type"],"arcgis-assistant-interrupt-preview":[()=>import("./UDRKUVZP.js"),"interrupts:"],"arcgis-assistant-message":[()=>import("./EYOWRGDP.js"),"_messages:,assistantAvatarEnabled,copyEnabled,feedbackEnabled,footerDisabled,logEnabled,message:,readAloudEnabled"],"arcgis-assistant-message-block":[()=>import("./5HBAJ57P.js"),"block:"],"arcgis-assistant-message-feedback":[()=>import("./MXTXJKFE.js"),"_messages:,feedbackEnabled,message:"],"arcgis-assistant-message-footer":[()=>import("./6P44KOKX.js"),"_messages:,copyEnabled,feedbackEnabled,logEnabled,message:,readAloudEnabled"],"arcgis-assistant-message-loading":[()=>import("./O4NVW75A.js"),"_messages:,assistantAvatarEnabled,interrupts:,loading,loadingMessage"],"arcgis-assistant-message-log":[()=>import("./F3CSORDI.js"),"log:,logEnabled,showLog"],"arcgis-assistant-message-read-aloud":[()=>import("./WSWB3B7B.js"),"_messages:,message:,readAloudEnabled"],"arcgis-assistant-message-text":[()=>import("./LFQLCCJJ.js"),"content,parts:"],"arcgis-assistant-speech-input":[()=>import("./5MK44FNO.js"),"awaitingResponse,inputValue,language,mode;;clearDraftSession"],"arcgis-assistant-suggested-prompts":[()=>import("./SXM4NUT5.js"),"_messages:,label,prompts:"],"arcgis-assistant-user-message":[()=>import("./XV3DHHYJ.js"),"content,message:,user,userAvatarEnabled"]});a({resourcesUrl:import.meta.url});var t=new CSSStyleSheet;t.replaceSync("@layer{:not([hydrated]):is(arcgis-assistant,arcgis-assistant-agent,arcgis-assistant-data-exploration-agent,arcgis-assistant-help-agent,arcgis-assistant-knowledge-agent,arcgis-assistant-layer-styling-agent,arcgis-assistant-navigation-agent,arcgis-assistant-chat,arcgis-assistant-chat-entry,arcgis-assistant-interrupt,arcgis-assistant-message,arcgis-assistant-message-block,arcgis-assistant-message-feedback,arcgis-assistant-message-footer,arcgis-assistant-message-loading,arcgis-assistant-message-log,arcgis-assistant-message-read-aloud,arcgis-assistant-message-text,arcgis-assistant-speech-input,arcgis-assistant-suggested-prompts,arcgis-assistant-user-message){visibility:hidden}}");document.adoptedStyleSheets=[...document.adoptedStyleSheets,t];window.$arcgis||Object.defineProperty(window,"$arcgis",{configurable:!1,enumerable:!0,writable:!1,value:{}}),((a,r,p,j,i=(a.importMap??={}).imports??={})=>{"agent-utils/index,agent-utils/middlewares/middleware,agent-utils/middlewares/humanInTheLoop,agent-utils/middlewares/trace".split(",").map(e=>i[p+e+j]=i[p+e]=import.meta.resolve("./"+e+j));a.t=(c,...x)=>Promise.all(x.map(x=>x.then?x:(!a?.forceESM&&a?.import||(x=>import(x+".js").then(m=>m.default??m)))("@arcgis/core/"+x))).then(c);r.p=a.t(([m])=>{r.t=m.trackAccess;r.o=m.createObservable;r.c=m.createTrackingTarget;r.r=m.runTracked},"applications/Components/reactiveUtils")})($arcgis,e,"@arcgis/ai-components/",".js")
2
+ import{p as s,y as e}from"./COH3QXWG.js";import"./R74ZHFA6.js";import"./UZLQALHY.js";var a=s(e,{"arcgis-assistant":[()=>import("./VJRJ2HAM.js"),"_messages:,allowedAgentIds:,alwaysUseAgentId,assistantAvatarEnabled,awaitingResponse:,awaitingResponseStep:,commandProvider:,copyEnabled,description,entityProviders:,entryMessage,feedbackEnabled,heading,interrupt:,keepSuggestedPrompts,logEnabled,messages:,orchestrator:,readAloudEnabled,referenceElement,runtimeEventsEnabled,streamingDisabled,suggestedPrompts:,userAvatarEnabled,voiceInputEnabled;clearChatHistory,submitMessage;cancelInterrupt,register,submitInterrupt,unregister"],"arcgis-assistant-agent":[()=>import("./6YRLY5TX.js"),"agent:,context:,itemId,workflow:;getContext"],"arcgis-assistant-data-exploration-agent":[()=>import("./PGVLC374.js"),"referenceElement;;getContext"],"arcgis-assistant-help-agent":[()=>import("./BJNYJCS5.js"),"referenceElement;;getContext"],"arcgis-assistant-knowledge-agent":[()=>import("./23CPLCYW.js"),"context:,referenceElement,serviceUrl;getContext"],"arcgis-assistant-layer-styling-agent":[()=>import("./DEPD7PJL.js"),"referenceElement;;getContext"],"arcgis-assistant-navigation-agent":[()=>import("./H4N7VNL5.js"),"referenceElement;;getContext"],"arcgis-assistant-chat":[()=>import("./6ECRQVHY.js"),"interrupt:,loading,messages:"],"arcgis-assistant-chat-entry":[()=>import("./NR2O3AP2.js"),"_messages:,awaitingResponse,commandProvider:,disabled,entityProviders:,entryPlaceholder,inputValue,keyboardShortcutsDisabled,messages:,status,voiceInputEnabled;submitMessage"],"arcgis-assistant-interrupt":[()=>import("./CSTXLFCP.js"),"_messages:,message,options:,type"],"arcgis-assistant-interrupt-preview":[()=>import("./VYOIFJVE.js"),"interrupts:"],"arcgis-assistant-message":[()=>import("./KPJHQ424.js"),"_messages:,assistantAvatarEnabled,copyEnabled,feedbackEnabled,footerDisabled,logEnabled,message:,readAloudEnabled"],"arcgis-assistant-message-block":[()=>import("./5HBAJ57P.js"),"block:"],"arcgis-assistant-message-feedback":[()=>import("./KQGC2FCP.js"),"_messages:,feedbackEnabled,message:"],"arcgis-assistant-message-footer":[()=>import("./4WYNWR6R.js"),"_messages:,copyEnabled,feedbackEnabled,logEnabled,message:,readAloudEnabled"],"arcgis-assistant-message-loading":[()=>import("./K5FWDMTV.js"),"_messages:,assistantAvatarEnabled,interrupts:,loading,loadingMessage"],"arcgis-assistant-message-log":[()=>import("./F3CSORDI.js"),"log:,logEnabled,showLog"],"arcgis-assistant-message-read-aloud":[()=>import("./7ELUGB4X.js"),"_messages:,message:,readAloudEnabled"],"arcgis-assistant-message-text":[()=>import("./LFQLCCJJ.js"),"content,parts:"],"arcgis-assistant-speech-input":[()=>import("./5MK44FNO.js"),"awaitingResponse,inputValue,language,mode;;clearDraftSession"],"arcgis-assistant-suggested-prompts":[()=>import("./PQRE67OM.js"),"_messages:,label,prompts:"],"arcgis-assistant-user-message":[()=>import("./XV3DHHYJ.js"),"content,message:,user,userAvatarEnabled"]});a({resourcesUrl:import.meta.url});var t=new CSSStyleSheet;t.replaceSync("@layer{:not([hydrated]):is(arcgis-assistant,arcgis-assistant-agent,arcgis-assistant-data-exploration-agent,arcgis-assistant-help-agent,arcgis-assistant-knowledge-agent,arcgis-assistant-layer-styling-agent,arcgis-assistant-navigation-agent,arcgis-assistant-chat,arcgis-assistant-chat-entry,arcgis-assistant-interrupt,arcgis-assistant-message,arcgis-assistant-message-block,arcgis-assistant-message-feedback,arcgis-assistant-message-footer,arcgis-assistant-message-loading,arcgis-assistant-message-log,arcgis-assistant-message-read-aloud,arcgis-assistant-message-text,arcgis-assistant-speech-input,arcgis-assistant-suggested-prompts,arcgis-assistant-user-message){visibility:hidden}}");document.adoptedStyleSheets=[...document.adoptedStyleSheets,t];window.$arcgis||Object.defineProperty(window,"$arcgis",{configurable:!1,enumerable:!0,writable:!1,value:{}}),((a,r,p,j,i=(a.importMap??={}).imports??={})=>{"agent-utils/index,agent-utils/middlewares/middleware,agent-utils/middlewares/humanInTheLoop,agent-utils/middlewares/trace".split(",").map(e=>i[p+e+j]=i[p+e]=import.meta.resolve("./"+e+j));a.t=(c,...x)=>Promise.all(x.map(x=>x.then?x:(!a?.forceESM&&a?.import||(x=>import(x+".js").then(m=>m.default??m)))("@arcgis/core/"+x))).then(c);r.p=a.t(([m])=>{r.t=m.trackAccess;r.o=m.createObservable;r.c=m.createTrackingTarget;r.r=m.runTracked},"applications/Components/reactiveUtils")})($arcgis,e,"@arcgis/ai-components/",".js")
@@ -18,17 +18,18 @@ const a = (e, t) => t, c = (e, t) => ({
18
18
  return u[u.length - 1]?.trim() === s ? e : `${e}
19
19
 
20
20
  ${s}`;
21
- }, d = () => ({
21
+ }, i = () => ({
22
22
  userRequest: "",
23
+ inputParts: [],
23
24
  assignedTask: "",
24
25
  messages: [],
25
26
  priorSteps: [],
26
27
  sharedState: {},
27
28
  sharedResources: []
28
- }), i = () => ({
29
+ }), d = () => ({
29
30
  agentExecutionContext: r({
30
31
  reducer: c,
31
- default: d
32
+ default: i
32
33
  }),
33
34
  outputMessage: r({
34
35
  reducer: o,
@@ -47,11 +48,11 @@ ${s}`;
47
48
  sharedResourceAdditions: r({
48
49
  reducer: a
49
50
  })
50
- }), g = () => i();
51
+ }), g = () => d();
51
52
  export {
52
- i as a,
53
+ d as a,
53
54
  o as b,
54
- d as c,
55
+ i as c,
55
56
  g as d,
56
57
  c as m,
57
58
  a as r
@@ -2,9 +2,9 @@
2
2
  import M from "@arcgis/core/identity/IdentityManager.js";
3
3
  import _ from "@arcgis/core/portal/Portal.js";
4
4
  import { g as $, a as D } from "./aiFactory.js";
5
- import { isGraphInterrupt as F, StateGraph as L, START as W, END as q, MemorySaver as T } from "@langchain/langgraph/web";
5
+ import { isGraphInterrupt as F, StateGraph as L, START as q, END as W, MemorySaver as P } from "@langchain/langgraph/web";
6
6
  import { generateGuid as b } from "@arcgis/toolkit/string";
7
- import { g as A, D as j, b as H, W as P } from "./generateLayerDescriptions.js";
7
+ import { g as A, D as T, b as j, W as H } from "./generateLayerDescriptions.js";
8
8
  import { HumanMessage as U, AIMessage as O } from "@langchain/core/messages";
9
9
  import { s as p } from "./index.js";
10
10
  import { BaseCallbackHandler as G } from "@langchain/core/callbacks/base";
@@ -242,7 +242,7 @@ const B = async (n) => {
242
242
  assignedTask: n.agentExecutionContext.userRequest
243
243
  }
244
244
  };
245
- }, de = 3, ue = (n) => n.routing.mode === "direct" ? "assignDirectAgent" : "intentLLM", ge = (n) => n.routing.mode === "direct" || n.stepCount >= de || !n.requiresFollowUp ? "exit" : "intentLLM", le = () => new L(j).addNode("ingestInput", J).addNode("assignDirectAgent", ce).addNode("intentLLM", H).addNode("executeRegisteredAgent", oe).addNode("exit", X).addEdge(W, "ingestInput").addConditionalEdges("ingestInput", ue).addEdge("assignDirectAgent", "executeRegisteredAgent").addConditionalEdges("intentLLM", (e) => e.currentIntent === "none" || e.currentIntent === e.lastExecutedAgent ? "exit" : "executeRegisteredAgent").addConditionalEdges("executeRegisteredAgent", ge).addEdge("exit", q), he = (n, e) => {
245
+ }, de = 3, ue = (n) => n.routing.mode === "direct" ? "assignDirectAgent" : "intentLLM", ge = (n) => n.routing.mode === "direct" || n.stepCount >= de || !n.requiresFollowUp ? "exit" : "intentLLM", le = () => new L(T).addNode("ingestInput", J).addNode("assignDirectAgent", ce).addNode("intentLLM", j).addNode("executeRegisteredAgent", oe).addNode("exit", X).addEdge(q, "ingestInput").addConditionalEdges("ingestInput", ue).addEdge("assignDirectAgent", "executeRegisteredAgent").addConditionalEdges("intentLLM", (e) => e.currentIntent === "none" || e.currentIntent === e.lastExecutedAgent ? "exit" : "executeRegisteredAgent").addConditionalEdges("executeRegisteredAgent", ge).addEdge("exit", W), he = (n, e) => {
246
246
  const r = n.output?.usage_metadata ?? e.usage_metadata, s = n.output?.llmOutput?.tokenUsage, t = r?.input_tokens ?? s?.promptTokens, a = r?.output_tokens ?? s?.completionTokens, i = r?.total_tokens ?? s?.totalTokens;
247
247
  if (t === void 0 || a === void 0 || i === void 0)
248
248
  return;
@@ -468,7 +468,7 @@ function xe(n) {
468
468
  };
469
469
  }
470
470
  const Se = (n) => {
471
- const e = P.safeParse(n);
471
+ const e = H.safeParse(n);
472
472
  if (!e.success)
473
473
  throw new Error("Embeddings response validation failed. Regenerate embeddings.");
474
474
  return e.data;
@@ -578,10 +578,12 @@ class k {
578
578
  const s = this.createRequestAgentRegistry(r);
579
579
  if (!s.list().length)
580
580
  throw new Error("Orchestrator has no agents selected for this request.");
581
- if (++this.streamEpoch, !e.trim())
581
+ if (++this.streamEpoch, !e.trim() && !r.inputParts?.length)
582
582
  return;
583
+ if (!e.trim() && r.routing !== "direct")
584
+ throw new Error("Requests containing only structured input require direct agent routing.");
583
585
  const t = b();
584
- this.parentRunIds.clear(), this.activeRuntimeSpans.clear(), this.activeRunId = t, this.activeAbortController = new AbortController(), this.graph || (this.graph = le().compile({ checkpointer: new T() }));
586
+ this.parentRunIds.clear(), this.activeRuntimeSpans.clear(), this.activeRunId = t, this.activeAbortController = new AbortController(), this.graph || (this.graph = le().compile({ checkpointer: new P() }));
585
587
  const a = this.embeddingsWorker ? Ee({ worker: this.embeddingsWorker }) : void 0, i = this.embeddingsWorker ? xe({ worker: this.embeddingsWorker }) : void 0, o = /* @__PURE__ */ new Map(), d = r.routing === "direct" ? { mode: "direct", agentId: r.agentId } : { mode: "auto" }, c = {
586
588
  // eslint-disable-next-line @typescript-eslint/naming-convention
587
589
  thread_id: t,
@@ -605,6 +607,7 @@ class k {
605
607
  routing: d,
606
608
  agentExecutionContext: {
607
609
  userRequest: e,
610
+ inputParts: [...r.inputParts ?? []],
608
611
  messages: this.chatHistory,
609
612
  priorSteps: this.priorSteps,
610
613
  sharedState: this.sharedState,
@@ -2,7 +2,7 @@
2
2
  import type Collection from "@arcgis/core/core/Collection.js";
3
3
  import type { RuntimeSpanEvent } from "../../orchestrator/orchestrator/orchestratorEvents.js";
4
4
  import type { PublicLitElement as LitElement } from "@arcgis/lumina";
5
- import type { AssistantMessage, AssistantPromptSelectDetail, AssistantSlottableRequestDetail, ChatMessage, Interrupt } from "./types.js";
5
+ import type { AssistantCommandProvider, AssistantEntityProvider, AssistantMessage, AssistantSubmission, AssistantPromptSelectDetail, AssistantSlottableRequestDetail, ChatMessage, Interrupt, SubmitMessageOptions } from "./types.js";
6
6
  import type { T9nMeta } from "@arcgis/lumina/controllers";
7
7
  import type { ArcgisMap as ArcgisMap } from "@arcgis/map-components/components/arcgis-map";
8
8
 
@@ -88,6 +88,8 @@ export abstract class ArcgisAssistant extends LitElement {
88
88
  /** @internal */
89
89
  protected _messages: {
90
90
  assistantLabel: string;
91
+ multipleCommands: string;
92
+ partsOnlyRequiresAgent: string;
91
93
  stopButtonLabel: string;
92
94
  askButtonLabel: string;
93
95
  stoppedByUserLabel: string;
@@ -106,6 +108,8 @@ export abstract class ArcgisAssistant extends LitElement {
106
108
  userPrivilegesNotSufficientMessage: string;
107
109
  } & T9nMeta<{
108
110
  assistantLabel: string;
111
+ multipleCommands: string;
112
+ partsOnlyRequiresAgent: string;
109
113
  stopButtonLabel: string;
110
114
  askButtonLabel: string;
111
115
  stoppedByUserLabel: string;
@@ -189,6 +193,14 @@ export abstract class ArcgisAssistant extends LitElement {
189
193
  * @since 5.1
190
194
  */
191
195
  get awaitingResponseStep(): string;
196
+ /**
197
+ * Provider used by the built-in chat entry to suggest slash commands.
198
+ * Selected commands are included as structured input and removed from the prompt sent to the agent.
199
+ * A command with an `agentId` routes that request directly to the specified agent.
200
+ *
201
+ * @internal
202
+ */
203
+ accessor commandProvider: AssistantCommandProvider | undefined;
192
204
  /**
193
205
  * When `true`, enables the copy action that, when clicked, copies the content of the message to the clipboard. This can be helpful for users to easily copy and share
194
206
  * information provided by the assistant, such as a summary of findings, a set of instructions, or any other relevant details. Enabling this property can enhance the user experience by providing a convenient way for users to capture and utilize the information generated by the assistant.
@@ -222,6 +234,13 @@ export abstract class ArcgisAssistant extends LitElement {
222
234
  * ```
223
235
  */
224
236
  accessor description: string | undefined;
237
+ /**
238
+ * Providers used by the built-in chat entry to suggest structured entities.
239
+ * Selected entities remain in the prompt and do not affect agent routing.
240
+ *
241
+ * @internal
242
+ */
243
+ accessor entityProviders: readonly AssistantEntityProvider[] | undefined;
225
244
  /**
226
245
  * The instructions to display when the assistant is first loaded. This is intended to be a welcome or entry message that
227
246
  * provides guidance to users on how to interact with the assistant. Once the user submits their first message,
@@ -431,6 +450,7 @@ export abstract class ArcgisAssistant extends LitElement {
431
450
  * complex interactions and integrations with other components or services.
432
451
  *
433
452
  * @param message - The message to submit to the assistant. This should be a string containing the user's input or question they want to ask the assistant.
453
+ * @param options
434
454
  * @since 5.0
435
455
  * @example
436
456
  * ```js
@@ -438,7 +458,7 @@ export abstract class ArcgisAssistant extends LitElement {
438
458
  * assistant.submitMessage("What is the population of New York City?");
439
459
  * ```
440
460
  */
441
- submitMessage(message: string): Promise<void>;
461
+ submitMessage(message: string, options?: SubmitMessageOptions): Promise<void>;
442
462
  /**
443
463
  * Emitted when the user cancels a message. This is typically invoked when a user submits a question while a previous question is still being processed.
444
464
  * This allows app developers to capture messages cancelled by the user and respond to them in custom ways, such as by providing additional information,
@@ -618,7 +638,7 @@ export abstract class ArcgisAssistant extends LitElement {
618
638
  * });
619
639
  * ```
620
640
  */
621
- readonly arcgisSubmit: import("@arcgis/lumina").TargetedEvent<this, string>;
641
+ readonly arcgisSubmit: import("@arcgis/lumina").TargetedEvent<this, AssistantSubmission | string>;
622
642
  readonly "@eventTypes": {
623
643
  arcgisCancel: ArcgisAssistant["arcgisCancel"]["detail"];
624
644
  arcgisError: ArcgisAssistant["arcgisError"]["detail"];