@arcgis/ai-components 5.2.0-next.93 → 5.2.0-next.94
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/{W5JPJWMM.js → 2FYVIMRW.js} +1 -1
- package/dist/cdn/{C5ZL5Z52.js → 2OB6I4ZG.js} +1 -1
- package/dist/cdn/{LPR72QZF.js → 6KN5LUAV.js} +1 -1
- package/dist/cdn/{OWTGH34K.js → 7VUSIGEM.js} +1 -1
- package/dist/cdn/{VNJMTA6O.js → ANRQWYU2.js} +1 -1
- package/dist/cdn/{HKSFWTWK.js → ASR3I43T.js} +1 -1
- package/dist/cdn/{ZVGUAOXE.js → B2JDVLA6.js} +1 -1
- package/dist/cdn/{DP6O6PMH.js → B2O2LAEL.js} +1 -1
- package/dist/cdn/{JJJZ7FOM.js → CPYR4ZQP.js} +1 -1
- package/dist/cdn/{AT4XVTJR.js → D5UFYQHN.js} +1 -1
- package/dist/cdn/{HMUWQCXU.js → FG647IP6.js} +1 -1
- package/dist/cdn/{6KFMRBAA.js → FUF3NAU7.js} +1 -1
- package/dist/cdn/G2EGT3CF.js +6 -0
- package/dist/cdn/{PEYYWXFE.js → G7OMHU2B.js} +1 -1
- package/dist/cdn/{OL5656NI.js → HAEFC2SJ.js} +1 -1
- package/dist/cdn/{ZQMBJ6MI.js → HDACNIZF.js} +1 -1
- package/dist/cdn/JCOA24UH.js +3 -0
- package/dist/cdn/{SUYWKYWI.js → LNCT4S4I.js} +1 -1
- package/dist/cdn/{OYSPNIJI.js → MX7OEO5Z.js} +1 -1
- package/dist/cdn/{PSYRZMX2.js → NZSOJ726.js} +1 -1
- package/dist/cdn/{4HDDRBIY.js → OE3GW5LE.js} +1 -1
- package/dist/cdn/{ZLWWWTH4.js → R2PQVY4O.js} +1 -1
- package/dist/cdn/{COL6QYGQ.js → RJMPDAE6.js} +1 -1
- package/dist/cdn/{4EBLRHYE.js → RWQOM6TX.js} +1 -1
- package/dist/cdn/{FQH3HOFH.js → TFIJZWY3.js} +1 -1
- package/dist/cdn/{FUZ77UGP.js → UAANWCMU.js} +1 -1
- package/dist/cdn/UK3MKESF.js +3 -0
- package/dist/cdn/{KCU4FWF7.js → VOV5D2HS.js} +1 -1
- package/dist/cdn/{WP7ORLSB.js → WGO5SER7.js} +1 -1
- package/dist/cdn/{4NJ2FF7H.js → ZDV4K4WG.js} +1 -1
- package/dist/cdn/agent-utils/index.js +1 -1
- package/dist/cdn/index.js +1 -1
- package/dist/chunks/baseAgentState.js +32 -30
- package/dist/chunks/orchestrator.js +301 -249
- package/dist/components/arcgis-assistant/customElement.d.ts +24 -0
- package/dist/components/arcgis-assistant/customElement.js +275 -270
- package/dist/docs/api.json +1 -1
- package/dist/docs/docs.json +1 -1
- package/dist/docs/vscode.html-custom-data.json +1 -1
- package/dist/docs/web-types.json +1 -1
- package/dist/loader.js +1 -1
- package/dist/types/lumina.d.ts +1 -1
- package/dist/types/preact.d.ts +1 -1
- package/dist/types/react.d.ts +1 -1
- package/dist/types/stencil.d.ts +1 -1
- package/dist/utils/index.d.ts +45 -11
- package/package.json +5 -5
- package/dist/cdn/6VJXUIXY.js +0 -3
- package/dist/cdn/7M6VKBTK.js +0 -6
- package/dist/cdn/PKUDO2RC.js +0 -3
|
@@ -1,76 +1,76 @@
|
|
|
1
1
|
/* COPYRIGHT Esri - https://js.arcgis.com/5.2/LICENSE.txt */
|
|
2
2
|
import { c as x } from "../../chunks/runtime.js";
|
|
3
|
-
import { css as
|
|
4
|
-
import
|
|
5
|
-
import { whenOnce as
|
|
6
|
-
import
|
|
7
|
-
import { LitElement as
|
|
3
|
+
import { css as L, html as g } from "lit";
|
|
4
|
+
import T from "@arcgis/core/core/Collection.js";
|
|
5
|
+
import { whenOnce as R, watch as D, when as M } from "@arcgis/core/core/reactiveUtils.js";
|
|
6
|
+
import O from "@arcgis/core/portal/Portal.js";
|
|
7
|
+
import { LitElement as U, createEvent as d, nothing as _ } from "@arcgis/lumina";
|
|
8
8
|
import * as B from "@arcgis/toolkit/log";
|
|
9
9
|
import { rethrowError as z } from "@arcgis/toolkit/log";
|
|
10
|
-
import { createRef as
|
|
11
|
-
import { u as
|
|
12
|
-
import { O as
|
|
10
|
+
import { createRef as w, ref as k } from "lit/directives/ref.js";
|
|
11
|
+
import { u as q } 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
16
|
import "@arcgis/core/request.js";
|
|
17
|
-
import
|
|
17
|
+
import V 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
|
|
26
|
-
import { marked as
|
|
27
|
-
import { g as
|
|
28
|
-
import { g as
|
|
29
|
-
const
|
|
30
|
-
function
|
|
31
|
-
return o.trim() ?
|
|
24
|
+
import F from "@arcgis/core/core/Accessor.js";
|
|
25
|
+
import { property as b, subclass as j } from "@arcgis/core/core/accessorSupport/decorators.js";
|
|
26
|
+
import { marked as $ } from "marked";
|
|
27
|
+
import { g as H } from "../../chunks/utils3.js";
|
|
28
|
+
import { g as I } from "../../chunks/slottableRequestUtils.js";
|
|
29
|
+
const W = L`: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 E(o) {
|
|
31
|
+
return o.trim() ? $.lexer(o).filter((t) => t.type !== "space").map((t) => $.parser([t])) : [];
|
|
32
32
|
}
|
|
33
|
-
class
|
|
33
|
+
class A {
|
|
34
34
|
constructor() {
|
|
35
35
|
this._stableParts = [], this._stableText = "", this._rawText = "";
|
|
36
36
|
}
|
|
37
37
|
// full streamed markdown so far
|
|
38
38
|
// Add one chunk and return all current segments.
|
|
39
|
-
push(
|
|
40
|
-
return this._rawText +=
|
|
39
|
+
push(t) {
|
|
40
|
+
return this._rawText += t, this._advanceStableBoundary(), this.getParts();
|
|
41
41
|
}
|
|
42
42
|
// Parse the remaining live tail. Call once at stream end.
|
|
43
43
|
finalize() {
|
|
44
|
-
const
|
|
45
|
-
return
|
|
44
|
+
const t = this._rawText.slice(this._stableText.length);
|
|
45
|
+
return t.trim() && (this._stableParts.push(...E(t)), this._stableText = this._rawText), this._stableParts;
|
|
46
46
|
}
|
|
47
47
|
// Get full output: stable segments + current live tail.
|
|
48
48
|
getParts() {
|
|
49
|
-
const
|
|
50
|
-
return [...this._stableParts, ...
|
|
49
|
+
const t = this._trimIncompleteTail(this._rawText.slice(this._stableText.length)), e = t.trim() ? E(t) : [];
|
|
50
|
+
return [...this._stableParts, ...e];
|
|
51
51
|
}
|
|
52
52
|
reset() {
|
|
53
53
|
this._stableParts = [], this._stableText = "", this._rawText = "";
|
|
54
54
|
}
|
|
55
55
|
// Move parse-safe content from live tail into stable content.
|
|
56
56
|
_advanceStableBoundary() {
|
|
57
|
-
const
|
|
58
|
-
if (
|
|
57
|
+
const t = this._rawText.slice(this._stableText.length), e = this._lastSafeBoundary(t);
|
|
58
|
+
if (e <= 0)
|
|
59
59
|
return;
|
|
60
|
-
const i =
|
|
61
|
-
this._stableParts.push(...
|
|
60
|
+
const i = t.slice(0, e);
|
|
61
|
+
this._stableParts.push(...E(i)), this._stableText += i;
|
|
62
62
|
}
|
|
63
63
|
/**
|
|
64
64
|
* Find the last blank-line boundary that is outside code fences.
|
|
65
65
|
* Returns 0 if no safe boundary is available yet.
|
|
66
66
|
*/
|
|
67
|
-
_lastSafeBoundary(
|
|
68
|
-
const
|
|
67
|
+
_lastSafeBoundary(t) {
|
|
68
|
+
const e = t.split(`
|
|
69
69
|
`);
|
|
70
|
-
let i = !1,
|
|
71
|
-
for (const
|
|
72
|
-
/^\s*(```|~~~)/u.test(
|
|
73
|
-
return
|
|
70
|
+
let i = !1, r = 0, s = 0;
|
|
71
|
+
for (const l of e)
|
|
72
|
+
/^\s*(```|~~~)/u.test(l) && (i = !i), s += l.length + 1, l.trim() === "" && !i && (r = s);
|
|
73
|
+
return r < t.length ? r : 0;
|
|
74
74
|
}
|
|
75
75
|
/**
|
|
76
76
|
* Remove incomplete syntax at the end so we do not render partial markup.
|
|
@@ -79,27 +79,27 @@ class C {
|
|
|
79
79
|
* - HTML elements missing closing tags
|
|
80
80
|
* - markdown links missing closing ')'
|
|
81
81
|
*/
|
|
82
|
-
_trimIncompleteTail(
|
|
83
|
-
const
|
|
84
|
-
if (
|
|
85
|
-
return
|
|
86
|
-
const i = this._earliestUnclosedTag(
|
|
82
|
+
_trimIncompleteTail(t) {
|
|
83
|
+
const e = t.lastIndexOf("<");
|
|
84
|
+
if (e !== -1 && !t.includes(">", e))
|
|
85
|
+
return t.slice(0, e);
|
|
86
|
+
const i = this._earliestUnclosedTag(t);
|
|
87
87
|
if (i !== -1)
|
|
88
|
-
return
|
|
89
|
-
const
|
|
90
|
-
if (
|
|
91
|
-
const
|
|
92
|
-
if (!/\[[^\]]*\]\([^)]*\)/u.test(
|
|
93
|
-
return
|
|
88
|
+
return t.slice(0, i);
|
|
89
|
+
const r = t.lastIndexOf("[");
|
|
90
|
+
if (r !== -1) {
|
|
91
|
+
const s = t.slice(r);
|
|
92
|
+
if (!/\[[^\]]*\]\([^)]*\)/u.test(s))
|
|
93
|
+
return t.slice(0, r);
|
|
94
94
|
}
|
|
95
|
-
return
|
|
95
|
+
return t;
|
|
96
96
|
}
|
|
97
97
|
/**
|
|
98
98
|
* Return the index of the earliest unclosed opening tag, or -1.
|
|
99
99
|
* Ignores void elements (img, br, input, etc.) and self-closing tags.
|
|
100
100
|
*/
|
|
101
|
-
_earliestUnclosedTag(
|
|
102
|
-
const
|
|
101
|
+
_earliestUnclosedTag(t) {
|
|
102
|
+
const e = /* @__PURE__ */ new Set([
|
|
103
103
|
"br",
|
|
104
104
|
"img",
|
|
105
105
|
"hr",
|
|
@@ -113,57 +113,57 @@ class C {
|
|
|
113
113
|
"source",
|
|
114
114
|
"track",
|
|
115
115
|
"wbr"
|
|
116
|
-
]), i = /<(\/?)([a-zA-Z][\w-]*)\b[^>]*?(\/?)>/gu,
|
|
117
|
-
for (let
|
|
118
|
-
const [,
|
|
119
|
-
if (!(
|
|
120
|
-
if (
|
|
121
|
-
for (let
|
|
122
|
-
if (
|
|
123
|
-
|
|
116
|
+
]), i = /<(\/?)([a-zA-Z][\w-]*)\b[^>]*?(\/?)>/gu, r = [];
|
|
117
|
+
for (let s = i.exec(t); s; s = i.exec(t)) {
|
|
118
|
+
const [, l, a, n] = s, c = a.toLowerCase();
|
|
119
|
+
if (!(e.has(c) || n === "/"))
|
|
120
|
+
if (l === "/") {
|
|
121
|
+
for (let h = r.length - 1; h >= 0; h--)
|
|
122
|
+
if (r[h].name === c) {
|
|
123
|
+
r.splice(h);
|
|
124
124
|
break;
|
|
125
125
|
}
|
|
126
126
|
} else
|
|
127
|
-
|
|
127
|
+
r.push({ name: c, index: s.index });
|
|
128
128
|
}
|
|
129
|
-
return
|
|
129
|
+
return r.length ? r[0].index : -1;
|
|
130
130
|
}
|
|
131
131
|
}
|
|
132
|
-
function
|
|
133
|
-
const
|
|
134
|
-
return
|
|
132
|
+
function G(o) {
|
|
133
|
+
const t = new A();
|
|
134
|
+
return t.push(o), t.finalize();
|
|
135
135
|
}
|
|
136
|
-
const
|
|
137
|
-
async function*
|
|
138
|
-
const i = new
|
|
139
|
-
for (let
|
|
140
|
-
yield i.push(o.slice(
|
|
136
|
+
const Z = async (o) => await new Promise((t) => setTimeout(t, o));
|
|
137
|
+
async function* J(o, { chunkSize: t = 15, delay: e = 50 } = {}) {
|
|
138
|
+
const i = new A();
|
|
139
|
+
for (let r = 0; r < o.length; r += t)
|
|
140
|
+
yield i.push(o.slice(r, r + t)), await Z(e);
|
|
141
141
|
yield i.finalize();
|
|
142
142
|
}
|
|
143
|
-
var
|
|
144
|
-
for (var
|
|
145
|
-
(
|
|
146
|
-
return i &&
|
|
143
|
+
var K = Object.defineProperty, Q = Object.getOwnPropertyDescriptor, m = (o, t, e, i) => {
|
|
144
|
+
for (var r = i > 1 ? void 0 : i ? Q(t, e) : t, s = o.length - 1, l; s >= 0; s--)
|
|
145
|
+
(l = o[s]) && (r = (i ? l(t, e, r) : l(r)) || r);
|
|
146
|
+
return i && r && K(t, e, r), r;
|
|
147
147
|
};
|
|
148
148
|
const S = (o) => !o || typeof o != "object" ? !1 : o.name === "AbortError";
|
|
149
|
-
async function*
|
|
150
|
-
if (
|
|
149
|
+
async function* C(o, t, e, i, r = !1) {
|
|
150
|
+
if (r) {
|
|
151
151
|
if (i?.aborted) {
|
|
152
|
-
yield { type: "cancelled", log:
|
|
152
|
+
yield { type: "cancelled", log: e, runId: t };
|
|
153
153
|
return;
|
|
154
154
|
}
|
|
155
|
-
yield { type: "block-data", blockType: "text", data: { parts:
|
|
155
|
+
yield { type: "block-data", blockType: "text", data: { parts: G(o) }, runId: t };
|
|
156
156
|
return;
|
|
157
157
|
}
|
|
158
|
-
for await (const
|
|
158
|
+
for await (const s of J(o)) {
|
|
159
159
|
if (i?.aborted) {
|
|
160
|
-
yield { type: "cancelled", log:
|
|
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: s }, runId: t };
|
|
164
164
|
}
|
|
165
165
|
}
|
|
166
|
-
let
|
|
166
|
+
let p = class extends F {
|
|
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
|
}
|
|
@@ -179,15 +179,15 @@ let d = class extends V {
|
|
|
179
179
|
this.orchestrator?.dispose(), super.destroy();
|
|
180
180
|
}
|
|
181
181
|
async _initialize() {
|
|
182
|
-
this.removeHandles(), await Promise.all([this.portal.load(), this.view?.when()]), this.view && await
|
|
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 N.init({
|
|
185
185
|
agents: [...this.agents],
|
|
186
186
|
runtimeEventsEnabled: this.runtimeEventsEnabled,
|
|
187
187
|
view: this.view ?? void 0
|
|
188
188
|
})
|
|
189
189
|
), this.addHandles([
|
|
190
|
-
|
|
190
|
+
D(
|
|
191
191
|
() => [this.view, this.agents],
|
|
192
192
|
() => {
|
|
193
193
|
this._initialize();
|
|
@@ -198,95 +198,95 @@ let d = class extends V {
|
|
|
198
198
|
clearChatHistory() {
|
|
199
199
|
this.orchestrator?.newConversation();
|
|
200
200
|
}
|
|
201
|
-
async *ask(o, e) {
|
|
201
|
+
async *ask(o, t, e) {
|
|
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
|
|
205
|
+
const i = [];
|
|
206
|
+
let r, s = "pending";
|
|
207
207
|
try {
|
|
208
|
-
const
|
|
209
|
-
for await (const
|
|
210
|
-
switch (
|
|
208
|
+
const l = this.orchestrator.ask(o, t);
|
|
209
|
+
for await (const a of l)
|
|
210
|
+
switch (s = a.runId, a.type) {
|
|
211
211
|
case "runtime": {
|
|
212
|
-
yield { type: "runtime", event:
|
|
212
|
+
yield { type: "runtime", event: a, runId: s };
|
|
213
213
|
break;
|
|
214
214
|
}
|
|
215
215
|
case "trace": {
|
|
216
|
-
this._set("processingStep",
|
|
216
|
+
this._set("processingStep", a.data.text), i.push(a.data.text);
|
|
217
217
|
break;
|
|
218
218
|
}
|
|
219
219
|
case "completed": {
|
|
220
220
|
this._set("processing", !1), this._set("processingStep", "");
|
|
221
|
-
const
|
|
222
|
-
if (!
|
|
223
|
-
yield { type: "completed", error: "No response received.", log:
|
|
221
|
+
const n = a.result, c = !!n.content.length, h = !!r?.length;
|
|
222
|
+
if (!c && !h) {
|
|
223
|
+
yield { type: "completed", error: "No response received.", log: i, runId: s };
|
|
224
224
|
return;
|
|
225
225
|
}
|
|
226
|
-
const
|
|
227
|
-
if (yield { type: "block-start", blockType: "text", runId:
|
|
228
|
-
for (const
|
|
226
|
+
const u = n.content;
|
|
227
|
+
if (yield { type: "block-start", blockType: "text", runId: s }, yield* C(u, s, i, e, this.streamingDisabled), yield { type: "block-end", blockType: "text", runId: s }, h)
|
|
228
|
+
for (const y of r) {
|
|
229
229
|
if (e?.aborted) {
|
|
230
|
-
yield { type: "cancelled", log:
|
|
230
|
+
yield { type: "cancelled", log: i, runId: s };
|
|
231
231
|
return;
|
|
232
232
|
}
|
|
233
|
-
const { type:
|
|
234
|
-
if (yield { type: "block-start", blockType:
|
|
235
|
-
const P = typeof
|
|
236
|
-
yield*
|
|
233
|
+
const { type: f, data: v } = y;
|
|
234
|
+
if (yield { type: "block-start", blockType: f, runId: s }, f === "text") {
|
|
235
|
+
const P = typeof v?.content == "string" ? v.content : "";
|
|
236
|
+
yield* C(P, s, i, e, this.streamingDisabled);
|
|
237
237
|
} else
|
|
238
|
-
yield { type: "block-data", blockType:
|
|
239
|
-
yield { type: "block-end", blockType:
|
|
238
|
+
yield { type: "block-data", blockType: f, data: v, runId: s };
|
|
239
|
+
yield { type: "block-end", blockType: f, runId: s };
|
|
240
240
|
}
|
|
241
|
-
yield { type: "completed", response:
|
|
241
|
+
yield { type: "completed", response: u, blocks: r, log: i, runId: s };
|
|
242
242
|
return;
|
|
243
243
|
}
|
|
244
244
|
case "ux-suggestion": {
|
|
245
|
-
const
|
|
246
|
-
|
|
245
|
+
const n = a.suggestion;
|
|
246
|
+
r = r ? [...r, n] : [n];
|
|
247
247
|
break;
|
|
248
248
|
}
|
|
249
249
|
case "interrupt": {
|
|
250
|
-
const { kind:
|
|
251
|
-
switch (
|
|
250
|
+
const { kind: n, message: c, metadata: h } = a.interrupt, u = Array.isArray(h) ? h.filter((f) => typeof f == "string") : [], y = (() => {
|
|
251
|
+
switch (n) {
|
|
252
252
|
case "booleanChoice":
|
|
253
|
-
return { type: "boolean-choice", message:
|
|
253
|
+
return { type: "boolean-choice", message: c, options: u };
|
|
254
254
|
case "singleSelection":
|
|
255
|
-
return { type: "single-select", message:
|
|
255
|
+
return { type: "single-select", message: c, options: u };
|
|
256
256
|
case "multipleSelection":
|
|
257
|
-
return { type: "multi-select", message:
|
|
257
|
+
return { type: "multi-select", message: c, options: u };
|
|
258
258
|
case "textInput":
|
|
259
|
-
return { type: "text-input", message:
|
|
259
|
+
return { type: "text-input", message: c };
|
|
260
260
|
default:
|
|
261
|
-
return { type:
|
|
261
|
+
return { type: n, message: c, options: u };
|
|
262
262
|
}
|
|
263
263
|
})();
|
|
264
|
-
this._set("processingStep", "Waiting for user input..."), yield { type: "interrupt", payload:
|
|
264
|
+
this._set("processingStep", "Waiting for user input..."), yield { type: "interrupt", payload: y, runId: s };
|
|
265
265
|
break;
|
|
266
266
|
}
|
|
267
267
|
case "cancelled": {
|
|
268
|
-
yield { type: "cancelled", log:
|
|
268
|
+
yield { type: "cancelled", log: i, runId: s };
|
|
269
269
|
return;
|
|
270
270
|
}
|
|
271
271
|
case "error": {
|
|
272
|
-
if (e?.aborted || S(
|
|
273
|
-
yield { type: "cancelled", log:
|
|
272
|
+
if (e?.aborted || S(a.error)) {
|
|
273
|
+
yield { type: "cancelled", log: i, runId: s };
|
|
274
274
|
return;
|
|
275
275
|
}
|
|
276
|
-
yield { type: "completed", error:
|
|
276
|
+
yield { type: "completed", error: a.error.message, log: i, runId: s };
|
|
277
277
|
return;
|
|
278
278
|
}
|
|
279
279
|
default: {
|
|
280
|
-
console.warn("Unknown event type:",
|
|
280
|
+
console.warn("Unknown event type:", a);
|
|
281
281
|
break;
|
|
282
282
|
}
|
|
283
283
|
}
|
|
284
|
-
} catch (
|
|
285
|
-
if (e?.aborted || S(
|
|
286
|
-
yield { type: "cancelled", log:
|
|
284
|
+
} catch (l) {
|
|
285
|
+
if (e?.aborted || S(l)) {
|
|
286
|
+
yield { type: "cancelled", log: i, runId: s };
|
|
287
287
|
return;
|
|
288
288
|
}
|
|
289
|
-
console.warn("Error during message processing:",
|
|
289
|
+
console.warn("Error during message processing:", l), yield { type: "completed", error: "An error occurred during message processing.", log: i, runId: "error" };
|
|
290
290
|
return;
|
|
291
291
|
} finally {
|
|
292
292
|
this._set("processing", !1);
|
|
@@ -296,86 +296,86 @@ let d = class extends V {
|
|
|
296
296
|
this.orchestrator?.cancel();
|
|
297
297
|
}
|
|
298
298
|
};
|
|
299
|
-
|
|
300
|
-
|
|
301
|
-
],
|
|
302
|
-
|
|
303
|
-
|
|
304
|
-
],
|
|
305
|
-
|
|
306
|
-
|
|
307
|
-
],
|
|
308
|
-
|
|
309
|
-
|
|
310
|
-
],
|
|
311
|
-
|
|
312
|
-
|
|
313
|
-
],
|
|
314
|
-
|
|
315
|
-
|
|
316
|
-
],
|
|
317
|
-
|
|
318
|
-
|
|
319
|
-
],
|
|
320
|
-
|
|
321
|
-
|
|
322
|
-
],
|
|
323
|
-
|
|
324
|
-
|
|
325
|
-
],
|
|
326
|
-
|
|
327
|
-
|
|
328
|
-
],
|
|
329
|
-
const
|
|
330
|
-
class
|
|
299
|
+
m([
|
|
300
|
+
b({ readOnly: !0 })
|
|
301
|
+
], p.prototype, "orchestrator", 2);
|
|
302
|
+
m([
|
|
303
|
+
b()
|
|
304
|
+
], p.prototype, "agents", 2);
|
|
305
|
+
m([
|
|
306
|
+
b()
|
|
307
|
+
], p.prototype, "portal", 2);
|
|
308
|
+
m([
|
|
309
|
+
b()
|
|
310
|
+
], p.prototype, "view", 2);
|
|
311
|
+
m([
|
|
312
|
+
b()
|
|
313
|
+
], p.prototype, "streamingDisabled", 2);
|
|
314
|
+
m([
|
|
315
|
+
b()
|
|
316
|
+
], p.prototype, "runtimeEventsEnabled", 2);
|
|
317
|
+
m([
|
|
318
|
+
b({ readOnly: !0 })
|
|
319
|
+
], p.prototype, "loading", 2);
|
|
320
|
+
m([
|
|
321
|
+
b({ readOnly: !0 })
|
|
322
|
+
], p.prototype, "processing", 2);
|
|
323
|
+
m([
|
|
324
|
+
b({ readOnly: !0 })
|
|
325
|
+
], p.prototype, "processingStep", 2);
|
|
326
|
+
p = m([
|
|
327
|
+
j("OrchestratorController")
|
|
328
|
+
], p);
|
|
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 U {
|
|
331
331
|
constructor() {
|
|
332
|
-
super(...arguments), this._messages =
|
|
333
|
-
|
|
334
|
-
}, this.#n = (
|
|
335
|
-
|
|
336
|
-
const
|
|
337
|
-
this.submitInterrupt(
|
|
338
|
-
}, this.#
|
|
339
|
-
|
|
340
|
-
const
|
|
341
|
-
this._inputValue = "", this.arcgisSubmit.emit(
|
|
342
|
-
}, this.#
|
|
343
|
-
if (this._canceling = !0,
|
|
332
|
+
super(...arguments), this._messages = q({ blocking: !0 }), this.#t = w(), this.#o = w(), this.#s = w(), this.#e = null, this.#r = /* @__PURE__ */ new Map(), this.#i = O.getDefault(), this.#a = (t) => {
|
|
333
|
+
t.stopPropagation(), this.cancelInterrupt();
|
|
334
|
+
}, this.#n = (t) => {
|
|
335
|
+
t.stopPropagation();
|
|
336
|
+
const e = t.detail;
|
|
337
|
+
this.submitInterrupt(e);
|
|
338
|
+
}, this.#l = (t) => {
|
|
339
|
+
t.stopPropagation(), this.keepSuggestedPrompts || (this.suggestedPrompts = []);
|
|
340
|
+
const e = t.detail;
|
|
341
|
+
this._inputValue = "", this.arcgisSubmit.emit(e), this.submitMessage(e);
|
|
342
|
+
}, this.#c = (t) => {
|
|
343
|
+
if (this._canceling = !0, t.stopPropagation(), this.arcgisCancel.emit(), this._interrupt) {
|
|
344
344
|
this.orchestrator?.cancelInterrupt(), this._interrupt = null;
|
|
345
345
|
return;
|
|
346
346
|
}
|
|
347
|
-
this._orchestratorController?.cancel(), this.#
|
|
348
|
-
}, this.#
|
|
349
|
-
|
|
350
|
-
const
|
|
351
|
-
this.arcgisFeedback.emit(
|
|
352
|
-
}, this.#
|
|
353
|
-
|
|
354
|
-
const
|
|
355
|
-
this._inputValue =
|
|
356
|
-
}, this.#
|
|
357
|
-
this.arcgisSlottableRequest.emit(
|
|
358
|
-
}, this._orchestratorController = null, this._interrupt = null, this._interruptDetails = [], this._error = null, this._inputValue = "", this._isAnswering = !1, this._canceling = !1, this.messages = new
|
|
347
|
+
this._orchestratorController?.cancel(), this.#e?.abort(), this.#e = null;
|
|
348
|
+
}, this.#h = (t) => {
|
|
349
|
+
t.stopPropagation();
|
|
350
|
+
const e = t.detail;
|
|
351
|
+
this.arcgisFeedback.emit(e);
|
|
352
|
+
}, this.#g = (t) => {
|
|
353
|
+
t.stopPropagation();
|
|
354
|
+
const e = t.detail;
|
|
355
|
+
this._inputValue = e.prompt, this.arcgisPromptSelect.emit(e);
|
|
356
|
+
}, this.#u = (t) => {
|
|
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 T([]), 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
|
-
this.properties = { _orchestratorController: 16, _interrupt: 16, _interruptDetails: 16, _error: 16, _inputValue: 16, _isAnswering: 16, _signedInUserId: 16, _canceling: 16, _isSignedIn: 16, _user: 16, awaitingResponse: 32, awaitingResponseStep: 32, interrupt: 32, messages: 0, orchestrator: 32, entryMessage: 1, heading: 1, description: 1, referenceElement: 1, suggestedPrompts: 0, feedbackEnabled: 5, keepSuggestedPrompts: 5, streamingDisabled: 5, runtimeEventsEnabled: 5, logEnabled: 5, copyEnabled: 5, voiceInputEnabled: 5, readAloudEnabled: 5, assistantAvatarEnabled: 5, userAvatarEnabled: 5 };
|
|
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 };
|
|
362
362
|
}
|
|
363
363
|
static {
|
|
364
|
-
this.styles =
|
|
364
|
+
this.styles = W;
|
|
365
365
|
}
|
|
366
|
-
#e;
|
|
367
|
-
#l;
|
|
368
|
-
#s;
|
|
369
366
|
#t;
|
|
367
|
+
#o;
|
|
368
|
+
#s;
|
|
369
|
+
#e;
|
|
370
370
|
#r;
|
|
371
371
|
#i;
|
|
372
372
|
#a;
|
|
373
373
|
#n;
|
|
374
|
+
#l;
|
|
374
375
|
#c;
|
|
375
376
|
#h;
|
|
376
377
|
#g;
|
|
377
|
-
#
|
|
378
|
-
#d;
|
|
378
|
+
#u;
|
|
379
379
|
get _isSignedIn() {
|
|
380
380
|
return !!this.#i?.user || !!this._signedInUserId;
|
|
381
381
|
}
|
|
@@ -400,174 +400,179 @@ class ee extends O {
|
|
|
400
400
|
async clearChatHistory() {
|
|
401
401
|
this._reset(), this._orchestratorController?.clearChatHistory();
|
|
402
402
|
}
|
|
403
|
-
register(
|
|
404
|
-
this.#r.set(
|
|
403
|
+
register(t) {
|
|
404
|
+
this.#r.set(t.agent.id, t), this._orchestratorController && this.#d();
|
|
405
405
|
}
|
|
406
|
-
submitInterrupt(
|
|
407
|
-
this.arcgisInterruptSubmit.emit(
|
|
406
|
+
submitInterrupt(t) {
|
|
407
|
+
this.arcgisInterruptSubmit.emit(t), this._interrupt && (this._interruptDetails = [...this._interruptDetails, { interrupt: this._interrupt, response: t }]), this.orchestrator?.resumeInterrupt(t), this._interrupt = null;
|
|
408
408
|
}
|
|
409
|
-
async submitMessage(
|
|
410
|
-
const
|
|
411
|
-
if (!
|
|
409
|
+
async submitMessage(t) {
|
|
410
|
+
const e = t.trim();
|
|
411
|
+
if (!e || (this.messages.push({
|
|
412
412
|
id: Date.now().toString(),
|
|
413
413
|
// TODO: Replace with a more robust ID generation method or get from orchestrator
|
|
414
414
|
role: "user",
|
|
415
|
-
content:
|
|
415
|
+
content: e
|
|
416
416
|
}), !this._orchestratorController))
|
|
417
417
|
return;
|
|
418
|
-
this.#
|
|
419
|
-
const i = this._orchestratorController.ask(
|
|
420
|
-
for await (const
|
|
421
|
-
const
|
|
422
|
-
switch (
|
|
418
|
+
this.#e = new AbortController(), this._orchestratorController.streamingDisabled = this.streamingDisabled;
|
|
419
|
+
const i = this.alwaysUseAgentId ? { routing: "direct", agentId: this.alwaysUseAgentId } : { routing: "auto", agentIds: this.allowedAgentIds }, r = this._orchestratorController.ask(e, i, this.#e?.signal);
|
|
420
|
+
for await (const s of r) {
|
|
421
|
+
const l = s.runId, a = this.messages.at(-1);
|
|
422
|
+
switch (s.type) {
|
|
423
423
|
case "runtime":
|
|
424
|
-
this.arcgisRuntime.emit(
|
|
424
|
+
this.arcgisRuntime.emit(s.event);
|
|
425
425
|
break;
|
|
426
426
|
case "block-start": {
|
|
427
427
|
this._isAnswering = !0;
|
|
428
|
-
const
|
|
429
|
-
if (
|
|
430
|
-
const
|
|
431
|
-
this.messages.splice(-1, 1, { ...
|
|
428
|
+
const n = { type: s.blockType, isPending: !0 };
|
|
429
|
+
if (a?.role === "assistant" && a.id === l) {
|
|
430
|
+
const c = [...a.blocks ?? [], n];
|
|
431
|
+
this.messages.splice(-1, 1, { ...a, blocks: c });
|
|
432
432
|
} else
|
|
433
433
|
this.messages.push({
|
|
434
434
|
role: "assistant",
|
|
435
|
-
blocks: [
|
|
436
|
-
id:
|
|
435
|
+
blocks: [n],
|
|
436
|
+
id: l,
|
|
437
437
|
isStreaming: !0,
|
|
438
438
|
interrupts: this._interruptDetails
|
|
439
439
|
}), this._interruptDetails = [];
|
|
440
440
|
break;
|
|
441
441
|
}
|
|
442
442
|
case "block-data": {
|
|
443
|
-
if (
|
|
443
|
+
if (a?.role !== "assistant" || a?.id !== l)
|
|
444
444
|
break;
|
|
445
|
-
const
|
|
446
|
-
if (
|
|
445
|
+
const n = [...a.blocks ?? []], c = n[n.length - 1], { blockType: h, data: u } = s;
|
|
446
|
+
if (c?.type !== h || !c.isPending)
|
|
447
447
|
break;
|
|
448
|
-
h === "text" ?
|
|
449
|
-
...
|
|
448
|
+
h === "text" ? n[n.length - 1] = {
|
|
449
|
+
...c,
|
|
450
450
|
data: {
|
|
451
|
-
...
|
|
452
|
-
parts:
|
|
451
|
+
...c.data,
|
|
452
|
+
parts: u?.parts
|
|
453
453
|
}
|
|
454
|
-
} :
|
|
454
|
+
} : n[n.length - 1] = { ...c, data: { ...c.data, ...u ?? {} } }, this.messages.splice(-1, 1, { ...a, blocks: n });
|
|
455
455
|
break;
|
|
456
456
|
}
|
|
457
457
|
case "block-end": {
|
|
458
|
-
if (
|
|
458
|
+
if (a?.role !== "assistant" || a?.id !== l)
|
|
459
459
|
break;
|
|
460
|
-
const
|
|
461
|
-
if (
|
|
460
|
+
const n = [...a.blocks ?? []], c = n[n.length - 1];
|
|
461
|
+
if (c?.type !== s.blockType || !c.isPending)
|
|
462
462
|
break;
|
|
463
|
-
const h =
|
|
464
|
-
|
|
463
|
+
const h = c;
|
|
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
|
+
s.error ? (this.messages.push({
|
|
469
469
|
role: "assistant",
|
|
470
|
-
log:
|
|
471
|
-
error:
|
|
472
|
-
id:
|
|
470
|
+
log: s.log,
|
|
471
|
+
error: s.error,
|
|
472
|
+
id: l,
|
|
473
473
|
interrupts: this._interruptDetails
|
|
474
|
-
}), this._interruptDetails = []) :
|
|
475
|
-
...
|
|
476
|
-
content:
|
|
477
|
-
blocks:
|
|
474
|
+
}), this._interruptDetails = []) : a?.role === "assistant" && a.id === l && this.messages.splice(-1, 1, {
|
|
475
|
+
...a,
|
|
476
|
+
content: s.response,
|
|
477
|
+
blocks: a.blocks?.map((n) => ({ ...n, data: { ...n.data }, isPending: !1 })) ?? [],
|
|
478
478
|
isStreaming: !1,
|
|
479
|
-
log:
|
|
480
|
-
}), this._isAnswering = !1, this.#
|
|
479
|
+
log: s.log
|
|
480
|
+
}), this._isAnswering = !1, this.#e = null, this._canceling = !1;
|
|
481
481
|
break;
|
|
482
482
|
case "interrupt":
|
|
483
|
-
this._interrupt = { ...
|
|
483
|
+
this._interrupt = { ...s.payload, id: l }, this.arcgisInterrupt.emit(this._interrupt);
|
|
484
484
|
break;
|
|
485
485
|
case "cancelled":
|
|
486
|
-
|
|
487
|
-
...
|
|
488
|
-
blocks:
|
|
486
|
+
a?.role === "assistant" && a.id === l ? this.messages.splice(-1, 1, {
|
|
487
|
+
...a,
|
|
488
|
+
blocks: a.blocks?.filter((n) => n.type === "text" || !n.isPending) ?? [],
|
|
489
489
|
isStreaming: !1,
|
|
490
|
-
log:
|
|
490
|
+
log: s.log,
|
|
491
491
|
error: `(${this._messages.stoppedByUserLabel})`
|
|
492
492
|
}) : (this.messages.push({
|
|
493
493
|
role: "assistant",
|
|
494
|
-
log:
|
|
494
|
+
log: s.log,
|
|
495
495
|
error: `(${this._messages.stoppedByUserLabel})`,
|
|
496
|
-
id:
|
|
496
|
+
id: l,
|
|
497
497
|
interrupts: this._interruptDetails
|
|
498
|
-
}), this._interruptDetails = []), this._isAnswering = !1, this.#
|
|
498
|
+
}), this._interruptDetails = []), this._isAnswering = !1, this.#e = null, this._canceling = !1;
|
|
499
499
|
break;
|
|
500
500
|
}
|
|
501
501
|
}
|
|
502
502
|
}
|
|
503
|
-
unregister(
|
|
504
|
-
this.#r.delete(
|
|
503
|
+
unregister(t) {
|
|
504
|
+
this.#r.delete(t), this._orchestratorController && this.#d();
|
|
505
505
|
}
|
|
506
506
|
load() {
|
|
507
507
|
this.manager.onLifecycle(this._reset.bind(this));
|
|
508
508
|
}
|
|
509
509
|
loaded() {
|
|
510
510
|
this.manager.onLifecycle(() => {
|
|
511
|
-
this.#
|
|
512
|
-
const
|
|
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 = M(() => !!this._interrupt && !!this.#s.value, () => {
|
|
513
513
|
const i = this.#s.value;
|
|
514
514
|
i.removeEventListener("arcgisSubmit", this.#n), i.removeEventListener("arcgisCancel", this.#a), i.addEventListener("arcgisSubmit", this.#n, { once: !0 }), i.addEventListener("arcgisCancel", this.#a, { once: !0 });
|
|
515
|
-
}),
|
|
516
|
-
const
|
|
517
|
-
|
|
515
|
+
}), e = this.messages.on("after-add", (i) => {
|
|
516
|
+
const r = i.item;
|
|
517
|
+
r.role === "assistant" && (r.error || r.content) && this.arcgisResponse.emit(r);
|
|
518
518
|
});
|
|
519
519
|
return queueMicrotask(() => {
|
|
520
|
-
this.#
|
|
521
|
-
i ? this.arcgisReady.emit() : this._error && this.arcgisError.emit(new Error(this._error));
|
|
522
|
-
});
|
|
520
|
+
this.#p();
|
|
523
521
|
}), () => {
|
|
524
|
-
|
|
522
|
+
t.remove(), e.remove(), this.#t.value?.removeEventListener("arcgisPromptSelect", this.#g), this.#s.value?.removeEventListener("arcgisSubmit", this.#n), this.#s.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;
|
|
525
523
|
};
|
|
526
524
|
});
|
|
527
525
|
}
|
|
528
|
-
|
|
526
|
+
willUpdate(t) {
|
|
527
|
+
this.hasUpdated && t.has("runtimeEventsEnabled") && this._orchestratorController && (this._orchestratorController.destroy(), this._orchestratorController = null, this.#p());
|
|
528
|
+
}
|
|
529
|
+
async #d() {
|
|
529
530
|
try {
|
|
530
|
-
|
|
531
|
-
|
|
532
|
-
|
|
533
|
-
|
|
534
|
-
|
|
531
|
+
this._error = null;
|
|
532
|
+
const t = H(this.el, this.referenceElement);
|
|
533
|
+
await t?.componentOnReady();
|
|
534
|
+
const e = [...this.#r.values()];
|
|
535
|
+
return e.length ? (this._orchestratorController?.destroy(), this._orchestratorController = new p({
|
|
536
|
+
agents: e,
|
|
535
537
|
portal: this.#i,
|
|
536
538
|
runtimeEventsEnabled: this.runtimeEventsEnabled,
|
|
537
539
|
streamingDisabled: this.streamingDisabled,
|
|
538
|
-
view:
|
|
540
|
+
view: t?.view
|
|
539
541
|
}), await this._orchestratorController.load(), this.requestUpdate(), !0) : (this._error = this._messages.noAgentsFoundMessage, !1);
|
|
540
|
-
} catch (
|
|
541
|
-
return this._error =
|
|
542
|
+
} catch (t) {
|
|
543
|
+
return this._error = t?.message ?? this._messages.orchestratorInitializationErrorMessage, z(this)(t), !1;
|
|
542
544
|
}
|
|
543
545
|
}
|
|
546
|
+
async #p() {
|
|
547
|
+
await this.#d() ? this.arcgisReady.emit() : this._error && this.arcgisError.emit(new Error(this._error));
|
|
548
|
+
}
|
|
544
549
|
_reset() {
|
|
545
|
-
this._orchestratorController?.cancel(), this.#
|
|
550
|
+
this._orchestratorController?.cancel(), this.#e?.abort(), this._interrupt = null, this.messages.removeAll(), this._error = null, this._inputValue = "", this._signedInUserId = void 0;
|
|
546
551
|
}
|
|
547
552
|
_renderEntryMessage() {
|
|
548
|
-
return this._isSignedIn ? this._error ? this._renderErrorNotice() : this.entryMessage ? this.messages.length > 0 ? null :
|
|
553
|
+
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();
|
|
549
554
|
}
|
|
550
555
|
_renderSignInNotice() {
|
|
551
|
-
const
|
|
552
|
-
return
|
|
556
|
+
const t = this.#i;
|
|
557
|
+
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 () => {
|
|
553
558
|
try {
|
|
554
|
-
const
|
|
555
|
-
this._signedInUserId =
|
|
556
|
-
} catch (
|
|
557
|
-
this._error =
|
|
559
|
+
const e = await V.getCredential(`${t.url}/sharing`);
|
|
560
|
+
this._signedInUserId = e.userId, this._error = null, this.requestUpdate(), await this.#p();
|
|
561
|
+
} catch (e) {
|
|
562
|
+
this._error = e?.message ?? this._messages.signInErrorMessage, this.arcgisError.emit(new Error(this._error)), B.log("error", this, "Error signing in:", { detail: { error: e } });
|
|
558
563
|
}
|
|
559
|
-
}} target=_blank title=${this._messages.signInToArcGISOnlineLabel ??
|
|
564
|
+
}} target=_blank title=${this._messages.signInToArcGISOnlineLabel ?? _}>${this._messages.signInLabel}</calcite-link>` : g`<div slot=link>${this._messages.noPortalInformationMessage}</div>`}</calcite-notice>`;
|
|
560
565
|
}
|
|
561
566
|
_renderErrorNotice() {
|
|
562
|
-
return this._error ?
|
|
567
|
+
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;
|
|
563
568
|
}
|
|
564
569
|
render() {
|
|
565
|
-
return
|
|
566
|
-
this.#
|
|
570
|
+
return g`<calcite-panel .loading=${!this._orchestratorController && !this._error || this._orchestratorController?.loading} .heading=${this.heading ?? this._messages.assistantLabel} .description=${this.description} ${k(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, i) => g`<slot name=${I(t.id, i) ?? _} slot=${I(t.id, i) ?? _}><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} ${k(this.#s)}></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} ${k(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
|
+
this.#o.value?.submitMessage();
|
|
567
572
|
}} 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>`;
|
|
568
573
|
}
|
|
569
574
|
}
|
|
570
|
-
x("arcgis-assistant",
|
|
575
|
+
x("arcgis-assistant", et);
|
|
571
576
|
export {
|
|
572
|
-
|
|
577
|
+
et as ArcgisAssistant
|
|
573
578
|
};
|