@arcgis/ai-components 5.2.0-next.111 → 5.2.0-next.112
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.
- package/dist/cdn/4AQBRGO2.js +3 -0
- package/dist/cdn/5BBXNT75.js +66 -0
- package/dist/cdn/{P4GFYBBO.js → F3CSORDI.js} +1 -1
- package/dist/cdn/{2W7LK4HA.js → LFQLCCJJ.js} +1 -1
- package/dist/cdn/{ROQGPAR5.js → SLR75R32.js} +1 -1
- package/dist/cdn/{PYGX4HN7.js → XV3DHHYJ.js} +1 -1
- package/dist/cdn/assets/assistant/t9n/messages.en.json +1 -1
- package/dist/cdn/index.js +1 -1
- package/dist/components/arcgis-assistant/customElement.d.ts +6 -0
- package/dist/components/arcgis-assistant/customElement.js +125 -113
- package/dist/docs/api.json +1 -1
- package/dist/docs/docs.json +1 -1
- package/dist/docs/web-types.json +1 -1
- package/package.json +7 -7
- package/dist/cdn/DQ2Z65UO.js +0 -3
- package/dist/cdn/RFVZ7KCG.js +0 -66
|
@@ -1,36 +1,36 @@
|
|
|
1
1
|
/* COPYRIGHT Esri - https://js.arcgis.com/5.2/LICENSE.txt */
|
|
2
|
-
import { c as
|
|
3
|
-
import { css as
|
|
4
|
-
import
|
|
5
|
-
import { whenOnce as R, watch as D, when as
|
|
6
|
-
import
|
|
7
|
-
import { LitElement as
|
|
8
|
-
import * as
|
|
9
|
-
import { rethrowError as
|
|
10
|
-
import { createRef as w, ref as
|
|
11
|
-
import { u as
|
|
12
|
-
import { O as
|
|
2
|
+
import { c as L } from "../../chunks/runtime.js";
|
|
3
|
+
import { css as T, html as g } from "lit";
|
|
4
|
+
import M from "@arcgis/core/core/Collection.js";
|
|
5
|
+
import { whenOnce as R, watch as D, when as O } from "@arcgis/core/core/reactiveUtils.js";
|
|
6
|
+
import U from "@arcgis/core/portal/Portal.js";
|
|
7
|
+
import { LitElement as B, createEvent as d, nothing as _ } from "@arcgis/lumina";
|
|
8
|
+
import * as z from "@arcgis/toolkit/log";
|
|
9
|
+
import { rethrowError as N } from "@arcgis/toolkit/log";
|
|
10
|
+
import { createRef as w, ref as E } from "lit/directives/ref.js";
|
|
11
|
+
import { u as F } from "../../chunks/useT9n.js";
|
|
12
|
+
import { O as q } from "../../chunks/orchestrator.js";
|
|
13
13
|
import "@langchain/core/callbacks/dispatch/web";
|
|
14
14
|
import "@langchain/core/prompts";
|
|
15
15
|
import "@langchain/openai";
|
|
16
16
|
import "@arcgis/core/request.js";
|
|
17
|
-
import
|
|
17
|
+
import S from "@arcgis/core/identity/IdentityManager.js";
|
|
18
18
|
import "@arcgis/toolkit/string";
|
|
19
19
|
import "@arcgis/core/config.js";
|
|
20
20
|
import "@langchain/core/messages";
|
|
21
21
|
import "@arcgis/core/layers/FeatureLayer.js";
|
|
22
22
|
import "../../chunks/generateLayerDescriptions.js";
|
|
23
23
|
import "@langchain/langgraph/web";
|
|
24
|
-
import
|
|
25
|
-
import { property as b, subclass as
|
|
26
|
-
import { marked as
|
|
27
|
-
import { g as
|
|
28
|
-
import { g as
|
|
29
|
-
const W =
|
|
30
|
-
function
|
|
31
|
-
return o.trim() ?
|
|
24
|
+
import H from "@arcgis/core/core/Accessor.js";
|
|
25
|
+
import { property as b, subclass as V } from "@arcgis/core/core/accessorSupport/decorators.js";
|
|
26
|
+
import { marked as I } from "marked";
|
|
27
|
+
import { g as j } from "../../chunks/utils3.js";
|
|
28
|
+
import { g as $ } from "../../chunks/slottableRequestUtils.js";
|
|
29
|
+
const W = T`:host{display:block;width:var(--arcgis-internal-panel-width, 100%);height:var(--arcgis-internal-expand-max-height, 100%);--calcite-panel-content-bottom-space: 0}.footer-container{display:flex;flex-direction:column;flex:1 1 0;gap:var(--calcite-spacing-md)}.content-container{display:flex;flex-direction:column;flex:1 1 0;min-height:0;position:relative;overflow:auto}.suggested-prompts-container{display:flex;justify-content:center;width:100%;background:var(--calcite-panel-background-color, var(--calcite-color-background))}.suggested-prompts{display:block;padding:var(--calcite-spacing-md);max-width:100%;box-sizing:border-box}.error-notice{padding:var(--calcite-spacing-sm)}.interrupt-waiting-message{font-style:italic;color:var(--calcite-color-text-2)}`;
|
|
30
|
+
function k(o) {
|
|
31
|
+
return o.trim() ? I.lexer(o).filter((t) => t.type !== "space").map((t) => I.parser([t])) : [];
|
|
32
32
|
}
|
|
33
|
-
class
|
|
33
|
+
class P {
|
|
34
34
|
constructor() {
|
|
35
35
|
this._stableParts = [], this._stableText = "", this._rawText = "";
|
|
36
36
|
}
|
|
@@ -42,11 +42,11 @@ class A {
|
|
|
42
42
|
// Parse the remaining live tail. Call once at stream end.
|
|
43
43
|
finalize() {
|
|
44
44
|
const t = this._rawText.slice(this._stableText.length);
|
|
45
|
-
return t.trim() && (this._stableParts.push(...
|
|
45
|
+
return t.trim() && (this._stableParts.push(...k(t)), this._stableText = this._rawText), this._stableParts;
|
|
46
46
|
}
|
|
47
47
|
// Get full output: stable segments + current live tail.
|
|
48
48
|
getParts() {
|
|
49
|
-
const t = this._trimIncompleteTail(this._rawText.slice(this._stableText.length)), e = t.trim() ?
|
|
49
|
+
const t = this._trimIncompleteTail(this._rawText.slice(this._stableText.length)), e = t.trim() ? k(t) : [];
|
|
50
50
|
return [...this._stableParts, ...e];
|
|
51
51
|
}
|
|
52
52
|
reset() {
|
|
@@ -57,8 +57,8 @@ class A {
|
|
|
57
57
|
const t = this._rawText.slice(this._stableText.length), e = this._lastSafeBoundary(t);
|
|
58
58
|
if (e <= 0)
|
|
59
59
|
return;
|
|
60
|
-
const
|
|
61
|
-
this._stableParts.push(...
|
|
60
|
+
const s = t.slice(0, e);
|
|
61
|
+
this._stableParts.push(...k(s)), this._stableText += s;
|
|
62
62
|
}
|
|
63
63
|
/**
|
|
64
64
|
* Find the last blank-line boundary that is outside code fences.
|
|
@@ -67,9 +67,9 @@ class A {
|
|
|
67
67
|
_lastSafeBoundary(t) {
|
|
68
68
|
const e = t.split(`
|
|
69
69
|
`);
|
|
70
|
-
let
|
|
70
|
+
let s = !1, r = 0, i = 0;
|
|
71
71
|
for (const l of e)
|
|
72
|
-
/^\s*(```|~~~)/u.test(l) && (
|
|
72
|
+
/^\s*(```|~~~)/u.test(l) && (s = !s), i += l.length + 1, l.trim() === "" && !s && (r = i);
|
|
73
73
|
return r < t.length ? r : 0;
|
|
74
74
|
}
|
|
75
75
|
/**
|
|
@@ -83,13 +83,13 @@ class A {
|
|
|
83
83
|
const e = t.lastIndexOf("<");
|
|
84
84
|
if (e !== -1 && !t.includes(">", e))
|
|
85
85
|
return t.slice(0, e);
|
|
86
|
-
const
|
|
87
|
-
if (
|
|
88
|
-
return t.slice(0,
|
|
86
|
+
const s = this._earliestUnclosedTag(t);
|
|
87
|
+
if (s !== -1)
|
|
88
|
+
return t.slice(0, s);
|
|
89
89
|
const r = t.lastIndexOf("[");
|
|
90
90
|
if (r !== -1) {
|
|
91
|
-
const
|
|
92
|
-
if (!/\[[^\]]*\]\([^)]*\)/u.test(
|
|
91
|
+
const i = t.slice(r);
|
|
92
|
+
if (!/\[[^\]]*\]\([^)]*\)/u.test(i))
|
|
93
93
|
return t.slice(0, r);
|
|
94
94
|
}
|
|
95
95
|
return t;
|
|
@@ -113,9 +113,9 @@ class A {
|
|
|
113
113
|
"source",
|
|
114
114
|
"track",
|
|
115
115
|
"wbr"
|
|
116
|
-
]),
|
|
117
|
-
for (let
|
|
118
|
-
const [, l, a, n] =
|
|
116
|
+
]), s = /<(\/?)([a-zA-Z][\w-]*)\b[^>]*?(\/?)>/gu, r = [];
|
|
117
|
+
for (let i = s.exec(t); i; i = s.exec(t)) {
|
|
118
|
+
const [, l, a, n] = i, c = a.toLowerCase();
|
|
119
119
|
if (!(e.has(c) || n === "/"))
|
|
120
120
|
if (l === "/") {
|
|
121
121
|
for (let h = r.length - 1; h >= 0; h--)
|
|
@@ -124,46 +124,46 @@ class A {
|
|
|
124
124
|
break;
|
|
125
125
|
}
|
|
126
126
|
} else
|
|
127
|
-
r.push({ name: c, index:
|
|
127
|
+
r.push({ name: c, index: i.index });
|
|
128
128
|
}
|
|
129
129
|
return r.length ? r[0].index : -1;
|
|
130
130
|
}
|
|
131
131
|
}
|
|
132
132
|
function G(o) {
|
|
133
|
-
const t = new
|
|
133
|
+
const t = new P();
|
|
134
134
|
return t.push(o), t.finalize();
|
|
135
135
|
}
|
|
136
136
|
const Z = async (o) => await new Promise((t) => setTimeout(t, o));
|
|
137
137
|
async function* J(o, { chunkSize: t = 15, delay: e = 50 } = {}) {
|
|
138
|
-
const
|
|
138
|
+
const s = new P();
|
|
139
139
|
for (let r = 0; r < o.length; r += t)
|
|
140
|
-
yield
|
|
141
|
-
yield
|
|
140
|
+
yield s.push(o.slice(r, r + t)), await Z(e);
|
|
141
|
+
yield s.finalize();
|
|
142
142
|
}
|
|
143
|
-
var K = Object.defineProperty, Q = Object.getOwnPropertyDescriptor, m = (o, t, e,
|
|
144
|
-
for (var r =
|
|
145
|
-
(l = o[
|
|
146
|
-
return
|
|
143
|
+
var K = Object.defineProperty, Q = Object.getOwnPropertyDescriptor, m = (o, t, e, s) => {
|
|
144
|
+
for (var r = s > 1 ? void 0 : s ? Q(t, e) : t, i = o.length - 1, l; i >= 0; i--)
|
|
145
|
+
(l = o[i]) && (r = (s ? l(t, e, r) : l(r)) || r);
|
|
146
|
+
return s && r && K(t, e, r), r;
|
|
147
147
|
};
|
|
148
|
-
const
|
|
149
|
-
async function* C(o, t, e,
|
|
148
|
+
const A = (o) => !o || typeof o != "object" ? !1 : o.name === "AbortError";
|
|
149
|
+
async function* C(o, t, e, s, r = !1) {
|
|
150
150
|
if (r) {
|
|
151
|
-
if (
|
|
151
|
+
if (s?.aborted) {
|
|
152
152
|
yield { type: "cancelled", log: e, runId: t };
|
|
153
153
|
return;
|
|
154
154
|
}
|
|
155
155
|
yield { type: "block-data", blockType: "text", data: { parts: G(o) }, runId: t };
|
|
156
156
|
return;
|
|
157
157
|
}
|
|
158
|
-
for await (const
|
|
159
|
-
if (
|
|
158
|
+
for await (const i of J(o)) {
|
|
159
|
+
if (s?.aborted) {
|
|
160
160
|
yield { type: "cancelled", log: e, runId: t };
|
|
161
161
|
return;
|
|
162
162
|
}
|
|
163
|
-
yield { type: "block-data", blockType: "text", data: { parts:
|
|
163
|
+
yield { type: "block-data", blockType: "text", data: { parts: i }, runId: t };
|
|
164
164
|
}
|
|
165
165
|
}
|
|
166
|
-
let p = class extends
|
|
166
|
+
let p = class extends H {
|
|
167
167
|
constructor(o) {
|
|
168
168
|
super(o), this.view = null, this.streamingDisabled = !1, this.runtimeEventsEnabled = !1, this.loading = !1, this.processing = !1, this.processingStep = "";
|
|
169
169
|
}
|
|
@@ -181,7 +181,7 @@ let p = class extends F {
|
|
|
181
181
|
async _initialize() {
|
|
182
182
|
this.removeHandles(), await Promise.all([this.portal.load(), this.view?.when()]), this.view && await R(() => !this.view.updating), this._set(
|
|
183
183
|
"orchestrator",
|
|
184
|
-
await
|
|
184
|
+
await q.init({
|
|
185
185
|
agents: [...this.agents],
|
|
186
186
|
runtimeEventsEnabled: this.runtimeEventsEnabled,
|
|
187
187
|
view: this.view ?? void 0
|
|
@@ -202,43 +202,43 @@ let p = class extends F {
|
|
|
202
202
|
if (!this.orchestrator)
|
|
203
203
|
throw new Error("Orchestrator not initialized yet.");
|
|
204
204
|
this._set("processing", !0), this._set("processingStep", "");
|
|
205
|
-
const
|
|
206
|
-
let r,
|
|
205
|
+
const s = [];
|
|
206
|
+
let r, i = "pending";
|
|
207
207
|
try {
|
|
208
208
|
const l = this.orchestrator.ask(o, t);
|
|
209
209
|
for await (const a of l)
|
|
210
|
-
switch (
|
|
210
|
+
switch (i = a.runId, a.type) {
|
|
211
211
|
case "runtime": {
|
|
212
|
-
yield { type: "runtime", event: a, runId:
|
|
212
|
+
yield { type: "runtime", event: a, runId: i };
|
|
213
213
|
break;
|
|
214
214
|
}
|
|
215
215
|
case "trace": {
|
|
216
|
-
this._set("processingStep", a.data.text),
|
|
216
|
+
this._set("processingStep", a.data.text), s.push(a.data.text);
|
|
217
217
|
break;
|
|
218
218
|
}
|
|
219
219
|
case "completed": {
|
|
220
220
|
this._set("processing", !1), this._set("processingStep", "");
|
|
221
221
|
const n = a.result, c = !!n.content.length, h = !!r?.length;
|
|
222
222
|
if (!c && !h) {
|
|
223
|
-
yield { type: "completed", error: "No response received.", log:
|
|
223
|
+
yield { type: "completed", error: "No response received.", log: s, runId: i };
|
|
224
224
|
return;
|
|
225
225
|
}
|
|
226
226
|
const u = n.content;
|
|
227
|
-
if (yield { type: "block-start", blockType: "text", runId:
|
|
227
|
+
if (yield { type: "block-start", blockType: "text", runId: i }, yield* C(u, i, s, e, this.streamingDisabled), yield { type: "block-end", blockType: "text", runId: i }, h)
|
|
228
228
|
for (const y of r) {
|
|
229
229
|
if (e?.aborted) {
|
|
230
|
-
yield { type: "cancelled", log:
|
|
230
|
+
yield { type: "cancelled", log: s, runId: i };
|
|
231
231
|
return;
|
|
232
232
|
}
|
|
233
233
|
const { type: f, data: v } = y;
|
|
234
|
-
if (yield { type: "block-start", blockType: f, runId:
|
|
235
|
-
const
|
|
236
|
-
yield* C(
|
|
234
|
+
if (yield { type: "block-start", blockType: f, runId: i }, f === "text") {
|
|
235
|
+
const x = typeof v?.content == "string" ? v.content : "";
|
|
236
|
+
yield* C(x, i, s, e, this.streamingDisabled);
|
|
237
237
|
} else
|
|
238
|
-
yield { type: "block-data", blockType: f, data: v, runId:
|
|
239
|
-
yield { type: "block-end", blockType: f, runId:
|
|
238
|
+
yield { type: "block-data", blockType: f, data: v, runId: i };
|
|
239
|
+
yield { type: "block-end", blockType: f, runId: i };
|
|
240
240
|
}
|
|
241
|
-
yield { type: "completed", response: u, blocks: r, log:
|
|
241
|
+
yield { type: "completed", response: u, blocks: r, log: s, runId: i };
|
|
242
242
|
return;
|
|
243
243
|
}
|
|
244
244
|
case "ux-suggestion": {
|
|
@@ -261,19 +261,19 @@ let p = class extends F {
|
|
|
261
261
|
return { type: n, message: c, options: u };
|
|
262
262
|
}
|
|
263
263
|
})();
|
|
264
|
-
this._set("processingStep", "Waiting for user input..."), yield { type: "interrupt", payload: y, runId:
|
|
264
|
+
this._set("processingStep", "Waiting for user input..."), yield { type: "interrupt", payload: y, runId: i };
|
|
265
265
|
break;
|
|
266
266
|
}
|
|
267
267
|
case "cancelled": {
|
|
268
|
-
yield { type: "cancelled", log:
|
|
268
|
+
yield { type: "cancelled", log: s, runId: i };
|
|
269
269
|
return;
|
|
270
270
|
}
|
|
271
271
|
case "error": {
|
|
272
|
-
if (e?.aborted ||
|
|
273
|
-
yield { type: "cancelled", log:
|
|
272
|
+
if (e?.aborted || A(a.error)) {
|
|
273
|
+
yield { type: "cancelled", log: s, runId: i };
|
|
274
274
|
return;
|
|
275
275
|
}
|
|
276
|
-
yield { type: "completed", error: a.error.message, log:
|
|
276
|
+
yield { type: "completed", error: a.error.message, log: s, runId: i };
|
|
277
277
|
return;
|
|
278
278
|
}
|
|
279
279
|
default: {
|
|
@@ -282,11 +282,11 @@ let p = class extends F {
|
|
|
282
282
|
}
|
|
283
283
|
}
|
|
284
284
|
} catch (l) {
|
|
285
|
-
if (e?.aborted ||
|
|
286
|
-
yield { type: "cancelled", log:
|
|
285
|
+
if (e?.aborted || A(l)) {
|
|
286
|
+
yield { type: "cancelled", log: s, runId: i };
|
|
287
287
|
return;
|
|
288
288
|
}
|
|
289
|
-
console.warn("Error during message processing:", l), yield { type: "completed", error: "An error occurred during message processing.", log:
|
|
289
|
+
console.warn("Error during message processing:", l), yield { type: "completed", error: "An error occurred during message processing.", log: s, runId: "error" };
|
|
290
290
|
return;
|
|
291
291
|
} finally {
|
|
292
292
|
this._set("processing", !1);
|
|
@@ -324,12 +324,12 @@ m([
|
|
|
324
324
|
b({ readOnly: !0 })
|
|
325
325
|
], p.prototype, "processingStep", 2);
|
|
326
326
|
p = m([
|
|
327
|
-
|
|
327
|
+
V("OrchestratorController")
|
|
328
328
|
], p);
|
|
329
329
|
const X = "Embeddings resource 'embeddings-v01.json' not found in the webmap portal item.", Y = "Embeddings not found for this web map.", tt = "https://developers.arcgis.com/javascript/latest/agentic-apps/ai-webmap-setup/#embeddings";
|
|
330
|
-
class et extends
|
|
330
|
+
class et extends B {
|
|
331
331
|
constructor() {
|
|
332
|
-
super(...arguments), this._messages =
|
|
332
|
+
super(...arguments), this._messages = F({ blocking: !0 }), this.#t = w(), this.#o = w(), this.#i = w(), this.#e = null, this.#r = /* @__PURE__ */ new Map(), this.#s = U.getDefault(), this.#a = (t) => {
|
|
333
333
|
t.stopPropagation(), this.cancelInterrupt();
|
|
334
334
|
}, this.#n = (t) => {
|
|
335
335
|
t.stopPropagation();
|
|
@@ -355,7 +355,7 @@ class et extends U {
|
|
|
355
355
|
this._inputValue = e.prompt, this.arcgisPromptSelect.emit(e);
|
|
356
356
|
}, this.#u = (t) => {
|
|
357
357
|
this.arcgisSlottableRequest.emit(t.detail);
|
|
358
|
-
}, this._orchestratorController = null, this._interrupt = null, this._interruptDetails = [], this._error = null, this._inputValue = "", this._isAnswering = !1, this._canceling = !1, this.messages = new
|
|
358
|
+
}, this._orchestratorController = null, this._interrupt = null, this._interruptDetails = [], this._error = null, this._inputValue = "", this._isAnswering = !1, this._canceling = !1, this.messages = new M([]), this.referenceElement = null, this.suggestedPrompts = [], this.feedbackEnabled = !1, this.keepSuggestedPrompts = !1, this.streamingDisabled = !1, this.runtimeEventsEnabled = !1, this.logEnabled = !1, this.copyEnabled = !1, this.voiceInputEnabled = !1, this.readAloudEnabled = !1, this.assistantAvatarEnabled = !1, this.userAvatarEnabled = !1, this.arcgisCancel = d(), this.arcgisError = d(), this.arcgisFeedback = d(), this.arcgisInterrupt = d(), this.arcgisInterruptCancel = d(), this.arcgisInterruptSubmit = d(), this.arcgisPromptSelect = d(), this.arcgisReady = d(), this.arcgisResponse = d(), this.arcgisRuntime = d({ bubbles: !1, composed: !1 }), this.arcgisSlottableRequest = d({ bubbles: !1, composed: !1 }), this.arcgisSubmit = d();
|
|
359
359
|
}
|
|
360
360
|
static {
|
|
361
361
|
this.properties = { _orchestratorController: 16, _interrupt: 16, _interruptDetails: 16, _error: 16, _inputValue: 16, _isAnswering: 16, _signedInUserId: 16, _canceling: 16, _isSignedIn: 16, _user: 16, awaitingResponse: 32, awaitingResponseStep: 32, interrupt: 32, messages: 0, orchestrator: 32, entryMessage: 1, heading: 1, description: 1, referenceElement: 1, alwaysUseAgentId: 1, allowedAgentIds: 0, suggestedPrompts: 0, feedbackEnabled: 5, keepSuggestedPrompts: 5, streamingDisabled: 5, runtimeEventsEnabled: 5, logEnabled: 5, copyEnabled: 5, voiceInputEnabled: 5, readAloudEnabled: 5, assistantAvatarEnabled: 5, userAvatarEnabled: 5 };
|
|
@@ -365,10 +365,10 @@ class et extends U {
|
|
|
365
365
|
}
|
|
366
366
|
#t;
|
|
367
367
|
#o;
|
|
368
|
-
#
|
|
368
|
+
#i;
|
|
369
369
|
#e;
|
|
370
370
|
#r;
|
|
371
|
-
#
|
|
371
|
+
#s;
|
|
372
372
|
#a;
|
|
373
373
|
#n;
|
|
374
374
|
#l;
|
|
@@ -377,10 +377,10 @@ class et extends U {
|
|
|
377
377
|
#g;
|
|
378
378
|
#u;
|
|
379
379
|
get _isSignedIn() {
|
|
380
|
-
return !!this.#
|
|
380
|
+
return !!this.#s?.user || !!this._signedInUserId;
|
|
381
381
|
}
|
|
382
382
|
get _user() {
|
|
383
|
-
return this.#
|
|
383
|
+
return this.#s?.user?.fullName || this.#s?.user?.username;
|
|
384
384
|
}
|
|
385
385
|
get awaitingResponse() {
|
|
386
386
|
return this._orchestratorController?.processing ?? !1;
|
|
@@ -416,16 +416,16 @@ class et extends U {
|
|
|
416
416
|
}), !this._orchestratorController))
|
|
417
417
|
return;
|
|
418
418
|
this.#e = new AbortController(), this._orchestratorController.streamingDisabled = this.streamingDisabled;
|
|
419
|
-
const
|
|
420
|
-
for await (const
|
|
421
|
-
const l =
|
|
422
|
-
switch (
|
|
419
|
+
const s = this.alwaysUseAgentId ? { routing: "direct", agentId: this.alwaysUseAgentId } : { routing: "auto", agentIds: this.allowedAgentIds }, r = this._orchestratorController.ask(e, s, this.#e?.signal);
|
|
420
|
+
for await (const i of r) {
|
|
421
|
+
const l = i.runId, a = this.messages.at(-1);
|
|
422
|
+
switch (i.type) {
|
|
423
423
|
case "runtime":
|
|
424
|
-
this.arcgisRuntime.emit(
|
|
424
|
+
this.arcgisRuntime.emit(i.event);
|
|
425
425
|
break;
|
|
426
426
|
case "block-start": {
|
|
427
427
|
this._isAnswering = !0;
|
|
428
|
-
const n = { type:
|
|
428
|
+
const n = { type: i.blockType, isPending: !0 };
|
|
429
429
|
if (a?.role === "assistant" && a.id === l) {
|
|
430
430
|
const c = [...a.blocks ?? [], n];
|
|
431
431
|
this.messages.splice(-1, 1, { ...a, blocks: c });
|
|
@@ -442,7 +442,7 @@ class et extends U {
|
|
|
442
442
|
case "block-data": {
|
|
443
443
|
if (a?.role !== "assistant" || a?.id !== l)
|
|
444
444
|
break;
|
|
445
|
-
const n = [...a.blocks ?? []], c = n[n.length - 1], { blockType: h, data: u } =
|
|
445
|
+
const n = [...a.blocks ?? []], c = n[n.length - 1], { blockType: h, data: u } = i;
|
|
446
446
|
if (c?.type !== h || !c.isPending)
|
|
447
447
|
break;
|
|
448
448
|
h === "text" ? n[n.length - 1] = {
|
|
@@ -458,40 +458,40 @@ class et extends U {
|
|
|
458
458
|
if (a?.role !== "assistant" || a?.id !== l)
|
|
459
459
|
break;
|
|
460
460
|
const n = [...a.blocks ?? []], c = n[n.length - 1];
|
|
461
|
-
if (c?.type !==
|
|
461
|
+
if (c?.type !== i.blockType || !c.isPending)
|
|
462
462
|
break;
|
|
463
463
|
const h = c;
|
|
464
464
|
n[n.length - 1] = { ...h, data: { ...h.data }, isPending: !1 }, this.messages.splice(-1, 1, { ...a, blocks: n });
|
|
465
465
|
break;
|
|
466
466
|
}
|
|
467
467
|
case "completed":
|
|
468
|
-
|
|
468
|
+
i.error ? (this.messages.push({
|
|
469
469
|
role: "assistant",
|
|
470
|
-
log:
|
|
471
|
-
error:
|
|
470
|
+
log: i.log,
|
|
471
|
+
error: i.error,
|
|
472
472
|
id: l,
|
|
473
473
|
interrupts: this._interruptDetails
|
|
474
474
|
}), this._interruptDetails = []) : a?.role === "assistant" && a.id === l && this.messages.splice(-1, 1, {
|
|
475
475
|
...a,
|
|
476
|
-
content:
|
|
476
|
+
content: i.response,
|
|
477
477
|
blocks: a.blocks?.map((n) => ({ ...n, data: { ...n.data }, isPending: !1 })) ?? [],
|
|
478
478
|
isStreaming: !1,
|
|
479
|
-
log:
|
|
479
|
+
log: i.log
|
|
480
480
|
}), this._isAnswering = !1, this.#e = null, this._canceling = !1;
|
|
481
481
|
break;
|
|
482
482
|
case "interrupt":
|
|
483
|
-
this._interrupt = { ...
|
|
483
|
+
this._interrupt = { ...i.payload, id: l }, this.arcgisInterrupt.emit(this._interrupt);
|
|
484
484
|
break;
|
|
485
485
|
case "cancelled":
|
|
486
486
|
a?.role === "assistant" && a.id === l ? this.messages.splice(-1, 1, {
|
|
487
487
|
...a,
|
|
488
488
|
blocks: a.blocks?.filter((n) => n.type === "text" || !n.isPending) ?? [],
|
|
489
489
|
isStreaming: !1,
|
|
490
|
-
log:
|
|
490
|
+
log: i.log,
|
|
491
491
|
error: `(${this._messages.stoppedByUserLabel})`
|
|
492
492
|
}) : (this.messages.push({
|
|
493
493
|
role: "assistant",
|
|
494
|
-
log:
|
|
494
|
+
log: i.log,
|
|
495
495
|
error: `(${this._messages.stoppedByUserLabel})`,
|
|
496
496
|
id: l,
|
|
497
497
|
interrupts: this._interruptDetails
|
|
@@ -509,38 +509,50 @@ class et extends U {
|
|
|
509
509
|
loaded() {
|
|
510
510
|
this.manager.onLifecycle(() => {
|
|
511
511
|
this.#t.value?.addEventListener("arcgisPromptSelect", this.#g), this.#t.value?.addEventListener("arcgisSubmit", this.#l), this.#t.value?.addEventListener("arcgisCancel", this.#c), this.#t.value?.addEventListener("arcgisFeedback", this.#h);
|
|
512
|
-
const t =
|
|
513
|
-
const
|
|
514
|
-
|
|
515
|
-
}), e = this.messages.on("after-add", (
|
|
516
|
-
const r =
|
|
512
|
+
const t = O(() => !!this._interrupt && !!this.#i.value, () => {
|
|
513
|
+
const s = this.#i.value;
|
|
514
|
+
s.removeEventListener("arcgisSubmit", this.#n), s.removeEventListener("arcgisCancel", this.#a), s.addEventListener("arcgisSubmit", this.#n, { once: !0 }), s.addEventListener("arcgisCancel", this.#a, { once: !0 });
|
|
515
|
+
}), e = this.messages.on("after-add", (s) => {
|
|
516
|
+
const r = s.item;
|
|
517
517
|
r.role === "assistant" && (r.error || r.content) && this.arcgisResponse.emit(r);
|
|
518
518
|
});
|
|
519
519
|
return queueMicrotask(() => {
|
|
520
520
|
this.#p();
|
|
521
521
|
}), () => {
|
|
522
|
-
t.remove(), e.remove(), this.#t.value?.removeEventListener("arcgisPromptSelect", this.#g), this.#
|
|
522
|
+
t.remove(), e.remove(), this.#t.value?.removeEventListener("arcgisPromptSelect", this.#g), 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;
|
|
523
523
|
};
|
|
524
524
|
});
|
|
525
525
|
}
|
|
526
526
|
willUpdate(t) {
|
|
527
527
|
this.hasUpdated && t.has("runtimeEventsEnabled") && this._orchestratorController && (this._orchestratorController.destroy(), this._orchestratorController = null, this.#p());
|
|
528
528
|
}
|
|
529
|
+
async #m() {
|
|
530
|
+
await S.checkSignInStatus(this.#s.url);
|
|
531
|
+
const t = await this.#s.load();
|
|
532
|
+
if (!t.helperServices?.aiAssistantServices?.url)
|
|
533
|
+
throw new Error(this._messages.serviceUrlNotAvailableMessage);
|
|
534
|
+
let s = !1;
|
|
535
|
+
const r = await t.fetchSettings();
|
|
536
|
+
if (r.aiConfig ? s = r.aiConfig.aiForOrg?.enabled === !0 && r.aiConfig.aiForOrg?.aiCapabilities?.aiAgents?.enabled === !0 : s = r.aiAssistantsEnabled === !0, !s)
|
|
537
|
+
throw new Error(this._messages.aiAssistantsNotEnabledMessage);
|
|
538
|
+
if (!t.isPortal && !(t?.user?.privileges?.includes("portal:user:useAIAssistants") === !0))
|
|
539
|
+
throw new Error(this._messages.userPrivilegesNotSufficientMessage);
|
|
540
|
+
}
|
|
529
541
|
async #d() {
|
|
530
542
|
try {
|
|
531
543
|
this._error = null;
|
|
532
|
-
const t =
|
|
544
|
+
const t = j(this.el, this.referenceElement);
|
|
533
545
|
await t?.componentOnReady();
|
|
534
546
|
const e = [...this.#r.values()];
|
|
535
|
-
return e.length ? (this._orchestratorController?.destroy(), this._orchestratorController = new p({
|
|
547
|
+
return e.length ? (await this.#m(), this._orchestratorController?.destroy(), this._orchestratorController = new p({
|
|
536
548
|
agents: e,
|
|
537
|
-
portal: this.#
|
|
549
|
+
portal: this.#s,
|
|
538
550
|
runtimeEventsEnabled: this.runtimeEventsEnabled,
|
|
539
551
|
streamingDisabled: this.streamingDisabled,
|
|
540
552
|
view: t?.view
|
|
541
553
|
}), await this._orchestratorController.load(), this.requestUpdate(), !0) : (this._error = this._messages.noAgentsFoundMessage, !1);
|
|
542
554
|
} catch (t) {
|
|
543
|
-
return this._error = t?.message ?? this._messages.orchestratorInitializationErrorMessage,
|
|
555
|
+
return this._error = t?.message ?? this._messages.orchestratorInitializationErrorMessage, N(this)(t), !1;
|
|
544
556
|
}
|
|
545
557
|
}
|
|
546
558
|
async #p() {
|
|
@@ -553,13 +565,13 @@ class et extends U {
|
|
|
553
565
|
return this._isSignedIn ? this._error ? this._renderErrorNotice() : this.entryMessage ? this.messages.length > 0 ? null : g`<calcite-notice open kind=brand closable icon width=full><div slot=message>${this.entryMessage}</div></calcite-notice>` : g`<slot name=entry-message></slot>` : this._renderSignInNotice();
|
|
554
566
|
}
|
|
555
567
|
_renderSignInNotice() {
|
|
556
|
-
const t = this.#
|
|
568
|
+
const t = this.#s;
|
|
557
569
|
return g`<calcite-notice slot=entry-message open kind=brand icon width=full><div slot=message>${this._messages.signInRequiredMessage}</div>${t ? g`<calcite-link slot=link @click=${async () => {
|
|
558
570
|
try {
|
|
559
|
-
const e = await
|
|
571
|
+
const e = await S.getCredential(`${t.url}/sharing`);
|
|
560
572
|
this._signedInUserId = e.userId, this._error = null, this.requestUpdate(), await this.#p();
|
|
561
573
|
} catch (e) {
|
|
562
|
-
this._error = e?.message ?? this._messages.signInErrorMessage, this.arcgisError.emit(new Error(this._error)),
|
|
574
|
+
this._error = e?.message ?? this._messages.signInErrorMessage, this.arcgisError.emit(new Error(this._error)), z.log("error", this, "Error signing in:", { detail: { error: e } });
|
|
563
575
|
}
|
|
564
576
|
}} target=_blank title=${this._messages.signInToArcGISOnlineLabel ?? _}>${this._messages.signInLabel}</calcite-link>` : g`<div slot=link>${this._messages.noPortalInformationMessage}</div>`}</calcite-notice>`;
|
|
565
577
|
}
|
|
@@ -567,12 +579,12 @@ class et extends U {
|
|
|
567
579
|
return this._error ? g`<calcite-notice slot=entry-message open kind=brand icon width=full>${this._error === X ? g`<div slot=message>${Y}</div><calcite-link slot=link .href=${tt} target=_blank title=${this._messages.learnAboutWebMapEmbeddingsLabel ?? _}>${this._messages.readMoreLabel}</calcite-link>` : g`<div slot=message>${this._error}</div>`}</calcite-notice>` : null;
|
|
568
580
|
}
|
|
569
581
|
render() {
|
|
570
|
-
return g`<calcite-panel .loading=${!this._orchestratorController && !this._error || this._orchestratorController?.loading} .heading=${this.heading ?? this._messages.assistantLabel} .description=${this.description} ${
|
|
582
|
+
return g`<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" ? g`<arcgis-assistant-message .message=${t} .feedbackEnabled=${this.feedbackEnabled} .logEnabled=${this.logEnabled} .copyEnabled=${this.copyEnabled} .readAloudEnabled=${this.readAloudEnabled} @arcgisSlottableRequest=${this.#u} .assistantAvatarEnabled=${this.assistantAvatarEnabled}>${t.blocks?.map((e, s) => g`<slot name=${$(t.id, s) ?? _} slot=${$(t.id, s) ?? _}><arcgis-assistant-message-block .block=${e}></arcgis-assistant-message-block></slot>`)}</arcgis-assistant-message>` : g`<arcgis-assistant-user-message .message=${t} .user=${this._user} .userAvatarEnabled=${this.userAvatarEnabled}></arcgis-assistant-user-message>`)}</slot>${this._interrupt ? g`<div slot=message-loading><div class="interrupt-waiting-message">${this._messages.waitingForUserInputMessage}</div></div>` : g`<slot name=message-loading slot=message-loading><arcgis-assistant-message-loading .loading=${this.awaitingResponse} .loadingMessage=${this.awaitingResponseStep} .assistantAvatarEnabled=${this.assistantAvatarEnabled} .interrupts=${this._interruptDetails}></arcgis-assistant-message-loading></slot>`}</arcgis-assistant-chat></div>${this._interrupt ? g`<slot name=interrupt><arcgis-assistant-interrupt slot=content-bottom .type=${this._interrupt.type} .message=${this._interrupt.message} .options=${this._interrupt.options} ${E(this.#i)}></arcgis-assistant-interrupt></slot>` : this.suggestedPrompts?.length ? g`<div class="suggested-prompts-container" slot=content-bottom><arcgis-assistant-suggested-prompts class="suggested-prompts" .prompts=${this.suggestedPrompts}></arcgis-assistant-suggested-prompts></div>` : null}<div class="footer-container" slot=footer>${this._renderEntryMessage()}<slot name=chat-entry><arcgis-assistant-chat-entry .awaitingResponse=${this.awaitingResponse || this._isAnswering} .inputValue=${this._inputValue} .messages=${this.messages} .voiceInputEnabled=${this.voiceInputEnabled} .disabled=${this._canceling || !this._isSignedIn || !!this._interrupt || !!this._error} ${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=${() => {
|
|
571
583
|
this.#o.value?.submitMessage();
|
|
572
584
|
}} 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>`;
|
|
573
585
|
}
|
|
574
586
|
}
|
|
575
|
-
|
|
587
|
+
L("arcgis-assistant", et);
|
|
576
588
|
export {
|
|
577
589
|
et as ArcgisAssistant
|
|
578
590
|
};
|