@arcgis/ai-components 5.2.0-next.12 → 5.2.0-next.14

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 (75) hide show
  1. package/dist/agent-utils/LLMAgent.js +1 -0
  2. package/dist/cdn/{5CV7R5IS.js → 22IT5TDB.js} +2 -2
  3. package/dist/cdn/{EBISDZ5H.js → 4UDYY3HL.js} +1 -1
  4. package/dist/cdn/7PANDHIL.js +16 -0
  5. package/dist/cdn/ADYIXCSG.js +2 -0
  6. package/dist/cdn/CAECQD75.js +2 -0
  7. package/dist/cdn/{34SG44C3.js → CE6VDP2D.js} +1 -1
  8. package/dist/cdn/CI3QSFPS.js +2 -0
  9. package/dist/cdn/DEAYZ3MK.js +2 -0
  10. package/dist/cdn/{YLN2BZ5J.js → E2HENO3T.js} +1 -1
  11. package/dist/cdn/FWU6DFIB.js +2 -0
  12. package/dist/cdn/GBYLKQIL.js +2 -0
  13. package/dist/cdn/GPYYAQVI.js +2 -0
  14. package/dist/cdn/{ERL2CB2Y.js → I2Y67HBL.js} +5 -5
  15. package/dist/cdn/JG2BIENI.js +3 -0
  16. package/dist/cdn/JN744CAW.js +2 -0
  17. package/dist/cdn/K475UT3E.js +2 -0
  18. package/dist/cdn/{JLKGS6Y5.js → L4XF4H6V.js} +1 -1
  19. package/dist/cdn/M3SWPT3M.js +2 -0
  20. package/dist/cdn/MAV3DW27.js +4 -0
  21. package/dist/cdn/PB2ODJC7.js +2 -0
  22. package/dist/cdn/{QCSN44H4.js → QSA4T3BU.js} +1 -1
  23. package/dist/cdn/{R56X6ZKR.js → QYR3NSF2.js} +3 -3
  24. package/dist/cdn/RMLXVQZ5.js +2 -0
  25. package/dist/cdn/{T43LEBBE.js → S75VFYR4.js} +18 -18
  26. package/dist/cdn/SBHLUL3Q.js +2 -0
  27. package/dist/cdn/{X2ZDYHCG.js → TNMXWUXU.js} +9 -4
  28. package/dist/cdn/WH6QQK6N.js +2 -0
  29. package/dist/cdn/XBW4MWQR.js +2 -0
  30. package/dist/cdn/{Z2G7MP5L.js → XU6NCSE2.js} +1 -1
  31. package/dist/cdn/Z7UWJ4AI.js +3 -0
  32. package/dist/cdn/ZOSUDIJH.js +2 -0
  33. package/dist/cdn/ZPLFFLPF.js +2 -0
  34. package/dist/cdn/agent-utils/index.js +1 -1
  35. package/dist/cdn/index.js +1 -1
  36. package/dist/chunks/adapter.js +170 -169
  37. package/dist/chunks/arcgisKnowledgeGraph.js +8 -7
  38. package/dist/chunks/dataExplorationGraph.js +88 -76
  39. package/dist/chunks/data_explore_query_prompt.js +9 -4
  40. package/dist/chunks/generateLayerDescriptions.js +161 -159
  41. package/dist/chunks/helpGraph.js +3 -2
  42. package/dist/chunks/layerStylingGraph.js +1 -0
  43. package/dist/chunks/navigationGraph.js +3 -2
  44. package/dist/chunks/orchestrator.js +108 -107
  45. package/dist/chunks/toolCallResponse.js +10 -9
  46. package/dist/components/arcgis-assistant/customElement.js +136 -124
  47. package/dist/components/arcgis-assistant-data-exploration-agent/customElement.js +3 -2
  48. package/dist/components/arcgis-assistant-help-agent/customElement.js +1 -0
  49. package/dist/components/arcgis-assistant-knowledge-agent/customElement.js +4 -3
  50. package/dist/components/arcgis-assistant-layer-styling-agent/customElement.js +1 -0
  51. package/dist/components/arcgis-assistant-navigation-agent/customElement.js +1 -0
  52. package/dist/docs/api.json +1 -1
  53. package/dist/docs/docs.json +1 -1
  54. package/dist/docs/web-types.json +1 -1
  55. package/package.json +5 -5
  56. package/dist/cdn/24QNMEFG.js +0 -2
  57. package/dist/cdn/3NBDVZ2I.js +0 -2
  58. package/dist/cdn/53NTYC4I.js +0 -2
  59. package/dist/cdn/AZGGTNA3.js +0 -2
  60. package/dist/cdn/B7WJFBOZ.js +0 -2
  61. package/dist/cdn/DZ2QWNUA.js +0 -3
  62. package/dist/cdn/F6QHMKF5.js +0 -2
  63. package/dist/cdn/H2CHHGGH.js +0 -2
  64. package/dist/cdn/HWKDNS4K.js +0 -4
  65. package/dist/cdn/IMQ4TVHF.js +0 -16
  66. package/dist/cdn/IRZDTYO2.js +0 -2
  67. package/dist/cdn/KHXUWZHB.js +0 -2
  68. package/dist/cdn/LIFK3QSD.js +0 -2
  69. package/dist/cdn/O3EN27N5.js +0 -2
  70. package/dist/cdn/PBO6FZN6.js +0 -2
  71. package/dist/cdn/Q3ZW4FYA.js +0 -3
  72. package/dist/cdn/UPEEHMSY.js +0 -2
  73. package/dist/cdn/WAIFKDR3.js +0 -2
  74. package/dist/cdn/XON27U6U.js +0 -2
  75. package/dist/cdn/YUKR4AZW.js +0 -2
@@ -1,56 +1,58 @@
1
1
  /* COPYRIGHT Esri - https://js.arcgis.com/5.2/LICENSE.txt */
2
- import { c as $ } from "../../chunks/runtime.js";
3
- import { css as C, html as l } from "lit";
4
- import I from "@arcgis/core/core/Collection.js";
5
- import { whenOnce as P, watch as A, when as x } from "@arcgis/core/core/reactiveUtils.js";
6
- import L from "@arcgis/core/portal/Portal.js";
7
- import { LitElement as R, createEvent as g, nothing as k } from "@arcgis/lumina";
8
- import { rethrowError as O } from "@arcgis/toolkit/log";
2
+ import { c as I } from "../../chunks/runtime.js";
3
+ import { css as C, html as c } from "lit";
4
+ import P from "@arcgis/core/core/Collection.js";
5
+ import { whenOnce as A, watch as L, when as x } from "@arcgis/core/core/reactiveUtils.js";
6
+ import R from "@arcgis/core/portal/Portal.js";
7
+ import { LitElement as M, createEvent as p, nothing as k } from "@arcgis/lumina";
8
+ import * as O from "@arcgis/toolkit/log";
9
+ import { rethrowError as D } from "@arcgis/toolkit/log";
9
10
  import { createRef as _, ref as v } from "lit/directives/ref.js";
10
- import { u as M } from "../../chunks/useT9n.js";
11
- import { O as D } from "../../chunks/orchestrator.js";
11
+ import { u as T } from "../../chunks/useT9n.js";
12
+ import { O as N } from "../../chunks/orchestrator.js";
12
13
  import "@langchain/core/callbacks/dispatch/web";
13
14
  import "@langchain/core/prompts";
14
15
  import "@langchain/openai";
15
- import T from "@arcgis/core/identity/IdentityManager.js";
16
+ import z from "@arcgis/core/identity/IdentityManager.js";
17
+ import "@arcgis/toolkit/string";
16
18
  import "@arcgis/core/config.js";
17
19
  import "@langchain/core/messages";
18
20
  import "@arcgis/core/layers/FeatureLayer.js";
19
21
  import "../../chunks/generateLayerDescriptions.js";
20
22
  import "@langchain/langgraph/web";
21
- import N from "@arcgis/core/core/Accessor.js";
22
- import { property as b, subclass as B } from "@arcgis/core/core/accessorSupport/decorators.js";
23
- import { g as V } from "../../chunks/utils3.js";
23
+ import B from "@arcgis/core/core/Accessor.js";
24
+ import { property as b, subclass as V } from "@arcgis/core/core/accessorSupport/decorators.js";
25
+ import { g as j } from "../../chunks/utils3.js";
24
26
  import { g as w } from "../../chunks/slottableRequestUtils.js";
25
- const z = C`:host{display:block;width:var(--arcgis-internal-panel-width, 100%);height:var(--arcgis-internal-expand-max-height, 100%);--calcite-panel-content-bottom-space: 0}.footer-container{display:flex;flex-direction:column;flex:1 1 0;gap:var(--calcite-spacing-md)}.content-container{display:flex;flex-direction:column;flex:1 1 0;min-height:0;position:relative;overflow:auto}.suggested-prompts-container{display:flex;justify-content:center;width:100%;background:var(--calcite-panel-background-color, var(--calcite-color-background))}.suggested-prompts{display:block;padding:var(--calcite-spacing-md);max-width:100%;box-sizing:border-box}.error-notice{padding:var(--calcite-spacing-sm)}.interrupt-waiting-message{font-style:italic;color:var(--calcite-color-text-2)}`;
26
- var H = Object.defineProperty, j = Object.getOwnPropertyDescriptor, m = (c, t, e, i) => {
27
- for (var r = i > 1 ? void 0 : i ? j(t, e) : t, n = c.length - 1, s; n >= 0; n--)
28
- (s = c[n]) && (r = (i ? s(t, e, r) : s(r)) || r);
29
- return i && r && H(t, e, r), r;
27
+ const q = C`:host{display:block;width:var(--arcgis-internal-panel-width, 100%);height:var(--arcgis-internal-expand-max-height, 100%);--calcite-panel-content-bottom-space: 0}.footer-container{display:flex;flex-direction:column;flex:1 1 0;gap:var(--calcite-spacing-md)}.content-container{display:flex;flex-direction:column;flex:1 1 0;min-height:0;position:relative;overflow:auto}.suggested-prompts-container{display:flex;justify-content:center;width:100%;background:var(--calcite-panel-background-color, var(--calcite-color-background))}.suggested-prompts{display:block;padding:var(--calcite-spacing-md);max-width:100%;box-sizing:border-box}.error-notice{padding:var(--calcite-spacing-sm)}.interrupt-waiting-message{font-style:italic;color:var(--calcite-color-text-2)}`;
28
+ var H = Object.defineProperty, U = Object.getOwnPropertyDescriptor, m = (o, t, e, i) => {
29
+ for (var s = i > 1 ? void 0 : i ? U(t, e) : t, l = o.length - 1, r; l >= 0; l--)
30
+ (r = o[l]) && (s = (i ? r(t, e, s) : r(s)) || s);
31
+ return i && s && H(t, e, s), s;
30
32
  };
31
- const q = async (c) => await new Promise((t) => setTimeout(t, c));
32
- async function* F(c, {
33
+ const F = async (o) => await new Promise((t) => setTimeout(t, o)), E = (o) => !o || typeof o != "object" ? !1 : o.name === "AbortError";
34
+ async function* G(o, {
33
35
  chunkSize: t = 5,
34
36
  // chars per "token"
35
37
  delay: e = 20
36
38
  // ms between chunks
37
39
  } = {}) {
38
40
  let i = 0;
39
- for (; i < c.length; )
40
- yield c.slice(i, i + t), i += t, await q(e);
41
+ for (; i < o.length; )
42
+ yield o.slice(i, i + t), i += t, await F(e);
41
43
  }
42
- async function* E(c, t, e, i) {
43
- for await (const r of F(c)) {
44
+ async function* S(o, t, e, i) {
45
+ for await (const s of G(o)) {
44
46
  if (i?.aborted) {
45
47
  yield { type: "cancelled", log: e, runId: t };
46
48
  return;
47
49
  }
48
- yield { type: "block-data", blockType: "text", data: { content: r }, runId: t };
50
+ yield { type: "block-data", blockType: "text", data: { content: s }, runId: t };
49
51
  }
50
52
  }
51
- let d = class extends N {
52
- constructor(c) {
53
- super(c), this.view = null, this.loading = !1, this.processing = !1, this.processingStep = "";
53
+ let d = class extends B {
54
+ constructor(o) {
55
+ super(o), this.view = null, this.loading = !1, this.processing = !1, this.processingStep = "";
54
56
  }
55
57
  async load() {
56
58
  this._set("loading", !0);
@@ -64,14 +66,14 @@ let d = class extends N {
64
66
  this.orchestrator?.dispose(), super.destroy();
65
67
  }
66
68
  async _initialize() {
67
- this.removeHandles(), await Promise.all([this.portal.load(), this.view?.when()]), this.view && await P(() => !this.view.updating), this._set(
69
+ this.removeHandles(), await Promise.all([this.portal.load(), this.view?.when()]), this.view && await A(() => !this.view.updating), this._set(
68
70
  "orchestrator",
69
- await D.init({
71
+ await N.init({
70
72
  agents: [...this.agents],
71
73
  view: this.view ?? void 0
72
74
  })
73
75
  ), this.addHandles([
74
- A(
76
+ L(
75
77
  () => [this.view, this.agents],
76
78
  () => {
77
79
  this._initialize();
@@ -82,30 +84,29 @@ let d = class extends N {
82
84
  clearChatHistory() {
83
85
  this.orchestrator?.newConversation();
84
86
  }
85
- async *ask(c, t) {
87
+ async *ask(o, t) {
86
88
  if (!this.orchestrator)
87
89
  throw new Error("Orchestrator not initialized yet.");
88
90
  this._set("processing", !0), this._set("processingStep", "");
89
91
  const e = [];
90
- let i;
92
+ let i, s = "pending";
91
93
  try {
92
- const r = this.orchestrator.ask(c);
93
- for await (const n of r) {
94
- const s = n.runId;
95
- switch (n.type) {
94
+ const l = this.orchestrator.ask(o);
95
+ for await (const r of l)
96
+ switch (s = r.runId, r.type) {
96
97
  case "trace": {
97
- this._set("processingStep", n.data.text), e.push(n.data.text);
98
+ this._set("processingStep", r.data.text), e.push(r.data.text);
98
99
  break;
99
100
  }
100
101
  case "completed": {
101
102
  this._set("processing", !1), this._set("processingStep", "");
102
- const a = n.result, o = !!a.content.length, h = !!i?.length;
103
- if (!o && !h) {
103
+ const a = r.result, n = !!a.content.length, h = !!i?.length;
104
+ if (!n && !h) {
104
105
  yield { type: "completed", error: "No response received.", log: e, runId: s };
105
106
  return;
106
107
  }
107
- const p = a.content;
108
- if (yield { type: "block-start", blockType: "text", runId: s }, yield* E(p, s, e, t), yield { type: "block-end", blockType: "text", runId: s }, h)
108
+ const g = a.content;
109
+ if (yield { type: "block-start", blockType: "text", runId: s }, yield* S(g, s, e, t), yield { type: "block-end", blockType: "text", runId: s }, h)
109
110
  for (const f of i) {
110
111
  if (t?.aborted) {
111
112
  yield { type: "cancelled", log: e, runId: s };
@@ -113,33 +114,33 @@ let d = class extends N {
113
114
  }
114
115
  const { type: u, data: y } = f;
115
116
  if (yield { type: "block-start", blockType: u, runId: s }, u === "text") {
116
- const S = typeof y?.content == "string" ? y.content : "";
117
- yield* E(S, s, e, t);
117
+ const $ = typeof y?.content == "string" ? y.content : "";
118
+ yield* S($, s, e, t);
118
119
  } else
119
120
  yield { type: "block-data", blockType: u, data: y, runId: s };
120
121
  yield { type: "block-end", blockType: u, runId: s };
121
122
  }
122
- yield { type: "completed", response: p, blocks: i, log: e, runId: s };
123
+ yield { type: "completed", response: g, blocks: i, log: e, runId: s };
123
124
  return;
124
125
  }
125
126
  case "ux-suggestion": {
126
- const a = n.suggestion;
127
+ const a = r.suggestion;
127
128
  i = i ? [...i, a] : [a];
128
129
  break;
129
130
  }
130
131
  case "interrupt": {
131
- const { kind: a, message: o, metadata: h } = n.interrupt, p = Array.isArray(h) ? h.filter((u) => typeof u == "string") : [], f = (() => {
132
+ const { kind: a, message: n, metadata: h } = r.interrupt, g = Array.isArray(h) ? h.filter((u) => typeof u == "string") : [], f = (() => {
132
133
  switch (a) {
133
134
  case "booleanChoice":
134
- return { type: "boolean-choice", message: o, options: p };
135
+ return { type: "boolean-choice", message: n, options: g };
135
136
  case "singleSelection":
136
- return { type: "single-select", message: o, options: p };
137
+ return { type: "single-select", message: n, options: g };
137
138
  case "multipleSelection":
138
- return { type: "multi-select", message: o, options: p };
139
+ return { type: "multi-select", message: n, options: g };
139
140
  case "textInput":
140
- return { type: "text-input", message: o };
141
+ return { type: "text-input", message: n };
141
142
  default:
142
- return { type: a, message: o, options: p };
143
+ return { type: a, message: n, options: g };
143
144
  }
144
145
  })();
145
146
  this._set("processingStep", "Waiting for user input..."), yield { type: "interrupt", payload: f, runId: s };
@@ -150,17 +151,24 @@ let d = class extends N {
150
151
  return;
151
152
  }
152
153
  case "error": {
153
- yield { type: "completed", error: n.error.message, log: e, runId: s };
154
+ if (t?.aborted || E(r.error)) {
155
+ yield { type: "cancelled", log: e, runId: s };
156
+ return;
157
+ }
158
+ yield { type: "completed", error: r.error.message, log: e, runId: s };
154
159
  return;
155
160
  }
156
161
  default: {
157
- console.warn("Unknown event type:", n);
162
+ console.warn("Unknown event type:", r);
158
163
  break;
159
164
  }
160
165
  }
166
+ } catch (l) {
167
+ if (t?.aborted || E(l)) {
168
+ yield { type: "cancelled", log: e, runId: s };
169
+ return;
161
170
  }
162
- } catch (r) {
163
- console.warn("Error during message processing:", r), yield { type: "completed", error: "An error occurred during message processing.", log: e, runId: "error" };
171
+ console.warn("Error during message processing:", l), yield { type: "completed", error: "An error occurred during message processing.", log: e, runId: "error" };
164
172
  return;
165
173
  } finally {
166
174
  this._set("processing", !1);
@@ -192,12 +200,12 @@ m([
192
200
  b({ readOnly: !0 })
193
201
  ], d.prototype, "processingStep", 2);
194
202
  d = m([
195
- B("OrchestratorController")
203
+ V("OrchestratorController")
196
204
  ], d);
197
- const G = "Embeddings resource 'embeddings-v01.json' not found in the webmap portal item.", U = "Embeddings not found for this web map.", W = "https://developers.arcgis.com/javascript/latest/agentic-apps/ai-webmap-setup/#embeddings";
198
- class Y extends R {
205
+ const W = "Embeddings resource 'embeddings-v01.json' not found in the webmap portal item.", Y = "Embeddings not found for this web map.", J = "https://developers.arcgis.com/javascript/latest/agentic-apps/ai-webmap-setup/#embeddings";
206
+ class K extends M {
199
207
  constructor() {
200
- super(...arguments), this._messages = M({ blocking: !0 }), this.#t = _(), this.#n = _(), this.#s = _(), this.#e = null, this.#o = /* @__PURE__ */ new Map(), this.#i = L.getDefault(), this.#r = (t) => {
208
+ super(...arguments), this._messages = T({ blocking: !0 }), this.#t = _(), this.#n = _(), this.#s = _(), this.#e = null, this.#o = /* @__PURE__ */ new Map(), this.#r = R.getDefault(), this.#i = (t) => {
201
209
  t.stopPropagation(), this.cancelInterrupt();
202
210
  }, this.#a = (t) => {
203
211
  t.stopPropagation();
@@ -217,49 +225,52 @@ class Y extends R {
217
225
  t.stopPropagation();
218
226
  const e = t.detail;
219
227
  this.arcgisFeedback.emit(e);
220
- }, this.#p = (t) => {
228
+ }, this.#g = (t) => {
221
229
  t.stopPropagation();
222
230
  const e = t.detail;
223
231
  this._inputValue = e.prompt, this.arcgisPromptSelect.emit(e);
224
- }, this.#g = (t) => {
232
+ }, this.#p = (t) => {
225
233
  this.arcgisSlottableRequest.emit(t.detail);
226
- }, this._orchestratorController = null, this._interrupt = null, this._interruptDetails = [], this._error = null, this._inputValue = "", this._isAnswering = !1, this._canceling = !1, this.messages = new I([]), this.referenceElement = null, this.suggestedPrompts = [], this.feedbackEnabled = !1, this.keepSuggestedPrompts = !1, this.logEnabled = !1, this.copyEnabled = !1, this.voiceInputEnabled = !1, this.readAloudEnabled = !1, this.assistantAvatarEnabled = !1, this.arcgisCancel = g(), this.arcgisError = g(), this.arcgisFeedback = g(), this.arcgisInterrupt = g(), this.arcgisInterruptCancel = g(), this.arcgisInterruptSubmit = g(), this.arcgisPromptSelect = g(), this.arcgisReady = g(), this.arcgisSubmit = g(), this.arcgisSlottableRequest = g({ bubbles: !1, composed: !1 }), this.arcgisResponse = g();
234
+ }, this._orchestratorController = null, this._interrupt = null, this._interruptDetails = [], this._error = null, this._inputValue = "", this._isAnswering = !1, this._canceling = !1, this.messages = new P([]), this.referenceElement = null, this.suggestedPrompts = [], this.feedbackEnabled = !1, this.keepSuggestedPrompts = !1, this.logEnabled = !1, this.copyEnabled = !1, this.voiceInputEnabled = !1, this.readAloudEnabled = !1, this.assistantAvatarEnabled = !1, this.arcgisCancel = p(), this.arcgisError = p(), this.arcgisFeedback = p(), this.arcgisInterrupt = p(), this.arcgisInterruptCancel = p(), this.arcgisInterruptSubmit = p(), this.arcgisPromptSelect = p(), this.arcgisReady = p(), this.arcgisSubmit = p(), this.arcgisSlottableRequest = p({ bubbles: !1, composed: !1 }), this.arcgisResponse = p();
227
235
  }
228
236
  static {
229
- this.properties = { _orchestratorController: 16, _interrupt: 16, _interruptDetails: 16, _error: 16, _inputValue: 16, _isAnswering: 16, _canceling: 16, _user: 16, awaitingResponse: 32, awaitingResponseStep: 32, interrupt: 32, messages: 0, orchestrator: 32, entryMessage: 1, heading: 1, description: 1, referenceElement: 1, suggestedPrompts: 0, feedbackEnabled: 5, keepSuggestedPrompts: 5, logEnabled: 5, copyEnabled: 5, voiceInputEnabled: 5, readAloudEnabled: 5, assistantAvatarEnabled: 5 };
237
+ this.properties = { _orchestratorController: 16, _interrupt: 16, _interruptDetails: 16, _error: 16, _inputValue: 16, _isAnswering: 16, _signedInUserId: 16, _canceling: 16, _isSignedIn: 16, _user: 16, awaitingResponse: 32, awaitingResponseStep: 32, interrupt: 32, messages: 0, orchestrator: 32, entryMessage: 1, heading: 1, description: 1, referenceElement: 1, suggestedPrompts: 0, feedbackEnabled: 5, keepSuggestedPrompts: 5, logEnabled: 5, copyEnabled: 5, voiceInputEnabled: 5, readAloudEnabled: 5, assistantAvatarEnabled: 5 };
230
238
  }
231
239
  static {
232
- this.styles = z;
240
+ this.styles = q;
233
241
  }
234
242
  #t;
235
243
  #n;
236
244
  #s;
237
245
  #e;
238
246
  #o;
239
- #i;
240
247
  #r;
248
+ #i;
241
249
  #a;
242
250
  #l;
243
251
  #c;
244
252
  #h;
245
- #p;
246
253
  #g;
254
+ #p;
247
255
  async #d() {
248
256
  try {
249
- const t = V(this.el, this.referenceElement);
257
+ const t = j(this.el, this.referenceElement);
250
258
  await t?.componentOnReady();
251
259
  const e = [...this.#o.values()];
252
- return e.length ? (this._orchestratorController = new d({
260
+ return e.length ? (this._orchestratorController?.destroy(), this._orchestratorController = new d({
253
261
  agents: e,
254
- portal: this.#i,
262
+ portal: this.#r,
255
263
  view: t?.view
256
264
  }), await this._orchestratorController.load(), !0) : (this._error = "No agents found.", !1);
257
265
  } catch (t) {
258
- return this._error = t?.message ?? "Error initializing orchestrator.", O(this)(t), !1;
266
+ return this._error = t?.message ?? "Error initializing orchestrator.", D(this)(t), !1;
259
267
  }
260
268
  }
269
+ get _isSignedIn() {
270
+ return !!this.#r?.user || !!this._signedInUserId;
271
+ }
261
272
  get _user() {
262
- return this.#i?.user?.fullName || this.#i?.user?.username;
273
+ return this.#r?.user?.fullName || this.#r?.user?.username;
263
274
  }
264
275
  get awaitingResponse() {
265
276
  return this._orchestratorController?.processing ?? !1;
@@ -293,81 +304,81 @@ class Y extends R {
293
304
  return;
294
305
  this.#e = new AbortController();
295
306
  const i = this._orchestratorController.ask(e, this.#e?.signal);
296
- for await (const r of i) {
297
- const n = r.runId, s = this.messages.at(-1);
298
- switch (r.type) {
307
+ for await (const s of i) {
308
+ const l = s.runId, r = this.messages.at(-1);
309
+ switch (s.type) {
299
310
  case "block-start": {
300
311
  this._isAnswering = !0;
301
- const a = { type: r.blockType, isPending: !0 };
302
- if (s?.role === "assistant" && s.id === n) {
303
- const o = [...s.blocks ?? [], a];
304
- this.messages.splice(-1, 1, { ...s, blocks: o });
312
+ const a = { type: s.blockType, isPending: !0 };
313
+ if (r?.role === "assistant" && r.id === l) {
314
+ const n = [...r.blocks ?? [], a];
315
+ this.messages.splice(-1, 1, { ...r, blocks: n });
305
316
  } else
306
317
  this.messages.push({
307
318
  role: "assistant",
308
319
  blocks: [a],
309
- id: n,
320
+ id: l,
310
321
  isStreaming: !0,
311
322
  interrupts: this._interruptDetails
312
323
  }), this._interruptDetails = [];
313
324
  break;
314
325
  }
315
326
  case "block-data": {
316
- if (s?.role !== "assistant" || s?.id !== n)
327
+ if (r?.role !== "assistant" || r?.id !== l)
317
328
  break;
318
- const a = [...s.blocks ?? []], o = a[a.length - 1], { blockType: h, data: p } = r;
319
- if (o?.type !== h || !o.isPending)
329
+ const a = [...r.blocks ?? []], n = a[a.length - 1], { blockType: h, data: g } = s;
330
+ if (n?.type !== h || !n.isPending)
320
331
  break;
321
332
  if (h === "text") {
322
- const f = typeof o.data?.content == "string" ? o.data.content : "", u = typeof p?.content == "string" ? p.content : "";
323
- a[a.length - 1] = { ...o, data: { ...o.data, content: f + u } };
333
+ const f = typeof n.data?.content == "string" ? n.data.content : "", u = typeof g?.content == "string" ? g.content : "";
334
+ a[a.length - 1] = { ...n, data: { ...n.data, content: f + u } };
324
335
  } else
325
- a[a.length - 1] = { ...o, data: { ...o.data, ...p ?? {} } };
326
- this.messages.splice(-1, 1, { ...s, blocks: a });
336
+ a[a.length - 1] = { ...n, data: { ...n.data, ...g ?? {} } };
337
+ this.messages.splice(-1, 1, { ...r, blocks: a });
327
338
  break;
328
339
  }
329
340
  case "block-end": {
330
- if (s?.role !== "assistant" || s?.id !== n)
341
+ if (r?.role !== "assistant" || r?.id !== l)
331
342
  break;
332
- const a = [...s.blocks ?? []], o = a[a.length - 1];
333
- if (o?.type !== r.blockType || !o.isPending)
343
+ const a = [...r.blocks ?? []], n = a[a.length - 1];
344
+ if (n?.type !== s.blockType || !n.isPending)
334
345
  break;
335
- const h = o;
336
- a[a.length - 1] = { ...h, data: { ...h.data }, isPending: !1 }, this.messages.splice(-1, 1, { ...s, blocks: a });
346
+ const h = n;
347
+ a[a.length - 1] = { ...h, data: { ...h.data }, isPending: !1 }, this.messages.splice(-1, 1, { ...r, blocks: a });
337
348
  break;
338
349
  }
339
350
  case "completed":
340
- r.error ? (this.messages.push({
351
+ s.error ? (this.messages.push({
341
352
  role: "assistant",
342
- log: r.log,
343
- error: r.error,
344
- id: n,
353
+ log: s.log,
354
+ error: s.error,
355
+ id: l,
345
356
  interrupts: this._interruptDetails
346
- }), this._interruptDetails = []) : s?.role === "assistant" && s.id === n && this.messages.splice(-1, 1, {
347
- ...s,
348
- content: r.response,
349
- blocks: s.blocks?.map((a) => ({ ...a, isPending: !1 })) ?? [],
357
+ }), this._interruptDetails = []) : r?.role === "assistant" && r.id === l && this.messages.splice(-1, 1, {
358
+ ...r,
359
+ content: s.response,
360
+ blocks: r.blocks?.map((a) => ({ ...a, isPending: !1 })) ?? [],
350
361
  isStreaming: !1,
351
- log: r.log
362
+ log: s.log
352
363
  }), this._isAnswering = !1, this.#e = null, this._canceling = !1;
353
364
  break;
354
365
  case "interrupt":
355
- this._interrupt = { ...r.payload, id: n }, this.arcgisInterrupt.emit(this._interrupt);
366
+ this._interrupt = { ...s.payload, id: l }, this.arcgisInterrupt.emit(this._interrupt);
356
367
  break;
357
368
  case "cancelled":
358
- s?.role === "assistant" && s.id === n ? this.messages.splice(-1, 1, {
359
- ...s,
360
- blocks: s.blocks?.filter((a) => a.type === "text" || !a.isPending) ?? [],
369
+ r?.role === "assistant" && r.id === l ? this.messages.splice(-1, 1, {
370
+ ...r,
371
+ blocks: r.blocks?.filter((a) => a.type === "text" || !a.isPending) ?? [],
361
372
  isStreaming: !1,
362
- log: r.log,
373
+ log: s.log,
363
374
  error: "(Stopped by user)"
364
375
  // TODO: use strings from t9n
365
376
  }) : (this.messages.push({
366
377
  role: "assistant",
367
- log: r.log,
378
+ log: s.log,
368
379
  error: "(Stopped by user)",
369
380
  // TODO: use strings from t9n
370
- id: n,
381
+ id: l,
371
382
  interrupts: this._interruptDetails
372
383
  }), this._interruptDetails = []), this._isAnswering = !1, this.#e = null, this._canceling = !1;
373
384
  break;
@@ -382,49 +393,50 @@ class Y extends R {
382
393
  }
383
394
  loaded() {
384
395
  this.manager.onLifecycle(() => {
385
- this.#t.value?.addEventListener("arcgisPromptSelect", this.#p), this.#t.value?.addEventListener("arcgisSubmit", this.#l), this.#t.value?.addEventListener("arcgisCancel", this.#c), this.#t.value?.addEventListener("arcgisFeedback", this.#h);
396
+ this.#t.value?.addEventListener("arcgisPromptSelect", this.#g), this.#t.value?.addEventListener("arcgisSubmit", this.#l), this.#t.value?.addEventListener("arcgisCancel", this.#c), this.#t.value?.addEventListener("arcgisFeedback", this.#h);
386
397
  const t = x(() => !!this._interrupt && !!this.#s.value, () => {
387
398
  const i = this.#s.value;
388
- i.removeEventListener("arcgisSubmit", this.#a), i.removeEventListener("arcgisCancel", this.#r), i.addEventListener("arcgisSubmit", this.#a, { once: !0 }), i.addEventListener("arcgisCancel", this.#r, { once: !0 });
399
+ i.removeEventListener("arcgisSubmit", this.#a), i.removeEventListener("arcgisCancel", this.#i), i.addEventListener("arcgisSubmit", this.#a, { once: !0 }), i.addEventListener("arcgisCancel", this.#i, { once: !0 });
389
400
  }), e = this.messages.on("after-add", (i) => {
390
- const r = i.item;
391
- r.role === "assistant" && (r.error || r.content) && this.arcgisResponse.emit(r);
401
+ const s = i.item;
402
+ s.role === "assistant" && (s.error || s.content) && this.arcgisResponse.emit(s);
392
403
  });
393
404
  return queueMicrotask(() => {
394
405
  this.#d().then((i) => {
395
406
  i ? this.arcgisReady.emit() : this._error && this.arcgisError.emit(new Error(this._error));
396
407
  });
397
408
  }), () => {
398
- t.remove(), e.remove(), this.#t.value?.removeEventListener("arcgisPromptSelect", this.#p), this.#s.value?.removeEventListener("arcgisSubmit", this.#a), this.#s.value?.removeEventListener("arcgisCancel", this.#r), this.#t.value?.removeEventListener("arcgisSubmit", this.#l), this.#t.value?.removeEventListener("arcgisCancel", this.#c), this.#t.value?.removeEventListener("arcgisFeedback", this.#h), this._orchestratorController?.destroy(), this._orchestratorController = null;
409
+ t.remove(), e.remove(), this.#t.value?.removeEventListener("arcgisPromptSelect", this.#g), this.#s.value?.removeEventListener("arcgisSubmit", this.#a), this.#s.value?.removeEventListener("arcgisCancel", this.#i), 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;
399
410
  };
400
411
  });
401
412
  }
402
413
  _reset() {
403
- this._orchestratorController?.cancel(), this.#e?.abort(), this._interrupt = null, this.messages.removeAll(), this._error = null, this._inputValue = "";
414
+ this._orchestratorController?.cancel(), this.#e?.abort(), this._interrupt = null, this.messages.removeAll(), this._error = null, this._inputValue = "", this._signedInUserId = void 0;
404
415
  }
405
416
  _renderEntryMessage() {
406
- return !this._user ? this._renderSignInNotice() : this._error ? this._renderErrorNotice() : this.entryMessage ? this.messages.length > 0 ? null : l`<calcite-notice open kind=brand closable icon width=full><div slot=message>${this.entryMessage}</div></calcite-notice>` : l`<slot name=entry-message></slot>`;
417
+ return this._isSignedIn ? this._error ? this._renderErrorNotice() : this.entryMessage ? this.messages.length > 0 ? null : c`<calcite-notice open kind=brand closable icon width=full><div slot=message>${this.entryMessage}</div></calcite-notice>` : c`<slot name=entry-message></slot>` : this._renderSignInNotice();
407
418
  }
408
419
  _renderSignInNotice() {
409
- const t = this.#i;
410
- return l`<calcite-notice slot=entry-message open kind=brand icon width=full><div slot=message>You need to sign in to use the assistant chat.</div>${t ? l`<calcite-link slot=link @click=${async () => {
420
+ const t = this.#r;
421
+ return c`<calcite-notice slot=entry-message open kind=brand icon width=full><div slot=message>You need to sign in to use the assistant chat.</div>${t ? c`<calcite-link slot=link @click=${async () => {
411
422
  try {
412
- await T.getCredential(t.url), this._error = null, await this.#d(), this.arcgisReady.emit();
423
+ const e = await z.getCredential(`${t.url}/sharing`);
424
+ this._signedInUserId = e.userId, this._error = null, this.requestUpdate(), await this.#d() ? this.arcgisReady.emit() : this._error && this.arcgisError.emit(new Error(this._error));
413
425
  } catch (e) {
414
- console.error("Error signing in:", e);
426
+ this._error = e?.message ?? "Error signing in.", this.arcgisError.emit(new Error(this._error)), O.log("error", this, "Error signing in:", { detail: { error: e } });
415
427
  }
416
- }} target=_blank title="Sign in to ArcGIS Online">Sign in</calcite-link>` : l`<div slot=link>No portal information available</div>`}</calcite-notice>`;
428
+ }} target=_blank title="Sign in to ArcGIS Online">Sign in</calcite-link>` : c`<div slot=link>No portal information available</div>`}</calcite-notice>`;
417
429
  }
418
430
  _renderErrorNotice() {
419
- return this._error ? l`<calcite-notice slot=entry-message open kind=brand icon width=full>${this._error === G ? l`<div slot=message>${U}</div><calcite-link slot=link .href=${W} target=_blank title="Learn about web map embeddings">Read more</calcite-link>` : l`<div slot=message>${this._error}</div>`}</calcite-notice>` : null;
431
+ return this._error ? c`<calcite-notice slot=entry-message open kind=brand icon width=full>${this._error === W ? c`<div slot=message>${Y}</div><calcite-link slot=link .href=${J} target=_blank title="Learn about web map embeddings">Read more</calcite-link>` : c`<div slot=message>${this._error}</div>`}</calcite-notice>` : null;
420
432
  }
421
433
  render() {
422
- return l`<calcite-panel .loading=${!this._orchestratorController && !this._error || this._orchestratorController?.loading} .heading=${this.heading ?? this._messages.assistantLabel} .description=${this.description} ${v(this.#t)}><slot name=header-actions-start slot=header-actions-start></slot><slot name=header-actions-end slot=header-actions-end></slot><div class="content-container"><arcgis-assistant-chat .loading=${this.awaitingResponse} .messages=${this.messages} .interrupt=${this._interrupt}><slot name=message-starter slot=message-starter></slot><slot name=messages slot=messages>${this.messages.map((t) => t.role === "assistant" ? l`<arcgis-assistant-message .message=${t} .feedbackEnabled=${this.feedbackEnabled} .logEnabled=${this.logEnabled} .copyEnabled=${this.copyEnabled} .readAloudEnabled=${this.readAloudEnabled} @arcgisSlottableRequest=${this.#g} .assistantAvatarEnabled=${this.assistantAvatarEnabled}>${t.blocks?.map((e, i) => l`<slot name=${w(t.id, i) ?? k} slot=${w(t.id, i) ?? k}><arcgis-assistant-message-block .block=${e}></arcgis-assistant-message-block></slot>`)}</arcgis-assistant-message>` : l`<arcgis-assistant-user-message .message=${t} .user=${this._user}></arcgis-assistant-user-message>`)}</slot>${this._interrupt ? l`<div slot=message-loading><div class="interrupt-waiting-message">waiting for user input...</div> // TODO: use t9n strings</div>` : l`<slot name=message-loading slot=message-loading><arcgis-assistant-message-loading .loading=${this.awaitingResponse} .loadingMessage=${this.awaitingResponseStep} .assistantAvatarEnabled=${this.assistantAvatarEnabled} .interrupts=${this._interruptDetails}></arcgis-assistant-message-loading></slot>`}</arcgis-assistant-chat></div>${this._interrupt ? l`<arcgis-assistant-interrupt slot=content-bottom .type=${this._interrupt.type} .message=${this._interrupt.message} .options=${this._interrupt.options} ${v(this.#s)}></arcgis-assistant-interrupt>` : this.suggestedPrompts?.length ? l`<div class="suggested-prompts-container" slot=content-bottom><arcgis-assistant-suggested-prompts class="suggested-prompts" .prompts=${this.suggestedPrompts}></arcgis-assistant-suggested-prompts></div>` : null}<div class="footer-container" slot=footer>${this._renderEntryMessage()}<slot name=chat-entry><arcgis-assistant-chat-entry .awaitingResponse=${this.awaitingResponse || this._isAnswering} .inputValue=${this._inputValue} .messages=${this.messages} .voiceInputEnabled=${this.voiceInputEnabled} .disabled=${this._canceling || !this._user || !!this._interrupt} ${v(this.#n)}><slot name=entry-actions-start slot=entry-actions-start></slot><slot name=entry-actions-end slot=entry-actions-end><calcite-button .iconStart=${this.awaitingResponse || this._isAnswering ? "circle-stop" : "send"} @click=${() => {
434
+ return c`<calcite-panel .loading=${!this._orchestratorController && !this._error || this._orchestratorController?.loading} .heading=${this.heading ?? this._messages.assistantLabel} .description=${this.description} ${v(this.#t)}><slot name=header-actions-start slot=header-actions-start></slot><slot name=header-actions-end slot=header-actions-end></slot><div class="content-container"><arcgis-assistant-chat .loading=${this.awaitingResponse} .messages=${this.messages} .interrupt=${this._interrupt}><slot name=message-starter slot=message-starter></slot><slot name=messages slot=messages>${this.messages.map((t) => t.role === "assistant" ? c`<arcgis-assistant-message .message=${t} .feedbackEnabled=${this.feedbackEnabled} .logEnabled=${this.logEnabled} .copyEnabled=${this.copyEnabled} .readAloudEnabled=${this.readAloudEnabled} @arcgisSlottableRequest=${this.#p} .assistantAvatarEnabled=${this.assistantAvatarEnabled}>${t.blocks?.map((e, i) => c`<slot name=${w(t.id, i) ?? k} slot=${w(t.id, i) ?? k}><arcgis-assistant-message-block .block=${e}></arcgis-assistant-message-block></slot>`)}</arcgis-assistant-message>` : c`<arcgis-assistant-user-message .message=${t} .user=${this._user}></arcgis-assistant-user-message>`)}</slot>${this._interrupt ? c`<div slot=message-loading><div class="interrupt-waiting-message">waiting for user input...</div></div>` : c`<slot name=message-loading slot=message-loading><arcgis-assistant-message-loading .loading=${this.awaitingResponse} .loadingMessage=${this.awaitingResponseStep} .assistantAvatarEnabled=${this.assistantAvatarEnabled} .interrupts=${this._interruptDetails}></arcgis-assistant-message-loading></slot>`}</arcgis-assistant-chat></div>${this._interrupt ? c`<slot name=interrupt><arcgis-assistant-interrupt slot=content-bottom .type=${this._interrupt.type} .message=${this._interrupt.message} .options=${this._interrupt.options} ${v(this.#s)}></arcgis-assistant-interrupt></slot>` : this.suggestedPrompts?.length ? c`<div class="suggested-prompts-container" slot=content-bottom><arcgis-assistant-suggested-prompts class="suggested-prompts" .prompts=${this.suggestedPrompts}></arcgis-assistant-suggested-prompts></div>` : null}<div class="footer-container" slot=footer>${this._renderEntryMessage()}<slot name=chat-entry><arcgis-assistant-chat-entry .awaitingResponse=${this.awaitingResponse || this._isAnswering} .inputValue=${this._inputValue} .messages=${this.messages} .voiceInputEnabled=${this.voiceInputEnabled} .disabled=${this._canceling || !this._isSignedIn || !!this._interrupt} ${v(this.#n)}><slot name=entry-actions-start slot=entry-actions-start></slot><slot name=entry-actions-end slot=entry-actions-end><calcite-button .iconStart=${this.awaitingResponse || this._isAnswering ? "circle-stop" : "send"} @click=${() => {
423
435
  this.#n.value?.submitMessage();
424
436
  }} 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>`;
425
437
  }
426
438
  }
427
- $("arcgis-assistant", Y);
439
+ I("arcgis-assistant", K);
428
440
  export {
429
- Y as ArcgisAssistant
441
+ K as ArcgisAssistant
430
442
  };
@@ -5,6 +5,7 @@ import "@langchain/langgraph/web";
5
5
  import "../../chunks/adapter.js";
6
6
  import "@arcgis/core/identity/IdentityManager.js";
7
7
  import "@arcgis/core/portal/Portal.js";
8
+ import "@arcgis/toolkit/string";
8
9
  import "../../chunks/generateLayerDescriptions.js";
9
10
  import "@langchain/core/messages";
10
11
  import "@langchain/core/callbacks/dispatch/web";
@@ -19,7 +20,7 @@ import "zod";
19
20
  import { D as r } from "../../chunks/dataExplorationGraph.js";
20
21
  import "@arcgis/core/views/LinkChartView.js";
21
22
  import "@arcgis/core/rest/knowledgeGraphService.js";
22
- import { r as a, a as o } from "../../chunks/utils2.js";
23
+ import { r as o, a } from "../../chunks/utils2.js";
23
24
  class s extends i {
24
25
  constructor() {
25
26
  super(...arguments), this.agent = r;
@@ -34,7 +35,7 @@ class s extends i {
34
35
  return { mapView: this.#t };
35
36
  }
36
37
  load() {
37
- this.#t = a(this, "arcgis-assistant-data-exploration-agent"), o(this);
38
+ this.#t = o(this, "arcgis-assistant-data-exploration-agent"), a(this);
38
39
  }
39
40
  }
40
41
  t("arcgis-assistant-data-exploration-agent", s);
@@ -5,6 +5,7 @@ import "@langchain/langgraph/web";
5
5
  import "../../chunks/adapter.js";
6
6
  import "@arcgis/core/identity/IdentityManager.js";
7
7
  import "@arcgis/core/portal/Portal.js";
8
+ import "@arcgis/toolkit/string";
8
9
  import "../../chunks/generateLayerDescriptions.js";
9
10
  import "@langchain/core/messages";
10
11
  import "@langchain/core/callbacks/dispatch/web";
@@ -5,6 +5,7 @@ import "@langchain/langgraph/web";
5
5
  import "../../chunks/adapter.js";
6
6
  import "@arcgis/core/identity/IdentityManager.js";
7
7
  import "@arcgis/core/portal/Portal.js";
8
+ import "@arcgis/toolkit/string";
8
9
  import "../../chunks/generateLayerDescriptions.js";
9
10
  import "@langchain/core/messages";
10
11
  import "@langchain/core/callbacks/dispatch/web";
@@ -22,7 +23,7 @@ import "@arcgis/core/smartMapping/statistics/uniqueValues.js";
22
23
  import { A as o } from "../../chunks/arcgisKnowledgeGraph.js";
23
24
  import { b as s, a as n } from "../../chunks/utils2.js";
24
25
  import { fetchKnowledgeGraph as a } from "@arcgis/core/rest/knowledgeGraphService.js";
25
- class c extends i {
26
+ class p extends i {
26
27
  constructor() {
27
28
  super(...arguments), this.agent = o;
28
29
  }
@@ -63,7 +64,7 @@ class c extends i {
63
64
  this.#e = s(this) ?? void 0, n(this);
64
65
  }
65
66
  }
66
- r("arcgis-assistant-knowledge-agent", c);
67
+ r("arcgis-assistant-knowledge-agent", p);
67
68
  export {
68
- c as ArcgisAssistantKnowledgeAgent
69
+ p as ArcgisAssistantKnowledgeAgent
69
70
  };
@@ -5,6 +5,7 @@ import "@langchain/langgraph/web";
5
5
  import "../../chunks/adapter.js";
6
6
  import "@arcgis/core/identity/IdentityManager.js";
7
7
  import "@arcgis/core/portal/Portal.js";
8
+ import "@arcgis/toolkit/string";
8
9
  import "../../chunks/generateLayerDescriptions.js";
9
10
  import "@langchain/core/messages";
10
11
  import "@langchain/core/callbacks/dispatch/web";
@@ -6,6 +6,7 @@ import "@langchain/langgraph/web";
6
6
  import "../../chunks/adapter.js";
7
7
  import "@arcgis/core/identity/IdentityManager.js";
8
8
  import "@arcgis/core/portal/Portal.js";
9
+ import "@arcgis/toolkit/string";
9
10
  import "../../chunks/generateLayerDescriptions.js";
10
11
  import "@langchain/core/messages";
11
12
  import "@langchain/core/callbacks/dispatch/web";