@arcgis/ai-components 6.0.0-next.2 → 6.0.0-next.4
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/agent-utils/middlewares/humanInTheLoop.js +22 -20
- package/dist/agents/agents/help/helpAgent.js +10 -10
- package/dist/agents/tools/navigation/goToBookmark/adapter.js +34 -17
- package/dist/cdn/46NXKDIE.js +2 -0
- package/dist/cdn/{7APXFHDF.js → 5OGABLOF.js} +4 -4
- package/dist/cdn/CKDKQVS3.js +2 -0
- package/dist/cdn/CV5YAJMD.js +2 -0
- package/dist/cdn/{L5OYOLWV.js → CWZG7DML.js} +1 -1
- package/dist/cdn/{UJMM5QA4.js → EWZNZZ5S.js} +1 -1
- package/dist/cdn/G4L7RUTK.js +49 -0
- package/dist/cdn/H653UVNH.js +2 -0
- package/dist/cdn/{Q7BJGEFH.js → I2RQZAFF.js} +1 -1
- package/dist/cdn/JZT4ECVH.js +2 -0
- package/dist/cdn/MNMCIS4E.js +15 -0
- package/dist/cdn/{ZROI63CW.js → MSHEHZYP.js} +2 -2
- package/dist/cdn/OVH4S4ZB.js +3 -0
- package/dist/cdn/{5SRRG7WG.js → RQYDIQVD.js} +2 -2
- package/dist/cdn/TZQ6XEKW.js +2 -0
- package/dist/cdn/YIF2OD6F.js +2 -0
- package/dist/cdn/agent-utils/SkillAgent.js +1 -1
- package/dist/cdn/agent-utils/middlewares/humanInTheLoop.js +1 -1
- package/dist/cdn/index.js +1 -1
- package/dist/chunks/SKILL3.js +6 -10
- package/dist/chunks/intent_prompt.js +18 -107
- package/dist/components/arcgis-assistant/customElement.js +100 -100
- package/dist/components/arcgis-assistant/types.d.ts +2 -0
- package/dist/components/arcgis-assistant-interrupt/customElement.d.ts +6 -0
- package/dist/components/arcgis-assistant-interrupt/customElement.js +24 -23
- 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/orchestrator/types.d.ts +6 -0
- 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/package.json +5 -5
- package/dist/cdn/7XVIZ7HK.js +0 -2
- package/dist/cdn/AWH4VDPD.js +0 -2
- package/dist/cdn/G3KILEGJ.js +0 -2
- package/dist/cdn/HOMSK66Q.js +0 -2
- package/dist/cdn/MHXM37QI.js +0 -2
- package/dist/cdn/RFIN7KO6.js +0 -138
- package/dist/cdn/SG6PAUVR.js +0 -2
- package/dist/cdn/SRXUC4QB.js +0 -3
- package/dist/cdn/V66TS2BB.js +0 -2
- package/dist/cdn/ZEDDYT24.js +0 -19
|
@@ -2,7 +2,7 @@
|
|
|
2
2
|
import { c as L } from "../../chunks/runtime.js";
|
|
3
3
|
import { css as T, html as d } from "lit";
|
|
4
4
|
import M from "@arcgis/core/core/Collection.js";
|
|
5
|
-
import { whenOnce as
|
|
5
|
+
import { whenOnce as O, watch as R, when as D } from "@arcgis/core/core/reactiveUtils.js";
|
|
6
6
|
import U from "@arcgis/core/portal/Portal.js";
|
|
7
7
|
import { LitElement as B, createEvent as b, nothing as w } from "@arcgis/lumina";
|
|
8
8
|
import * as z from "@arcgis/toolkit/log";
|
|
@@ -11,14 +11,14 @@ import { createRef as E, ref as k } from "lit/directives/ref.js";
|
|
|
11
11
|
import { u as q } from "../../chunks/useT9n.js";
|
|
12
12
|
import { Orchestrator as F } from "../../orchestrator/orchestrator/orchestrator.js";
|
|
13
13
|
import H from "@arcgis/core/core/Accessor.js";
|
|
14
|
-
import { property as
|
|
14
|
+
import { property as y, subclass as V } from "@arcgis/core/core/accessorSupport/decorators.js";
|
|
15
15
|
import { marked as S } from "marked";
|
|
16
16
|
import { g as j } from "../../chunks/utils2.js";
|
|
17
17
|
import { g as I } from "../../chunks/slottableRequestUtils.js";
|
|
18
18
|
import A from "@arcgis/core/identity/IdentityManager.js";
|
|
19
19
|
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)}`;
|
|
20
|
-
function $(
|
|
21
|
-
return
|
|
20
|
+
function $(o) {
|
|
21
|
+
return o.trim() ? S.lexer(o).filter((t) => t.type !== "space").map((t) => S.parser([t])) : [];
|
|
22
22
|
}
|
|
23
23
|
class x {
|
|
24
24
|
constructor() {
|
|
@@ -105,47 +105,47 @@ class x {
|
|
|
105
105
|
"wbr"
|
|
106
106
|
]), s = /<(\/?)([a-zA-Z][\w-]*)\b[^>]*?(\/?)>/gu, i = [];
|
|
107
107
|
for (let r = s.exec(t); r; r = s.exec(t)) {
|
|
108
|
-
const [, g, p, m] = r,
|
|
109
|
-
if (!(e.has(
|
|
108
|
+
const [, g, p, m] = r, n = p.toLowerCase();
|
|
109
|
+
if (!(e.has(n) || m === "/"))
|
|
110
110
|
if (g === "/") {
|
|
111
111
|
for (let c = i.length - 1; c >= 0; c--)
|
|
112
|
-
if (i[c].name ===
|
|
112
|
+
if (i[c].name === n) {
|
|
113
113
|
i.splice(c);
|
|
114
114
|
break;
|
|
115
115
|
}
|
|
116
116
|
} else
|
|
117
|
-
i.push({ name:
|
|
117
|
+
i.push({ name: n, index: r.index });
|
|
118
118
|
}
|
|
119
119
|
return i.length ? i[0].index : -1;
|
|
120
120
|
}
|
|
121
121
|
}
|
|
122
|
-
function G(
|
|
122
|
+
function G(o) {
|
|
123
123
|
const t = new x();
|
|
124
|
-
return t.push(
|
|
124
|
+
return t.push(o), t.finalize();
|
|
125
125
|
}
|
|
126
|
-
const Z = async (
|
|
127
|
-
async function* J(
|
|
126
|
+
const Z = async (o) => await new Promise((t) => setTimeout(t, o));
|
|
127
|
+
async function* J(o, { chunkSize: t = 15, delay: e = 50 } = {}) {
|
|
128
128
|
const s = new x();
|
|
129
|
-
for (let i = 0; i <
|
|
130
|
-
yield s.push(
|
|
129
|
+
for (let i = 0; i < o.length; i += t)
|
|
130
|
+
yield s.push(o.slice(i, i + t)), await Z(e);
|
|
131
131
|
yield s.finalize();
|
|
132
132
|
}
|
|
133
|
-
var K = Object.defineProperty, Q = Object.getOwnPropertyDescriptor,
|
|
134
|
-
for (var i = s > 1 ? void 0 : s ? Q(t, e) : t, r =
|
|
135
|
-
(g =
|
|
133
|
+
var K = Object.defineProperty, Q = Object.getOwnPropertyDescriptor, _ = (o, t, e, s) => {
|
|
134
|
+
for (var i = s > 1 ? void 0 : s ? Q(t, e) : t, r = o.length - 1, g; r >= 0; r--)
|
|
135
|
+
(g = o[r]) && (i = (s ? g(t, e, i) : g(i)) || i);
|
|
136
136
|
return s && i && K(t, e, i), i;
|
|
137
137
|
};
|
|
138
|
-
const P = (
|
|
139
|
-
async function* C(
|
|
138
|
+
const P = (o) => !o || typeof o != "object" ? !1 : o.name === "AbortError";
|
|
139
|
+
async function* C(o, t, e, s, i = !1) {
|
|
140
140
|
if (i) {
|
|
141
141
|
if (s?.aborted) {
|
|
142
142
|
yield { type: "cancelled", log: e, runId: t };
|
|
143
143
|
return;
|
|
144
144
|
}
|
|
145
|
-
yield { type: "block-data", blockType: "text", data: { parts: G(
|
|
145
|
+
yield { type: "block-data", blockType: "text", data: { parts: G(o) }, runId: t };
|
|
146
146
|
return;
|
|
147
147
|
}
|
|
148
|
-
for await (const r of J(
|
|
148
|
+
for await (const r of J(o)) {
|
|
149
149
|
if (s?.aborted) {
|
|
150
150
|
yield { type: "cancelled", log: e, runId: t };
|
|
151
151
|
return;
|
|
@@ -154,8 +154,8 @@ async function* C(l, t, e, s, i = !1) {
|
|
|
154
154
|
}
|
|
155
155
|
}
|
|
156
156
|
let u = class extends H {
|
|
157
|
-
constructor(
|
|
158
|
-
super(
|
|
157
|
+
constructor(o) {
|
|
158
|
+
super(o), this.view = null, this.streamingDisabled = !1, this.runtimeEventsEnabled = !1, this.loading = !1, this.processing = !1, this.processingStep = "";
|
|
159
159
|
}
|
|
160
160
|
async load() {
|
|
161
161
|
this._set("loading", !0);
|
|
@@ -169,7 +169,7 @@ let u = class extends H {
|
|
|
169
169
|
this.orchestrator?.dispose(), super.destroy();
|
|
170
170
|
}
|
|
171
171
|
async _initialize() {
|
|
172
|
-
this.removeHandles(), await Promise.all([this.portal.load(), this.view?.when()]), this.view && await
|
|
172
|
+
this.removeHandles(), await Promise.all([this.portal.load(), this.view?.when()]), this.view && await O(() => !this.view.updating), this._set(
|
|
173
173
|
"orchestrator",
|
|
174
174
|
await F.init({
|
|
175
175
|
agents: [...this.agents],
|
|
@@ -177,7 +177,7 @@ let u = class extends H {
|
|
|
177
177
|
view: this.view ?? void 0
|
|
178
178
|
})
|
|
179
179
|
), this.addHandles([
|
|
180
|
-
|
|
180
|
+
R(
|
|
181
181
|
() => [this.view, this.agents],
|
|
182
182
|
() => {
|
|
183
183
|
this._initialize();
|
|
@@ -188,14 +188,14 @@ let u = class extends H {
|
|
|
188
188
|
clearChatHistory() {
|
|
189
189
|
this.orchestrator?.newConversation();
|
|
190
190
|
}
|
|
191
|
-
async *ask(
|
|
191
|
+
async *ask(o, t, e) {
|
|
192
192
|
if (!this.orchestrator)
|
|
193
193
|
throw new Error("Orchestrator not initialized yet.");
|
|
194
194
|
this._set("processing", !0), this._set("processingStep", "");
|
|
195
195
|
const s = [];
|
|
196
196
|
let i, r = "pending";
|
|
197
197
|
try {
|
|
198
|
-
const g = this.orchestrator.ask(
|
|
198
|
+
const g = this.orchestrator.ask(o, t);
|
|
199
199
|
for await (const p of g)
|
|
200
200
|
switch (r = p.runId, p.type) {
|
|
201
201
|
case "runtime": {
|
|
@@ -208,27 +208,27 @@ let u = class extends H {
|
|
|
208
208
|
}
|
|
209
209
|
case "completed": {
|
|
210
210
|
this._set("processing", !1), this._set("processingStep", "");
|
|
211
|
-
const m = p.result,
|
|
212
|
-
if (!
|
|
211
|
+
const m = p.result, n = !!m.content.length, c = !!i?.length;
|
|
212
|
+
if (!n && !c) {
|
|
213
213
|
yield { type: "completed", error: "No response received.", log: s, runId: r };
|
|
214
214
|
return;
|
|
215
215
|
}
|
|
216
|
-
const
|
|
217
|
-
if (yield { type: "block-start", blockType: "text", runId: r }, yield* C(
|
|
218
|
-
for (const
|
|
216
|
+
const l = m.content;
|
|
217
|
+
if (yield { type: "block-start", blockType: "text", runId: r }, yield* C(l, r, s, e, this.streamingDisabled), yield { type: "block-end", blockType: "text", runId: r }, c)
|
|
218
|
+
for (const a of i) {
|
|
219
219
|
if (e?.aborted) {
|
|
220
220
|
yield { type: "cancelled", log: s, runId: r };
|
|
221
221
|
return;
|
|
222
222
|
}
|
|
223
|
-
const { type: h, data:
|
|
223
|
+
const { type: h, data: f } = a;
|
|
224
224
|
if (yield { type: "block-start", blockType: h, runId: r }, h === "text") {
|
|
225
|
-
const v = typeof
|
|
225
|
+
const v = typeof f?.content == "string" ? f.content : "";
|
|
226
226
|
yield* C(v, r, s, e, this.streamingDisabled);
|
|
227
227
|
} else
|
|
228
|
-
yield { type: "block-data", blockType: h, data:
|
|
228
|
+
yield { type: "block-data", blockType: h, data: f, runId: r };
|
|
229
229
|
yield { type: "block-end", blockType: h, runId: r };
|
|
230
230
|
}
|
|
231
|
-
yield { type: "completed", response:
|
|
231
|
+
yield { type: "completed", response: l, blocks: i, log: s, runId: r };
|
|
232
232
|
return;
|
|
233
233
|
}
|
|
234
234
|
case "ux-suggestion": {
|
|
@@ -237,21 +237,21 @@ let u = class extends H {
|
|
|
237
237
|
break;
|
|
238
238
|
}
|
|
239
239
|
case "interrupt": {
|
|
240
|
-
const { kind: m, message:
|
|
240
|
+
const { kind: m, message: n, metadata: c, showOtherOption: l } = p.interrupt, a = Array.isArray(c) ? c.filter((f) => typeof f == "string") : [], h = (() => {
|
|
241
241
|
switch (m) {
|
|
242
242
|
case "booleanChoice":
|
|
243
|
-
return { type: "boolean-choice", message:
|
|
243
|
+
return { type: "boolean-choice", message: n, options: a };
|
|
244
244
|
case "singleSelection":
|
|
245
|
-
return { type: "single-select", message:
|
|
245
|
+
return { type: "single-select", message: n, options: a };
|
|
246
246
|
case "multipleSelection":
|
|
247
|
-
return { type: "multi-select", message:
|
|
247
|
+
return { type: "multi-select", message: n, options: a };
|
|
248
248
|
case "textInput":
|
|
249
|
-
return { type: "text-input", message:
|
|
249
|
+
return { type: "text-input", message: n };
|
|
250
250
|
default:
|
|
251
|
-
return { type: m, message:
|
|
251
|
+
return { type: m, message: n, options: a };
|
|
252
252
|
}
|
|
253
253
|
})();
|
|
254
|
-
this._set("processingStep", "Waiting for user input..."), yield { type: "interrupt", payload:
|
|
254
|
+
this._set("processingStep", "Waiting for user input..."), yield { type: "interrupt", payload: { ...h, showOtherOption: l }, runId: r };
|
|
255
255
|
break;
|
|
256
256
|
}
|
|
257
257
|
case "cancelled": {
|
|
@@ -286,37 +286,37 @@ let u = class extends H {
|
|
|
286
286
|
this.orchestrator?.cancel();
|
|
287
287
|
}
|
|
288
288
|
};
|
|
289
|
-
|
|
290
|
-
|
|
289
|
+
_([
|
|
290
|
+
y({ readOnly: !0 })
|
|
291
291
|
], u.prototype, "orchestrator", 2);
|
|
292
|
-
|
|
293
|
-
|
|
292
|
+
_([
|
|
293
|
+
y()
|
|
294
294
|
], u.prototype, "agents", 2);
|
|
295
|
-
|
|
296
|
-
|
|
295
|
+
_([
|
|
296
|
+
y()
|
|
297
297
|
], u.prototype, "portal", 2);
|
|
298
|
-
|
|
299
|
-
|
|
298
|
+
_([
|
|
299
|
+
y()
|
|
300
300
|
], u.prototype, "view", 2);
|
|
301
|
-
|
|
302
|
-
|
|
301
|
+
_([
|
|
302
|
+
y()
|
|
303
303
|
], u.prototype, "messages", 2);
|
|
304
|
-
|
|
305
|
-
|
|
304
|
+
_([
|
|
305
|
+
y()
|
|
306
306
|
], u.prototype, "streamingDisabled", 2);
|
|
307
|
-
|
|
308
|
-
|
|
307
|
+
_([
|
|
308
|
+
y()
|
|
309
309
|
], u.prototype, "runtimeEventsEnabled", 2);
|
|
310
|
-
|
|
311
|
-
|
|
310
|
+
_([
|
|
311
|
+
y({ readOnly: !0 })
|
|
312
312
|
], u.prototype, "loading", 2);
|
|
313
|
-
|
|
314
|
-
|
|
313
|
+
_([
|
|
314
|
+
y({ readOnly: !0 })
|
|
315
315
|
], u.prototype, "processing", 2);
|
|
316
|
-
|
|
317
|
-
|
|
316
|
+
_([
|
|
317
|
+
y({ readOnly: !0 })
|
|
318
318
|
], u.prototype, "processingStep", 2);
|
|
319
|
-
u =
|
|
319
|
+
u = _([
|
|
320
320
|
V("OrchestratorController")
|
|
321
321
|
], u);
|
|
322
322
|
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";
|
|
@@ -414,7 +414,7 @@ class et extends B {
|
|
|
414
414
|
id: Date.now().toString(),
|
|
415
415
|
// TODO: Replace with a more robust ID generation method or get from orchestrator
|
|
416
416
|
role: "user",
|
|
417
|
-
content: e?.displayText?.trim() || s || i.map((
|
|
417
|
+
content: e?.displayText?.trim() || s || i.map((n) => this.#f(n)).join(" "),
|
|
418
418
|
parts: i
|
|
419
419
|
}), !this._orchestratorController))
|
|
420
420
|
return;
|
|
@@ -424,22 +424,22 @@ class et extends B {
|
|
|
424
424
|
...r ? { routing: "direct", agentId: r } : { routing: "auto", agentIds: this.allowedAgentIds },
|
|
425
425
|
locale: g
|
|
426
426
|
}, m = this._orchestratorController.ask(s, p, this.#e?.signal);
|
|
427
|
-
for await (const
|
|
428
|
-
const c =
|
|
429
|
-
switch (
|
|
427
|
+
for await (const n of m) {
|
|
428
|
+
const c = n.runId, l = this.messages.at(-1);
|
|
429
|
+
switch (n.type) {
|
|
430
430
|
case "runtime":
|
|
431
|
-
this.arcgisRuntime.emit(
|
|
431
|
+
this.arcgisRuntime.emit(n.event);
|
|
432
432
|
break;
|
|
433
433
|
case "block-start": {
|
|
434
434
|
this._isAnswering = !0;
|
|
435
|
-
const
|
|
436
|
-
if (
|
|
437
|
-
const h = [...
|
|
438
|
-
this.messages.splice(-1, 1, { ...
|
|
435
|
+
const a = { type: n.blockType, isPending: !0 };
|
|
436
|
+
if (l?.role === "assistant" && l.id === c) {
|
|
437
|
+
const h = [...l.blocks ?? [], a];
|
|
438
|
+
this.messages.splice(-1, 1, { ...l, blocks: h });
|
|
439
439
|
} else
|
|
440
440
|
this.messages.push({
|
|
441
441
|
role: "assistant",
|
|
442
|
-
blocks: [
|
|
442
|
+
blocks: [a],
|
|
443
443
|
id: c,
|
|
444
444
|
isStreaming: !0,
|
|
445
445
|
interrupts: this._interruptDetails
|
|
@@ -447,58 +447,58 @@ class et extends B {
|
|
|
447
447
|
break;
|
|
448
448
|
}
|
|
449
449
|
case "block-data": {
|
|
450
|
-
if (
|
|
450
|
+
if (l?.role !== "assistant" || l?.id !== c)
|
|
451
451
|
break;
|
|
452
|
-
const
|
|
453
|
-
if (h?.type !==
|
|
452
|
+
const a = [...l.blocks ?? []], h = a[a.length - 1], { blockType: f, data: v } = n;
|
|
453
|
+
if (h?.type !== f || !h.isPending)
|
|
454
454
|
break;
|
|
455
|
-
|
|
455
|
+
f === "text" ? a[a.length - 1] = {
|
|
456
456
|
...h,
|
|
457
457
|
data: {
|
|
458
458
|
...h.data,
|
|
459
459
|
parts: v?.parts
|
|
460
460
|
}
|
|
461
|
-
} :
|
|
461
|
+
} : a[a.length - 1] = { ...h, data: { ...h.data, ...v ?? {} } }, this.messages.splice(-1, 1, { ...l, blocks: a });
|
|
462
462
|
break;
|
|
463
463
|
}
|
|
464
464
|
case "block-end": {
|
|
465
|
-
if (
|
|
465
|
+
if (l?.role !== "assistant" || l?.id !== c)
|
|
466
466
|
break;
|
|
467
|
-
const
|
|
468
|
-
if (h?.type !==
|
|
467
|
+
const a = [...l.blocks ?? []], h = a[a.length - 1];
|
|
468
|
+
if (h?.type !== n.blockType || !h.isPending)
|
|
469
469
|
break;
|
|
470
|
-
const
|
|
471
|
-
|
|
470
|
+
const f = h;
|
|
471
|
+
a[a.length - 1] = { ...f, data: { ...f.data }, isPending: !1 }, this.messages.splice(-1, 1, { ...l, blocks: a });
|
|
472
472
|
break;
|
|
473
473
|
}
|
|
474
474
|
case "completed":
|
|
475
|
-
|
|
475
|
+
n.error ? (this.messages.push({
|
|
476
476
|
role: "assistant",
|
|
477
|
-
log:
|
|
478
|
-
error:
|
|
477
|
+
log: n.log,
|
|
478
|
+
error: n.error,
|
|
479
479
|
id: c,
|
|
480
480
|
interrupts: this._interruptDetails
|
|
481
|
-
}), this._interruptDetails = []) :
|
|
482
|
-
...
|
|
483
|
-
content:
|
|
484
|
-
blocks:
|
|
481
|
+
}), this._interruptDetails = []) : l?.role === "assistant" && l.id === c && this.messages.splice(-1, 1, {
|
|
482
|
+
...l,
|
|
483
|
+
content: n.response,
|
|
484
|
+
blocks: l.blocks?.map((a) => ({ ...a, data: { ...a.data }, isPending: !1 })) ?? [],
|
|
485
485
|
isStreaming: !1,
|
|
486
|
-
log:
|
|
486
|
+
log: n.log
|
|
487
487
|
}), this._isAnswering = !1, this.#e = null, this._canceling = !1;
|
|
488
488
|
break;
|
|
489
489
|
case "interrupt":
|
|
490
|
-
this._interrupt = { ...
|
|
490
|
+
this._interrupt = { ...n.payload, id: c }, this.arcgisInterrupt.emit(this._interrupt);
|
|
491
491
|
break;
|
|
492
492
|
case "cancelled":
|
|
493
|
-
|
|
494
|
-
...
|
|
495
|
-
blocks:
|
|
493
|
+
l?.role === "assistant" && l.id === c ? this.messages.splice(-1, 1, {
|
|
494
|
+
...l,
|
|
495
|
+
blocks: l.blocks?.filter((a) => a.type === "text" || !a.isPending) ?? [],
|
|
496
496
|
isStreaming: !1,
|
|
497
|
-
log:
|
|
497
|
+
log: n.log,
|
|
498
498
|
error: `(${this._messages.stoppedByUserLabel})`
|
|
499
499
|
}) : (this.messages.push({
|
|
500
500
|
role: "assistant",
|
|
501
|
-
log:
|
|
501
|
+
log: n.log,
|
|
502
502
|
error: `(${this._messages.stoppedByUserLabel})`,
|
|
503
503
|
id: c,
|
|
504
504
|
interrupts: this._interruptDetails
|
|
@@ -516,7 +516,7 @@ class et extends B {
|
|
|
516
516
|
loaded() {
|
|
517
517
|
this.manager.onLifecycle(() => {
|
|
518
518
|
this.#t.value?.addEventListener("arcgisPromptSelect", this.#d), this.#t.value?.addEventListener("arcgisSubmit", this.#l), this.#t.value?.addEventListener("arcgisCancel", this.#c), this.#t.value?.addEventListener("arcgisFeedback", this.#h);
|
|
519
|
-
const t =
|
|
519
|
+
const t = D(() => !!this._interrupt && !!this.#i.value, () => {
|
|
520
520
|
const s = this.#i.value;
|
|
521
521
|
s.removeEventListener("arcgisSubmit", this.#n), s.removeEventListener("arcgisCancel", this.#a), s.addEventListener("arcgisSubmit", this.#n, { once: !0 }), s.addEventListener("arcgisCancel", this.#a, { once: !0 });
|
|
522
522
|
}), e = this.messages.on("after-add", (s) => {
|
|
@@ -600,7 +600,7 @@ class et extends B {
|
|
|
600
600
|
return this._error ? d`<calcite-notice slot=entry-message open kind=brand icon width=full>${this._error === X ? d`<div slot=message>${Y}</div><calcite-link slot=link .href=${tt} target=_blank title=${this._messages.learnAboutWebMapEmbeddingsLabel ?? w}>${this._messages.readMoreLabel}</calcite-link>` : d`<div slot=message>${this._error}</div>`}</calcite-notice>` : null;
|
|
601
601
|
}
|
|
602
602
|
render() {
|
|
603
|
-
return d`<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" ? d`<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) => d`<slot name=${I(t.id, s) ?? w} slot=${I(t.id, s) ?? w}><arcgis-assistant-message-block .block=${e}></arcgis-assistant-message-block></slot>`)}</arcgis-assistant-message>` : d`<arcgis-assistant-user-message .message=${t} .user=${this._user} .userAvatarEnabled=${this.userAvatarEnabled}></arcgis-assistant-user-message>`)}</slot>${this._interrupt ? d`<div slot=message-loading><div class="interrupt-waiting-message">${this._messages.waitingForUserInputMessage}</div></div>` : d`<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 ? d`<slot name=interrupt><arcgis-assistant-interrupt slot=content-bottom .type=${this._interrupt.type} .message=${this._interrupt.message} .options=${this._interrupt.options} ${k(this.#i)}></arcgis-assistant-interrupt></slot>` : this.suggestedPrompts?.length ? d`<div class="suggested-prompts-container" slot=content-bottom><arcgis-assistant-suggested-prompts class="suggested-prompts" .prompts=${this.suggestedPrompts}></arcgis-assistant-suggested-prompts></div>` : null}<div class="footer-container" slot=footer>${this._renderEntryMessage()}${this._submissionError ? d`<div role=alert>${this._submissionError}</div>` : null}<slot name=chat-entry><arcgis-assistant-chat-entry .awaitingResponse=${this.awaitingResponse || this._isAnswering} .commandProvider=${this.commandProvider} .entityProviders=${this.entityProviders} .inputValue=${this._inputValue} .messages=${this.messages} .voiceInputEnabled=${this.voiceInputEnabled} .disabled=${this._canceling || !this._isSignedIn || !!this._interrupt || !!this._error} ${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=${() => {
|
|
603
|
+
return d`<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" ? d`<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) => d`<slot name=${I(t.id, s) ?? w} slot=${I(t.id, s) ?? w}><arcgis-assistant-message-block .block=${e}></arcgis-assistant-message-block></slot>`)}</arcgis-assistant-message>` : d`<arcgis-assistant-user-message .message=${t} .user=${this._user} .userAvatarEnabled=${this.userAvatarEnabled}></arcgis-assistant-user-message>`)}</slot>${this._interrupt ? d`<div slot=message-loading><div class="interrupt-waiting-message">${this._messages.waitingForUserInputMessage}</div></div>` : d`<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 ? d`<slot name=interrupt><arcgis-assistant-interrupt slot=content-bottom .type=${this._interrupt.type} .message=${this._interrupt.message} .options=${this._interrupt.options} .showOtherOption=${this._interrupt.showOtherOption ?? !1} ${k(this.#i)}></arcgis-assistant-interrupt></slot>` : this.suggestedPrompts?.length ? d`<div class="suggested-prompts-container" slot=content-bottom><arcgis-assistant-suggested-prompts class="suggested-prompts" .prompts=${this.suggestedPrompts}></arcgis-assistant-suggested-prompts></div>` : null}<div class="footer-container" slot=footer>${this._renderEntryMessage()}${this._submissionError ? d`<div role=alert>${this._submissionError}</div>` : null}<slot name=chat-entry><arcgis-assistant-chat-entry .awaitingResponse=${this.awaitingResponse || this._isAnswering} .commandProvider=${this.commandProvider} .entityProviders=${this.entityProviders} .inputValue=${this._inputValue} .messages=${this.messages} .voiceInputEnabled=${this.voiceInputEnabled} .disabled=${this._canceling || !this._isSignedIn || !!this._interrupt || !!this._error} ${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=${() => {
|
|
604
604
|
this.#o.value?.submitMessage();
|
|
605
605
|
}} 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>`;
|
|
606
606
|
}
|
|
@@ -39,6 +39,8 @@ export interface Interrupt {
|
|
|
39
39
|
* If the type is `single-select`, the options could be ["Choice A", "Choice B", "Choice C"].
|
|
40
40
|
*/
|
|
41
41
|
options?: string[];
|
|
42
|
+
/** Shows the built-in Other option for single-select and multi-select prompts. Defaults to false. */
|
|
43
|
+
showOtherOption?: boolean;
|
|
42
44
|
}
|
|
43
45
|
|
|
44
46
|
/** A chat message sent by the assistant. */
|
|
@@ -27,6 +27,12 @@ export abstract class ArcgisAssistantInterrupt extends LitElement {
|
|
|
27
27
|
}>;
|
|
28
28
|
accessor message: string | undefined;
|
|
29
29
|
accessor options: string[] | undefined;
|
|
30
|
+
/**
|
|
31
|
+
* Shows the built-in Other option for single-select and multi-select prompts. Defaults to false.
|
|
32
|
+
*
|
|
33
|
+
* @default false
|
|
34
|
+
*/
|
|
35
|
+
accessor showOtherOption: boolean;
|
|
30
36
|
accessor type: "boolean-choice" | "multi-select" | "single-select" | "text-input";
|
|
31
37
|
readonly arcgisCancel: import("@arcgis/lumina").TargetedEvent<this, void>;
|
|
32
38
|
readonly arcgisSubmit: import("@arcgis/lumina").TargetedEvent<this, string[] | boolean | string>;
|
|
@@ -1,27 +1,28 @@
|
|
|
1
1
|
/* COPYRIGHT Esri - https://js.arcgis.com/6.0/LICENSE.txt */
|
|
2
2
|
import { c as o } from "../../chunks/runtime.js";
|
|
3
|
-
import { css as n, html as
|
|
3
|
+
import { css as n, html as e } from "lit";
|
|
4
4
|
import { LitElement as h, createEvent as a, safeClassMap as u } from "@arcgis/lumina";
|
|
5
5
|
import { createRef as r, ref as c } from "lit/directives/ref.js";
|
|
6
|
-
import { u as
|
|
7
|
-
const
|
|
6
|
+
import { u as p } from "../../chunks/useT9n.js";
|
|
7
|
+
const d = n`:host{padding:var(--calcite-spacing-md);background:var(--calcite-panel-background-color, var(--calcite-color-background))}calcite-panel{border-radius:var(--calcite-dialog-corner-radius, var(--calcite-corner-radius-sm));border:0 solid var(--calcite-color-brand);border-block-start-width:4px;box-shadow:var(--calcite-shadow-md);width:100%;--calcite-panel-border-color: none}.interrupt-content{padding:0 var(--calcite-spacing-md);background:var(--calcite-color-foreground-1)}.other-input calcite-input[disabled]{pointer-events:none}.last-option{--calcite-list-border-color: transparent}`;
|
|
8
8
|
class m extends h {
|
|
9
9
|
constructor() {
|
|
10
|
-
super(...arguments), this.#
|
|
10
|
+
super(...arguments), this.#e = r(), this.#t = r(), this._messages = p({ blocking: !0 }), this._selectedOptions = [], this._otherValue = "", this._otherSelected = !1, this.showOtherOption = !1, this.arcgisCancel = a(), this.arcgisSubmit = a();
|
|
11
11
|
}
|
|
12
12
|
static {
|
|
13
|
-
this.properties = { _selectedOptions: 16, _otherValue: 16, _otherSelected: 16, type: 1, message: 1, options: [1, { type: Array }] };
|
|
13
|
+
this.properties = { _selectedOptions: 16, _otherValue: 16, _otherSelected: 16, type: 1, message: 1, options: [1, { type: Array }], showOtherOption: 5 };
|
|
14
14
|
}
|
|
15
15
|
static {
|
|
16
|
-
this.styles =
|
|
16
|
+
this.styles = d;
|
|
17
17
|
}
|
|
18
|
-
#t;
|
|
19
18
|
#e;
|
|
19
|
+
#t;
|
|
20
20
|
_isSubmitDisabled() {
|
|
21
|
-
return this._otherSelected ? !this._otherValue.trim() : !this._selectedOptions.length;
|
|
21
|
+
return this._otherSelected && this.showOtherOption ? !this._otherValue.trim() : !this._selectedOptions.length;
|
|
22
22
|
}
|
|
23
23
|
_getSubmitValue() {
|
|
24
|
-
|
|
24
|
+
const t = this._otherSelected && this.showOtherOption;
|
|
25
|
+
return typeof this._selectedOptions == "string" ? t ? this._otherValue.trim() : this._selectedOptions : this._selectedOptions.concat(t ? this._otherValue.trim() : []);
|
|
25
26
|
}
|
|
26
27
|
_getSkipValue() {
|
|
27
28
|
return this.type === "multi-select" ? [] : "";
|
|
@@ -29,39 +30,39 @@ class m extends h {
|
|
|
29
30
|
_selectOtherOption() {
|
|
30
31
|
this._otherSelected || (this._otherSelected = !0, this.type !== "multi-select" && (this._selectedOptions = ""), this._focusOtherInput());
|
|
31
32
|
}
|
|
32
|
-
_handleSingleSelectChange(
|
|
33
|
+
_handleSingleSelectChange(t) {
|
|
33
34
|
const i = this._otherSelected;
|
|
34
|
-
this._otherSelected =
|
|
35
|
+
this._otherSelected = t.target.selectedItems[0] === this.#t.value, this._selectedOptions = this._otherSelected ? "" : t.target.selectedItems[0]?.value, this._otherSelected && !i && this._focusOtherInput();
|
|
35
36
|
}
|
|
36
|
-
_handleMultiSelectChange(
|
|
37
|
-
const i = this._otherSelected, s = this.#
|
|
38
|
-
this._otherSelected = s ?
|
|
37
|
+
_handleMultiSelectChange(t) {
|
|
38
|
+
const i = this._otherSelected, s = this.#t.value;
|
|
39
|
+
this._otherSelected = s ? t.target.selectedItems.includes(s) : !1, this._selectedOptions = t.target.selectedItems.filter((l) => l !== s).map((l) => l.value), this._otherSelected && !i && this._focusOtherInput();
|
|
39
40
|
}
|
|
40
41
|
async _focusOtherInput() {
|
|
41
|
-
await this.updateComplete, await this.#
|
|
42
|
+
await this.updateComplete, await this.#e.value?.setFocus();
|
|
42
43
|
}
|
|
43
44
|
_renderOptions() {
|
|
44
|
-
return this.options?.map((
|
|
45
|
+
return this.options?.map((t, i) => e`<calcite-list-item class=${u({ "last-option": i === this.options.length - 1 })} .label=${t} .value=${t}></calcite-list-item>`);
|
|
45
46
|
}
|
|
46
47
|
_renderOtherInput() {
|
|
47
|
-
return
|
|
48
|
-
|
|
49
|
-
}}><calcite-input .label=${this._messages.otherLabel} .placeholder=${this._messages.otherLabel} .disabled=${!this._otherSelected} @calciteInputInput=${(
|
|
48
|
+
return e`<div slot=content class="other-input" @click=${(t) => {
|
|
49
|
+
t.stopPropagation(), this._selectOtherOption();
|
|
50
|
+
}}><calcite-input .label=${this._messages.otherLabel} .placeholder=${this._messages.otherLabel} .disabled=${!this._otherSelected} @calciteInputInput=${(t) => this._otherValue = t.target.value} ${c(this.#e)}></calcite-input></div>`;
|
|
50
51
|
}
|
|
51
52
|
_renderInterruptOptions() {
|
|
52
53
|
switch (this.type) {
|
|
53
54
|
case "single-select":
|
|
54
|
-
return
|
|
55
|
+
return e`<calcite-list selection-mode=single-persist .label=${this._messages.optionsLabel} @calciteListChange=${(t) => this._handleSingleSelectChange(t)}>${this._renderOptions()}${this.showOtherOption ? e`<calcite-list-item .selected=${this._otherSelected} ${c(this.#t)}>${this._renderOtherInput()}</calcite-list-item>` : null}</calcite-list>`;
|
|
55
56
|
case "multi-select":
|
|
56
|
-
return
|
|
57
|
+
return e`<calcite-list selection-mode=multiple .label=${this._messages.optionsLabel} @calciteListChange=${(t) => this._handleMultiSelectChange(t)}>${this._renderOptions()}${this.showOtherOption ? e`<calcite-list-item .selected=${this._otherSelected} ${c(this.#t)}>${this._renderOtherInput()}</calcite-list-item>` : null}</calcite-list>`;
|
|
57
58
|
case "boolean-choice":
|
|
58
59
|
return null;
|
|
59
60
|
case "text-input":
|
|
60
|
-
return
|
|
61
|
+
return e`<calcite-input .label=${this._messages.enterTextLabel} @calciteInputInput=${(t) => this._selectedOptions = t.target.value}></calcite-input>`;
|
|
61
62
|
}
|
|
62
63
|
}
|
|
63
64
|
render() {
|
|
64
|
-
return
|
|
65
|
+
return e`<calcite-panel .description=${this.message}><div class="interrupt-content">${this._renderInterruptOptions()}</div>${this.type === "boolean-choice" ? e`<calcite-button slot=footer-end appearance=outline @click=${() => this.arcgisSubmit.emit(!1)}>${this._messages.declineButtonLabel}</calcite-button><calcite-button slot=footer-end appearance=solid @click=${() => this.arcgisSubmit.emit(!0)}>${this._messages.approveButtonLabel}</calcite-button>` : e`<calcite-button slot=footer-end appearance=outline @click=${() => this.arcgisSubmit.emit(this._getSkipValue())}>${this._messages.skipButtonLabel}</calcite-button><calcite-button slot=footer-end appearance=solid .disabled=${this._isSubmitDisabled()} @click=${() => this.arcgisSubmit.emit(this._getSubmitValue())}>${this._messages.submitButtonLabel}</calcite-button>`}</calcite-panel>`;
|
|
65
66
|
}
|
|
66
67
|
}
|
|
67
68
|
o("arcgis-assistant-interrupt", m);
|