@arcgis/ai-components 5.2.0-next.13 → 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.
- package/dist/cdn/{LREQ3XAW.js → 22IT5TDB.js} +2 -2
- package/dist/cdn/7PANDHIL.js +16 -0
- package/dist/cdn/{KWTJAVWV.js → GBYLKQIL.js} +1 -1
- package/dist/cdn/{55R6J3FL.js → I2Y67HBL.js} +1 -1
- package/dist/cdn/JG2BIENI.js +3 -0
- package/dist/cdn/{ET453NAD.js → L4XF4H6V.js} +1 -1
- package/dist/cdn/{SRSFESAD.js → QYR3NSF2.js} +3 -3
- package/dist/cdn/{CFVVQXPJ.js → S75VFYR4.js} +5 -5
- package/dist/cdn/{X2ZDYHCG.js → TNMXWUXU.js} +9 -4
- package/dist/cdn/{DSVMXDPZ.js → XU6NCSE2.js} +1 -1
- package/dist/cdn/agent-utils/index.js +1 -1
- package/dist/cdn/index.js +1 -1
- package/dist/chunks/adapter.js +1 -1
- package/dist/chunks/arcgisKnowledgeGraph.js +5 -5
- package/dist/chunks/dataExplorationGraph.js +85 -74
- package/dist/chunks/data_explore_query_prompt.js +9 -4
- package/dist/chunks/generateLayerDescriptions.js +106 -106
- package/dist/chunks/orchestrator.js +63 -63
- package/dist/components/arcgis-assistant/customElement.js +123 -117
- 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 +5 -5
- package/dist/cdn/MRLTR3UO.js +0 -16
- package/dist/cdn/SWBER53G.js +0 -3
|
@@ -1,58 +1,58 @@
|
|
|
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
|
|
6
|
-
import
|
|
7
|
-
import { LitElement as
|
|
8
|
-
import * as
|
|
9
|
-
import { rethrowError as
|
|
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";
|
|
10
10
|
import { createRef as _, ref as v } from "lit/directives/ref.js";
|
|
11
|
-
import { u as
|
|
12
|
-
import { O as
|
|
11
|
+
import { u as T } from "../../chunks/useT9n.js";
|
|
12
|
+
import { O as N } from "../../chunks/orchestrator.js";
|
|
13
13
|
import "@langchain/core/callbacks/dispatch/web";
|
|
14
14
|
import "@langchain/core/prompts";
|
|
15
15
|
import "@langchain/openai";
|
|
16
|
-
import
|
|
16
|
+
import z from "@arcgis/core/identity/IdentityManager.js";
|
|
17
17
|
import "@arcgis/toolkit/string";
|
|
18
18
|
import "@arcgis/core/config.js";
|
|
19
19
|
import "@langchain/core/messages";
|
|
20
20
|
import "@arcgis/core/layers/FeatureLayer.js";
|
|
21
21
|
import "../../chunks/generateLayerDescriptions.js";
|
|
22
22
|
import "@langchain/langgraph/web";
|
|
23
|
-
import
|
|
24
|
-
import { property as b, subclass as
|
|
25
|
-
import { g as
|
|
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";
|
|
26
26
|
import { g as w } from "../../chunks/slottableRequestUtils.js";
|
|
27
|
-
const q =
|
|
28
|
-
var H = Object.defineProperty, U = Object.getOwnPropertyDescriptor, m = (
|
|
29
|
-
for (var
|
|
30
|
-
(
|
|
31
|
-
return i &&
|
|
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;
|
|
32
32
|
};
|
|
33
|
-
const
|
|
34
|
-
async function*
|
|
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, {
|
|
35
35
|
chunkSize: t = 5,
|
|
36
36
|
// chars per "token"
|
|
37
37
|
delay: e = 20
|
|
38
38
|
// ms between chunks
|
|
39
39
|
} = {}) {
|
|
40
40
|
let i = 0;
|
|
41
|
-
for (; i <
|
|
42
|
-
yield
|
|
41
|
+
for (; i < o.length; )
|
|
42
|
+
yield o.slice(i, i + t), i += t, await F(e);
|
|
43
43
|
}
|
|
44
|
-
async function*
|
|
45
|
-
for await (const
|
|
44
|
+
async function* S(o, t, e, i) {
|
|
45
|
+
for await (const s of G(o)) {
|
|
46
46
|
if (i?.aborted) {
|
|
47
47
|
yield { type: "cancelled", log: e, runId: t };
|
|
48
48
|
return;
|
|
49
49
|
}
|
|
50
|
-
yield { type: "block-data", blockType: "text", data: { content:
|
|
50
|
+
yield { type: "block-data", blockType: "text", data: { content: s }, runId: t };
|
|
51
51
|
}
|
|
52
52
|
}
|
|
53
|
-
let d = class extends
|
|
54
|
-
constructor(
|
|
55
|
-
super(
|
|
53
|
+
let d = class extends B {
|
|
54
|
+
constructor(o) {
|
|
55
|
+
super(o), this.view = null, this.loading = !1, this.processing = !1, this.processingStep = "";
|
|
56
56
|
}
|
|
57
57
|
async load() {
|
|
58
58
|
this._set("loading", !0);
|
|
@@ -66,14 +66,14 @@ let d = class extends z {
|
|
|
66
66
|
this.orchestrator?.dispose(), super.destroy();
|
|
67
67
|
}
|
|
68
68
|
async _initialize() {
|
|
69
|
-
this.removeHandles(), await Promise.all([this.portal.load(), this.view?.when()]), this.view && await
|
|
69
|
+
this.removeHandles(), await Promise.all([this.portal.load(), this.view?.when()]), this.view && await A(() => !this.view.updating), this._set(
|
|
70
70
|
"orchestrator",
|
|
71
|
-
await
|
|
71
|
+
await N.init({
|
|
72
72
|
agents: [...this.agents],
|
|
73
73
|
view: this.view ?? void 0
|
|
74
74
|
})
|
|
75
75
|
), this.addHandles([
|
|
76
|
-
|
|
76
|
+
L(
|
|
77
77
|
() => [this.view, this.agents],
|
|
78
78
|
() => {
|
|
79
79
|
this._initialize();
|
|
@@ -84,30 +84,29 @@ let d = class extends z {
|
|
|
84
84
|
clearChatHistory() {
|
|
85
85
|
this.orchestrator?.newConversation();
|
|
86
86
|
}
|
|
87
|
-
async *ask(
|
|
87
|
+
async *ask(o, t) {
|
|
88
88
|
if (!this.orchestrator)
|
|
89
89
|
throw new Error("Orchestrator not initialized yet.");
|
|
90
90
|
this._set("processing", !0), this._set("processingStep", "");
|
|
91
91
|
const e = [];
|
|
92
|
-
let i;
|
|
92
|
+
let i, s = "pending";
|
|
93
93
|
try {
|
|
94
|
-
const
|
|
95
|
-
for await (const
|
|
96
|
-
|
|
97
|
-
switch (n.type) {
|
|
94
|
+
const l = this.orchestrator.ask(o);
|
|
95
|
+
for await (const r of l)
|
|
96
|
+
switch (s = r.runId, r.type) {
|
|
98
97
|
case "trace": {
|
|
99
|
-
this._set("processingStep",
|
|
98
|
+
this._set("processingStep", r.data.text), e.push(r.data.text);
|
|
100
99
|
break;
|
|
101
100
|
}
|
|
102
101
|
case "completed": {
|
|
103
102
|
this._set("processing", !1), this._set("processingStep", "");
|
|
104
|
-
const a =
|
|
105
|
-
if (!
|
|
103
|
+
const a = r.result, n = !!a.content.length, h = !!i?.length;
|
|
104
|
+
if (!n && !h) {
|
|
106
105
|
yield { type: "completed", error: "No response received.", log: e, runId: s };
|
|
107
106
|
return;
|
|
108
107
|
}
|
|
109
108
|
const g = a.content;
|
|
110
|
-
if (yield { type: "block-start", blockType: "text", runId: s }, yield*
|
|
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)
|
|
111
110
|
for (const f of i) {
|
|
112
111
|
if (t?.aborted) {
|
|
113
112
|
yield { type: "cancelled", log: e, runId: s };
|
|
@@ -115,8 +114,8 @@ let d = class extends z {
|
|
|
115
114
|
}
|
|
116
115
|
const { type: u, data: y } = f;
|
|
117
116
|
if (yield { type: "block-start", blockType: u, runId: s }, u === "text") {
|
|
118
|
-
const
|
|
119
|
-
yield*
|
|
117
|
+
const $ = typeof y?.content == "string" ? y.content : "";
|
|
118
|
+
yield* S($, s, e, t);
|
|
120
119
|
} else
|
|
121
120
|
yield { type: "block-data", blockType: u, data: y, runId: s };
|
|
122
121
|
yield { type: "block-end", blockType: u, runId: s };
|
|
@@ -125,23 +124,23 @@ let d = class extends z {
|
|
|
125
124
|
return;
|
|
126
125
|
}
|
|
127
126
|
case "ux-suggestion": {
|
|
128
|
-
const a =
|
|
127
|
+
const a = r.suggestion;
|
|
129
128
|
i = i ? [...i, a] : [a];
|
|
130
129
|
break;
|
|
131
130
|
}
|
|
132
131
|
case "interrupt": {
|
|
133
|
-
const { kind: a, message:
|
|
132
|
+
const { kind: a, message: n, metadata: h } = r.interrupt, g = Array.isArray(h) ? h.filter((u) => typeof u == "string") : [], f = (() => {
|
|
134
133
|
switch (a) {
|
|
135
134
|
case "booleanChoice":
|
|
136
|
-
return { type: "boolean-choice", message:
|
|
135
|
+
return { type: "boolean-choice", message: n, options: g };
|
|
137
136
|
case "singleSelection":
|
|
138
|
-
return { type: "single-select", message:
|
|
137
|
+
return { type: "single-select", message: n, options: g };
|
|
139
138
|
case "multipleSelection":
|
|
140
|
-
return { type: "multi-select", message:
|
|
139
|
+
return { type: "multi-select", message: n, options: g };
|
|
141
140
|
case "textInput":
|
|
142
|
-
return { type: "text-input", message:
|
|
141
|
+
return { type: "text-input", message: n };
|
|
143
142
|
default:
|
|
144
|
-
return { type: a, message:
|
|
143
|
+
return { type: a, message: n, options: g };
|
|
145
144
|
}
|
|
146
145
|
})();
|
|
147
146
|
this._set("processingStep", "Waiting for user input..."), yield { type: "interrupt", payload: f, runId: s };
|
|
@@ -152,17 +151,24 @@ let d = class extends z {
|
|
|
152
151
|
return;
|
|
153
152
|
}
|
|
154
153
|
case "error": {
|
|
155
|
-
|
|
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 };
|
|
156
159
|
return;
|
|
157
160
|
}
|
|
158
161
|
default: {
|
|
159
|
-
console.warn("Unknown event type:",
|
|
162
|
+
console.warn("Unknown event type:", r);
|
|
160
163
|
break;
|
|
161
164
|
}
|
|
162
165
|
}
|
|
166
|
+
} catch (l) {
|
|
167
|
+
if (t?.aborted || E(l)) {
|
|
168
|
+
yield { type: "cancelled", log: e, runId: s };
|
|
169
|
+
return;
|
|
163
170
|
}
|
|
164
|
-
|
|
165
|
-
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" };
|
|
166
172
|
return;
|
|
167
173
|
} finally {
|
|
168
174
|
this._set("processing", !1);
|
|
@@ -194,12 +200,12 @@ m([
|
|
|
194
200
|
b({ readOnly: !0 })
|
|
195
201
|
], d.prototype, "processingStep", 2);
|
|
196
202
|
d = m([
|
|
197
|
-
|
|
203
|
+
V("OrchestratorController")
|
|
198
204
|
], d);
|
|
199
|
-
const
|
|
200
|
-
class
|
|
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 {
|
|
201
207
|
constructor() {
|
|
202
|
-
super(...arguments), this._messages =
|
|
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) => {
|
|
203
209
|
t.stopPropagation(), this.cancelInterrupt();
|
|
204
210
|
}, this.#a = (t) => {
|
|
205
211
|
t.stopPropagation();
|
|
@@ -225,7 +231,7 @@ class J extends R {
|
|
|
225
231
|
this._inputValue = e.prompt, this.arcgisPromptSelect.emit(e);
|
|
226
232
|
}, this.#p = (t) => {
|
|
227
233
|
this.arcgisSlottableRequest.emit(t.detail);
|
|
228
|
-
}, this._orchestratorController = null, this._interrupt = null, this._interruptDetails = [], this._error = null, this._inputValue = "", this._isAnswering = !1, this._canceling = !1, this.messages = new
|
|
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();
|
|
229
235
|
}
|
|
230
236
|
static {
|
|
231
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 };
|
|
@@ -238,8 +244,8 @@ class J extends R {
|
|
|
238
244
|
#s;
|
|
239
245
|
#e;
|
|
240
246
|
#o;
|
|
241
|
-
#i;
|
|
242
247
|
#r;
|
|
248
|
+
#i;
|
|
243
249
|
#a;
|
|
244
250
|
#l;
|
|
245
251
|
#c;
|
|
@@ -248,23 +254,23 @@ class J extends R {
|
|
|
248
254
|
#p;
|
|
249
255
|
async #d() {
|
|
250
256
|
try {
|
|
251
|
-
const t =
|
|
257
|
+
const t = j(this.el, this.referenceElement);
|
|
252
258
|
await t?.componentOnReady();
|
|
253
259
|
const e = [...this.#o.values()];
|
|
254
260
|
return e.length ? (this._orchestratorController?.destroy(), this._orchestratorController = new d({
|
|
255
261
|
agents: e,
|
|
256
|
-
portal: this.#
|
|
262
|
+
portal: this.#r,
|
|
257
263
|
view: t?.view
|
|
258
264
|
}), await this._orchestratorController.load(), !0) : (this._error = "No agents found.", !1);
|
|
259
265
|
} catch (t) {
|
|
260
|
-
return this._error = t?.message ?? "Error initializing orchestrator.",
|
|
266
|
+
return this._error = t?.message ?? "Error initializing orchestrator.", D(this)(t), !1;
|
|
261
267
|
}
|
|
262
268
|
}
|
|
263
269
|
get _isSignedIn() {
|
|
264
|
-
return !!this.#
|
|
270
|
+
return !!this.#r?.user || !!this._signedInUserId;
|
|
265
271
|
}
|
|
266
272
|
get _user() {
|
|
267
|
-
return this.#
|
|
273
|
+
return this.#r?.user?.fullName || this.#r?.user?.username;
|
|
268
274
|
}
|
|
269
275
|
get awaitingResponse() {
|
|
270
276
|
return this._orchestratorController?.processing ?? !1;
|
|
@@ -298,81 +304,81 @@ class J extends R {
|
|
|
298
304
|
return;
|
|
299
305
|
this.#e = new AbortController();
|
|
300
306
|
const i = this._orchestratorController.ask(e, this.#e?.signal);
|
|
301
|
-
for await (const
|
|
302
|
-
const
|
|
303
|
-
switch (
|
|
307
|
+
for await (const s of i) {
|
|
308
|
+
const l = s.runId, r = this.messages.at(-1);
|
|
309
|
+
switch (s.type) {
|
|
304
310
|
case "block-start": {
|
|
305
311
|
this._isAnswering = !0;
|
|
306
|
-
const a = { type:
|
|
307
|
-
if (
|
|
308
|
-
const
|
|
309
|
-
this.messages.splice(-1, 1, { ...
|
|
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 });
|
|
310
316
|
} else
|
|
311
317
|
this.messages.push({
|
|
312
318
|
role: "assistant",
|
|
313
319
|
blocks: [a],
|
|
314
|
-
id:
|
|
320
|
+
id: l,
|
|
315
321
|
isStreaming: !0,
|
|
316
322
|
interrupts: this._interruptDetails
|
|
317
323
|
}), this._interruptDetails = [];
|
|
318
324
|
break;
|
|
319
325
|
}
|
|
320
326
|
case "block-data": {
|
|
321
|
-
if (
|
|
327
|
+
if (r?.role !== "assistant" || r?.id !== l)
|
|
322
328
|
break;
|
|
323
|
-
const a = [...
|
|
324
|
-
if (
|
|
329
|
+
const a = [...r.blocks ?? []], n = a[a.length - 1], { blockType: h, data: g } = s;
|
|
330
|
+
if (n?.type !== h || !n.isPending)
|
|
325
331
|
break;
|
|
326
332
|
if (h === "text") {
|
|
327
|
-
const f = typeof
|
|
328
|
-
a[a.length - 1] = { ...
|
|
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 } };
|
|
329
335
|
} else
|
|
330
|
-
a[a.length - 1] = { ...
|
|
331
|
-
this.messages.splice(-1, 1, { ...
|
|
336
|
+
a[a.length - 1] = { ...n, data: { ...n.data, ...g ?? {} } };
|
|
337
|
+
this.messages.splice(-1, 1, { ...r, blocks: a });
|
|
332
338
|
break;
|
|
333
339
|
}
|
|
334
340
|
case "block-end": {
|
|
335
|
-
if (
|
|
341
|
+
if (r?.role !== "assistant" || r?.id !== l)
|
|
336
342
|
break;
|
|
337
|
-
const a = [...
|
|
338
|
-
if (
|
|
343
|
+
const a = [...r.blocks ?? []], n = a[a.length - 1];
|
|
344
|
+
if (n?.type !== s.blockType || !n.isPending)
|
|
339
345
|
break;
|
|
340
|
-
const h =
|
|
341
|
-
a[a.length - 1] = { ...h, data: { ...h.data }, isPending: !1 }, this.messages.splice(-1, 1, { ...
|
|
346
|
+
const h = n;
|
|
347
|
+
a[a.length - 1] = { ...h, data: { ...h.data }, isPending: !1 }, this.messages.splice(-1, 1, { ...r, blocks: a });
|
|
342
348
|
break;
|
|
343
349
|
}
|
|
344
350
|
case "completed":
|
|
345
|
-
|
|
351
|
+
s.error ? (this.messages.push({
|
|
346
352
|
role: "assistant",
|
|
347
|
-
log:
|
|
348
|
-
error:
|
|
349
|
-
id:
|
|
353
|
+
log: s.log,
|
|
354
|
+
error: s.error,
|
|
355
|
+
id: l,
|
|
350
356
|
interrupts: this._interruptDetails
|
|
351
|
-
}), this._interruptDetails = []) :
|
|
352
|
-
...
|
|
353
|
-
content:
|
|
354
|
-
blocks:
|
|
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 })) ?? [],
|
|
355
361
|
isStreaming: !1,
|
|
356
|
-
log:
|
|
362
|
+
log: s.log
|
|
357
363
|
}), this._isAnswering = !1, this.#e = null, this._canceling = !1;
|
|
358
364
|
break;
|
|
359
365
|
case "interrupt":
|
|
360
|
-
this._interrupt = { ...
|
|
366
|
+
this._interrupt = { ...s.payload, id: l }, this.arcgisInterrupt.emit(this._interrupt);
|
|
361
367
|
break;
|
|
362
368
|
case "cancelled":
|
|
363
|
-
|
|
364
|
-
...
|
|
365
|
-
blocks:
|
|
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) ?? [],
|
|
366
372
|
isStreaming: !1,
|
|
367
|
-
log:
|
|
373
|
+
log: s.log,
|
|
368
374
|
error: "(Stopped by user)"
|
|
369
375
|
// TODO: use strings from t9n
|
|
370
376
|
}) : (this.messages.push({
|
|
371
377
|
role: "assistant",
|
|
372
|
-
log:
|
|
378
|
+
log: s.log,
|
|
373
379
|
error: "(Stopped by user)",
|
|
374
380
|
// TODO: use strings from t9n
|
|
375
|
-
id:
|
|
381
|
+
id: l,
|
|
376
382
|
interrupts: this._interruptDetails
|
|
377
383
|
}), this._interruptDetails = []), this._isAnswering = !1, this.#e = null, this._canceling = !1;
|
|
378
384
|
break;
|
|
@@ -388,19 +394,19 @@ class J extends R {
|
|
|
388
394
|
loaded() {
|
|
389
395
|
this.manager.onLifecycle(() => {
|
|
390
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);
|
|
391
|
-
const t =
|
|
397
|
+
const t = x(() => !!this._interrupt && !!this.#s.value, () => {
|
|
392
398
|
const i = this.#s.value;
|
|
393
|
-
i.removeEventListener("arcgisSubmit", this.#a), i.removeEventListener("arcgisCancel", this.#
|
|
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 });
|
|
394
400
|
}), e = this.messages.on("after-add", (i) => {
|
|
395
|
-
const
|
|
396
|
-
|
|
401
|
+
const s = i.item;
|
|
402
|
+
s.role === "assistant" && (s.error || s.content) && this.arcgisResponse.emit(s);
|
|
397
403
|
});
|
|
398
404
|
return queueMicrotask(() => {
|
|
399
405
|
this.#d().then((i) => {
|
|
400
406
|
i ? this.arcgisReady.emit() : this._error && this.arcgisError.emit(new Error(this._error));
|
|
401
407
|
});
|
|
402
408
|
}), () => {
|
|
403
|
-
t.remove(), e.remove(), this.#t.value?.removeEventListener("arcgisPromptSelect", this.#g), this.#s.value?.removeEventListener("arcgisSubmit", this.#a), this.#s.value?.removeEventListener("arcgisCancel", this.#
|
|
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;
|
|
404
410
|
};
|
|
405
411
|
});
|
|
406
412
|
}
|
|
@@ -408,29 +414,29 @@ class J extends R {
|
|
|
408
414
|
this._orchestratorController?.cancel(), this.#e?.abort(), this._interrupt = null, this.messages.removeAll(), this._error = null, this._inputValue = "", this._signedInUserId = void 0;
|
|
409
415
|
}
|
|
410
416
|
_renderEntryMessage() {
|
|
411
|
-
return this._isSignedIn ? this._error ? this._renderErrorNotice() : this.entryMessage ? this.messages.length > 0 ? null :
|
|
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();
|
|
412
418
|
}
|
|
413
419
|
_renderSignInNotice() {
|
|
414
|
-
const t = this.#
|
|
415
|
-
return
|
|
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 () => {
|
|
416
422
|
try {
|
|
417
|
-
const e = await
|
|
423
|
+
const e = await z.getCredential(`${t.url}/sharing`);
|
|
418
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));
|
|
419
425
|
} catch (e) {
|
|
420
|
-
this._error = e?.message ?? "Error signing in.", this.arcgisError.emit(new Error(this._error)),
|
|
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 } });
|
|
421
427
|
}
|
|
422
|
-
}} target=_blank title="Sign in to ArcGIS Online">Sign in</calcite-link>` :
|
|
428
|
+
}} target=_blank title="Sign in to ArcGIS Online">Sign in</calcite-link>` : c`<div slot=link>No portal information available</div>`}</calcite-notice>`;
|
|
423
429
|
}
|
|
424
430
|
_renderErrorNotice() {
|
|
425
|
-
return this._error ?
|
|
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;
|
|
426
432
|
}
|
|
427
433
|
render() {
|
|
428
|
-
return
|
|
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=${() => {
|
|
429
435
|
this.#n.value?.submitMessage();
|
|
430
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>`;
|
|
431
437
|
}
|
|
432
438
|
}
|
|
433
|
-
|
|
439
|
+
I("arcgis-assistant", K);
|
|
434
440
|
export {
|
|
435
|
-
|
|
441
|
+
K as ArcgisAssistant
|
|
436
442
|
};
|