@arcgis/ai-components 5.1.0-next.128 → 5.1.0-next.129
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/{TD74CJBJ.js → 32S235WW.js} +1 -1
- package/dist/cdn/{EXWMN5DL.js → 3352JWU3.js} +1 -1
- package/dist/cdn/{77BGZ52R.js → 43BXVTTX.js} +1 -1
- package/dist/cdn/{7J26XD64.js → 45WQFXC6.js} +1 -1
- package/dist/cdn/5BWAWCMA.js +2 -0
- package/dist/cdn/{PYVVZRRJ.js → 6HIZCLMG.js} +1 -1
- package/dist/cdn/6MS2XN27.js +2 -0
- package/dist/cdn/{J2F4YIQI.js → COFOUGFJ.js} +2 -2
- package/dist/cdn/CY2AOS7J.js +2 -0
- package/dist/cdn/DPCBYJAM.js +2 -0
- package/dist/cdn/{M2TPM3PB.js → DQIMHH5V.js} +1 -1
- package/dist/cdn/DXWRFET6.js +2 -0
- package/dist/cdn/{6VQVN4YZ.js → E4TOTVRI.js} +1 -1
- package/dist/cdn/{ZQEBDNNS.js → EX6NWXUF.js} +1 -1
- package/dist/cdn/F2QU4HAK.js +2 -0
- package/dist/cdn/H4ENPGSI.js +2 -0
- package/dist/cdn/{6QA7CIBO.js → HFQQORS4.js} +1 -1
- package/dist/cdn/HWSIV5DK.js +2 -0
- package/dist/cdn/{XLFCW5OF.js → IFB2ASIW.js} +1 -1
- package/dist/cdn/{KLIA4JYQ.js → LYJY5QUA.js} +1 -1
- package/dist/cdn/M7C6Y752.js +2 -0
- package/dist/cdn/{OLAGTBRO.js → MEM7FGVU.js} +1 -1
- package/dist/cdn/{MLQKBQSG.js → P5M2HNJ7.js} +1 -1
- package/dist/cdn/{QEYLJYK7.js → P7EGIU6K.js} +1 -1
- package/dist/cdn/{BWIVB2DN.js → PW4XPFSA.js} +1 -1
- package/dist/cdn/{M56MGI7M.js → SOCUKQVO.js} +1 -1
- package/dist/cdn/TOYQ22PR.js +2 -0
- package/dist/cdn/VVG5FDCY.js +2 -0
- package/dist/cdn/{4SZDSAFW.js → ZR5WU3UB.js} +1 -1
- package/dist/cdn/ZSLJX22Z.js +3 -0
- package/dist/cdn/index.js +1 -1
- package/dist/chunks/slottableRequestUtils.js +3 -7
- package/dist/components/arcgis-assistant/customElement.d.ts +15 -0
- package/dist/components/arcgis-assistant/customElement.js +227 -127
- package/dist/components/arcgis-assistant/index.js +2 -3
- package/dist/components/arcgis-assistant/types.d.ts +14 -1
- package/dist/components/arcgis-assistant-chat/customElement.d.ts +2 -1
- package/dist/components/arcgis-assistant-chat/customElement.js +7 -7
- package/dist/components/arcgis-assistant-chat-entry/customElement.d.ts +2 -0
- package/dist/components/arcgis-assistant-chat-entry/customElement.js +25 -18
- package/dist/components/arcgis-assistant-interrupt/customElement.js +13 -9
- package/dist/components/arcgis-assistant-interrupt-preview/customElement.js +20 -0
- package/dist/components/arcgis-assistant-interrupt-preview/index.js +2 -0
- package/dist/components/arcgis-assistant-message/customElement.d.ts +2 -0
- package/dist/components/arcgis-assistant-message/customElement.js +28 -26
- package/dist/components/arcgis-assistant-message/index.js +2 -0
- package/dist/components/arcgis-assistant-message-block/customElement.js +18 -11
- package/dist/components/arcgis-assistant-message-block/index.js +1 -0
- package/dist/components/arcgis-assistant-message-loading/customElement.d.ts +4 -0
- package/dist/components/arcgis-assistant-message-loading/customElement.js +8 -8
- package/dist/components/arcgis-assistant-message-loading/index.js +1 -0
- package/dist/components/arcgis-assistant-suggested-prompts/customElement.js +8 -8
- package/dist/components/arcgis-assistant-user-message/customElement.js +1 -1
- 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 +6 -5
- package/dist/types/lumina.d.ts +6 -5
- package/dist/types/preact.d.ts +6 -5
- package/dist/types/react.d.ts +6 -5
- package/dist/types/stencil.d.ts +6 -5
- package/package.json +4 -4
- package/dist/cdn/2TKDD7IY.js +0 -2
- package/dist/cdn/7Z6WK75Y.js +0 -3
- package/dist/cdn/ASFDOICU.js +0 -2
- package/dist/cdn/EUNEQNYC.js +0 -2
- package/dist/cdn/GHPDN2L7.js +0 -2
- package/dist/cdn/KDUG6AWZ.js +0 -2
- package/dist/cdn/MM4TFFXX.js +0 -2
- package/dist/cdn/RBLFCUDD.js +0 -2
- package/dist/cdn/SRNPZKME.js +0 -2
- package/dist/cdn/YGW7TUNX.js +0 -2
- package/dist/cdn/ZTRICLZY.js +0 -2
|
@@ -1,35 +1,55 @@
|
|
|
1
1
|
/* COPYRIGHT Esri - https://js.arcgis.com/5.1/LICENSE.txt */
|
|
2
2
|
import { c as $ } from "../../chunks/runtime.js";
|
|
3
|
-
import { css as
|
|
4
|
-
import
|
|
5
|
-
import { whenOnce as
|
|
6
|
-
import
|
|
7
|
-
import { LitElement as R, createEvent as
|
|
8
|
-
import { rethrowError as
|
|
9
|
-
import { createRef as
|
|
3
|
+
import { css as C, html as l } from "lit";
|
|
4
|
+
import I from "@arcgis/core/core/Collection.js";
|
|
5
|
+
import { whenOnce as P, watch as A, when as x } from "@arcgis/core/core/reactiveUtils.js";
|
|
6
|
+
import L from "@arcgis/core/portal/Portal.js";
|
|
7
|
+
import { LitElement as R, createEvent as g, nothing as k } from "@arcgis/lumina";
|
|
8
|
+
import { rethrowError as O } from "@arcgis/toolkit/log";
|
|
9
|
+
import { createRef as _, ref as v } from "lit/directives/ref.js";
|
|
10
10
|
import { u as M } from "../../chunks/useT9n.js";
|
|
11
|
-
import { O } from "../../chunks/orchestrator.js";
|
|
11
|
+
import { O as D } from "../../chunks/orchestrator.js";
|
|
12
12
|
import "@langchain/core/callbacks/dispatch/web";
|
|
13
13
|
import "@langchain/core/prompts";
|
|
14
14
|
import "@langchain/openai";
|
|
15
|
-
import "@arcgis/core/identity/IdentityManager.js";
|
|
15
|
+
import T from "@arcgis/core/identity/IdentityManager.js";
|
|
16
16
|
import "@langchain/core/messages";
|
|
17
17
|
import "@arcgis/core/layers/FeatureLayer.js";
|
|
18
18
|
import "../../chunks/generateLayerDescriptions.js";
|
|
19
19
|
import "@langchain/langgraph/web";
|
|
20
|
-
import
|
|
21
|
-
import { property as
|
|
22
|
-
import { g as
|
|
23
|
-
import { g as
|
|
24
|
-
const
|
|
25
|
-
var
|
|
26
|
-
for (var
|
|
27
|
-
(
|
|
28
|
-
return i &&
|
|
20
|
+
import N from "@arcgis/core/core/Accessor.js";
|
|
21
|
+
import { property as b, subclass as B } from "@arcgis/core/core/accessorSupport/decorators.js";
|
|
22
|
+
import { g as V } from "../../chunks/utils3.js";
|
|
23
|
+
import { g as w } from "../../chunks/slottableRequestUtils.js";
|
|
24
|
+
const z = C`:host{display:block;width:var(--arcgis-internal-panel-width, 100%);height:var(--arcgis-internal-expand-max-height, 100%);--calcite-panel-content-bottom-space: 0}.footer-container{display:flex;flex-direction:column;flex:1 1 0;gap:var(--calcite-spacing-md)}.content-container{display:flex;flex-direction:column;flex:1 1 0;min-height:0;position:relative;overflow:auto}.suggested-prompts-container{display:flex;justify-content:center;width:100%;background:var(--calcite-panel-background-color, var(--calcite-color-background))}.suggested-prompts{display:block;padding:var(--calcite-spacing-md);max-width:100%;box-sizing:border-box}.error-notice{padding:var(--calcite-spacing-sm)}.interrupt-waiting-message{font-style:italic;color:var(--calcite-color-text-2)}`;
|
|
25
|
+
var H = Object.defineProperty, j = Object.getOwnPropertyDescriptor, m = (c, t, e, i) => {
|
|
26
|
+
for (var r = i > 1 ? void 0 : i ? j(t, e) : t, n = c.length - 1, s; n >= 0; n--)
|
|
27
|
+
(s = c[n]) && (r = (i ? s(t, e, r) : s(r)) || r);
|
|
28
|
+
return i && r && H(t, e, r), r;
|
|
29
29
|
};
|
|
30
|
-
|
|
31
|
-
|
|
32
|
-
|
|
30
|
+
const q = async (c) => await new Promise((t) => setTimeout(t, c));
|
|
31
|
+
async function* F(c, {
|
|
32
|
+
chunkSize: t = 5,
|
|
33
|
+
// chars per "token"
|
|
34
|
+
delay: e = 20
|
|
35
|
+
// ms between chunks
|
|
36
|
+
} = {}) {
|
|
37
|
+
let i = 0;
|
|
38
|
+
for (; i < c.length; )
|
|
39
|
+
yield c.slice(i, i + t), i += t, await q(e);
|
|
40
|
+
}
|
|
41
|
+
async function* E(c, t, e, i) {
|
|
42
|
+
for await (const r of F(c)) {
|
|
43
|
+
if (i?.aborted) {
|
|
44
|
+
yield { type: "cancelled", log: e, runId: t };
|
|
45
|
+
return;
|
|
46
|
+
}
|
|
47
|
+
yield { type: "block-data", blockType: "text", data: { content: r }, runId: t };
|
|
48
|
+
}
|
|
49
|
+
}
|
|
50
|
+
let d = class extends N {
|
|
51
|
+
constructor(c) {
|
|
52
|
+
super(c), this.view = null, this.loading = !1, this.processing = !1, this.processingStep = "";
|
|
33
53
|
}
|
|
34
54
|
async load() {
|
|
35
55
|
this._set("loading", !0);
|
|
@@ -43,14 +63,14 @@ let l = class extends A {
|
|
|
43
63
|
this.orchestrator?.dispose(), super.destroy();
|
|
44
64
|
}
|
|
45
65
|
async _initialize() {
|
|
46
|
-
this.removeHandles(), await Promise.all([this.portal.load(), this.view?.when()]), this.view && await
|
|
66
|
+
this.removeHandles(), await Promise.all([this.portal.load(), this.view?.when()]), this.view && await P(() => !this.view.updating), this._set(
|
|
47
67
|
"orchestrator",
|
|
48
|
-
await
|
|
68
|
+
await D.init({
|
|
49
69
|
agents: [...this.agents],
|
|
50
70
|
view: this.view ?? void 0
|
|
51
71
|
})
|
|
52
72
|
), this.addHandles([
|
|
53
|
-
|
|
73
|
+
A(
|
|
54
74
|
() => [this.view, this.agents],
|
|
55
75
|
() => {
|
|
56
76
|
this._initialize();
|
|
@@ -61,108 +81,122 @@ let l = class extends A {
|
|
|
61
81
|
clearChatHistory() {
|
|
62
82
|
this.orchestrator?.newConversation();
|
|
63
83
|
}
|
|
64
|
-
async *ask(
|
|
84
|
+
async *ask(c, t) {
|
|
65
85
|
if (!this.orchestrator)
|
|
66
86
|
throw new Error("Orchestrator not initialized yet.");
|
|
67
87
|
this._set("processing", !0), this._set("processingStep", "");
|
|
68
88
|
const e = [];
|
|
69
89
|
let i;
|
|
70
90
|
try {
|
|
71
|
-
const
|
|
72
|
-
for await (const
|
|
73
|
-
const
|
|
74
|
-
|
|
75
|
-
yield { type: "cancelled", runId: n };
|
|
76
|
-
break;
|
|
77
|
-
}
|
|
78
|
-
switch (r.type) {
|
|
91
|
+
const r = this.orchestrator.ask(c);
|
|
92
|
+
for await (const n of r) {
|
|
93
|
+
const s = n.runId;
|
|
94
|
+
switch (n.type) {
|
|
79
95
|
case "trace": {
|
|
80
|
-
this._set("processingStep",
|
|
96
|
+
this._set("processingStep", n.data.text), e.push(n.data.text);
|
|
81
97
|
break;
|
|
82
98
|
}
|
|
83
99
|
case "completed": {
|
|
84
|
-
|
|
85
|
-
|
|
86
|
-
|
|
100
|
+
this._set("processing", !1), this._set("processingStep", "");
|
|
101
|
+
const a = n.result, o = !!a.content.length, h = !!i?.length;
|
|
102
|
+
if (!o && !h) {
|
|
103
|
+
yield { type: "completed", error: "No response received.", log: e, runId: s };
|
|
87
104
|
return;
|
|
88
105
|
}
|
|
89
|
-
const
|
|
90
|
-
|
|
106
|
+
const p = a.content;
|
|
107
|
+
if (yield { type: "block-start", blockType: "text", runId: s }, yield* E(p, s, e, t), yield { type: "block-end", blockType: "text", runId: s }, h)
|
|
108
|
+
for (const f of i) {
|
|
109
|
+
if (t?.aborted) {
|
|
110
|
+
yield { type: "cancelled", log: e, runId: s };
|
|
111
|
+
return;
|
|
112
|
+
}
|
|
113
|
+
const { type: u, data: y } = f;
|
|
114
|
+
if (yield { type: "block-start", blockType: u, runId: s }, u === "text") {
|
|
115
|
+
const S = typeof y?.content == "string" ? y.content : "";
|
|
116
|
+
yield* E(S, s, e, t);
|
|
117
|
+
} else
|
|
118
|
+
yield { type: "block-data", blockType: u, data: y, runId: s };
|
|
119
|
+
yield { type: "block-end", blockType: u, runId: s };
|
|
120
|
+
}
|
|
121
|
+
yield { type: "completed", response: p, blocks: i, log: e, runId: s };
|
|
91
122
|
return;
|
|
92
123
|
}
|
|
93
124
|
case "ux-suggestion": {
|
|
94
|
-
const
|
|
95
|
-
i = i ? [...i,
|
|
125
|
+
const a = n.suggestion;
|
|
126
|
+
i = i ? [...i, a] : [a];
|
|
96
127
|
break;
|
|
97
128
|
}
|
|
98
129
|
case "interrupt": {
|
|
99
|
-
const { kind:
|
|
100
|
-
switch (
|
|
130
|
+
const { kind: a, message: o, metadata: h } = n.interrupt, p = Array.isArray(h) ? h.filter((u) => typeof u == "string") : [], f = (() => {
|
|
131
|
+
switch (a) {
|
|
101
132
|
case "booleanChoice":
|
|
102
|
-
return { type: "boolean-choice", message:
|
|
133
|
+
return { type: "boolean-choice", message: o, options: p };
|
|
103
134
|
case "singleSelection":
|
|
104
|
-
return { type: "single-select", message:
|
|
135
|
+
return { type: "single-select", message: o, options: p };
|
|
105
136
|
case "multipleSelection":
|
|
106
|
-
return { type: "multi-select", message:
|
|
137
|
+
return { type: "multi-select", message: o, options: p };
|
|
107
138
|
case "textInput":
|
|
108
|
-
return { type: "text-input", message:
|
|
139
|
+
return { type: "text-input", message: o };
|
|
109
140
|
default:
|
|
110
|
-
return { type:
|
|
141
|
+
return { type: a, message: o, options: p };
|
|
111
142
|
}
|
|
112
143
|
})();
|
|
113
|
-
this._set("processingStep", "Waiting for user input..."), yield { type: "interrupt", payload:
|
|
144
|
+
this._set("processingStep", "Waiting for user input..."), yield { type: "interrupt", payload: f, runId: s };
|
|
114
145
|
break;
|
|
115
146
|
}
|
|
116
147
|
case "cancelled": {
|
|
117
|
-
yield { type: "cancelled", runId:
|
|
148
|
+
yield { type: "cancelled", log: e, runId: s };
|
|
118
149
|
return;
|
|
119
150
|
}
|
|
120
151
|
case "error": {
|
|
121
|
-
yield { type: "completed", error:
|
|
152
|
+
yield { type: "completed", error: n.error.message, log: e, runId: s };
|
|
122
153
|
return;
|
|
123
154
|
}
|
|
124
155
|
default: {
|
|
125
|
-
console.warn("Unknown event type:",
|
|
156
|
+
console.warn("Unknown event type:", n);
|
|
126
157
|
break;
|
|
127
158
|
}
|
|
128
159
|
}
|
|
129
160
|
}
|
|
130
|
-
} catch (
|
|
131
|
-
console.warn("Error during message processing:",
|
|
161
|
+
} catch (r) {
|
|
162
|
+
console.warn("Error during message processing:", r), yield { type: "completed", error: "An error occurred during message processing.", log: e, runId: "error" };
|
|
132
163
|
return;
|
|
133
164
|
} finally {
|
|
134
165
|
this._set("processing", !1);
|
|
135
166
|
}
|
|
136
167
|
}
|
|
168
|
+
cancel() {
|
|
169
|
+
this.orchestrator?.cancel();
|
|
170
|
+
}
|
|
137
171
|
};
|
|
138
|
-
|
|
139
|
-
|
|
140
|
-
],
|
|
141
|
-
|
|
142
|
-
|
|
143
|
-
],
|
|
144
|
-
|
|
145
|
-
|
|
146
|
-
],
|
|
147
|
-
|
|
148
|
-
|
|
149
|
-
],
|
|
150
|
-
|
|
151
|
-
|
|
152
|
-
],
|
|
153
|
-
|
|
154
|
-
|
|
155
|
-
],
|
|
156
|
-
|
|
157
|
-
|
|
158
|
-
],
|
|
159
|
-
|
|
160
|
-
|
|
161
|
-
],
|
|
162
|
-
const
|
|
163
|
-
class
|
|
172
|
+
m([
|
|
173
|
+
b({ readOnly: !0 })
|
|
174
|
+
], d.prototype, "orchestrator", 2);
|
|
175
|
+
m([
|
|
176
|
+
b()
|
|
177
|
+
], d.prototype, "agents", 2);
|
|
178
|
+
m([
|
|
179
|
+
b()
|
|
180
|
+
], d.prototype, "portal", 2);
|
|
181
|
+
m([
|
|
182
|
+
b()
|
|
183
|
+
], d.prototype, "view", 2);
|
|
184
|
+
m([
|
|
185
|
+
b({ readOnly: !0 })
|
|
186
|
+
], d.prototype, "loading", 2);
|
|
187
|
+
m([
|
|
188
|
+
b({ readOnly: !0 })
|
|
189
|
+
], d.prototype, "processing", 2);
|
|
190
|
+
m([
|
|
191
|
+
b({ readOnly: !0 })
|
|
192
|
+
], d.prototype, "processingStep", 2);
|
|
193
|
+
d = m([
|
|
194
|
+
B("OrchestratorController")
|
|
195
|
+
], d);
|
|
196
|
+
const G = "Embeddings resource 'embeddings-v01.json' not found in the webmap portal item.", U = "Embeddings not found for this web map.", W = "https://developers.arcgis.com/javascript/latest/agentic-apps/ai-webmap-setup/#embeddings";
|
|
197
|
+
class Y extends R {
|
|
164
198
|
constructor() {
|
|
165
|
-
super(...arguments), this._messages = M({ blocking: !0 }), this.#t =
|
|
199
|
+
super(...arguments), this._messages = M({ blocking: !0 }), this.#t = _(), this.#n = _(), this.#s = _(), this.#e = null, this.#o = /* @__PURE__ */ new Map(), this.#i = L.getDefault(), this.#r = (t) => {
|
|
166
200
|
t.stopPropagation(), this.cancelInterrupt();
|
|
167
201
|
}, this.#a = (t) => {
|
|
168
202
|
t.stopPropagation();
|
|
@@ -173,11 +207,11 @@ class F extends R {
|
|
|
173
207
|
const e = t.detail;
|
|
174
208
|
this._inputValue = "", this.arcgisSubmit.emit(e), this.submitMessage(e);
|
|
175
209
|
}, this.#c = (t) => {
|
|
176
|
-
if (t.stopPropagation(), this.arcgisCancel.emit(), this._interrupt) {
|
|
210
|
+
if (this._canceling = !0, t.stopPropagation(), this.arcgisCancel.emit(), this._interrupt) {
|
|
177
211
|
this.orchestrator?.cancelInterrupt(), this._interrupt = null;
|
|
178
212
|
return;
|
|
179
213
|
}
|
|
180
|
-
this.#
|
|
214
|
+
this._orchestratorController?.cancel(), this.#e?.abort(), this.#e = null;
|
|
181
215
|
}, this.#h = (t) => {
|
|
182
216
|
t.stopPropagation();
|
|
183
217
|
const e = t.detail;
|
|
@@ -188,43 +222,43 @@ class F extends R {
|
|
|
188
222
|
this._inputValue = e.prompt, this.arcgisPromptSelect.emit(e);
|
|
189
223
|
}, this.#g = (t) => {
|
|
190
224
|
this.arcgisSlottableRequest.emit(t.detail);
|
|
191
|
-
}, this._orchestratorController = null, this._interrupt = null, this._error = null, this._inputValue = "", this.messages = new
|
|
225
|
+
}, this._orchestratorController = null, this._interrupt = null, this._interruptDetails = [], this._error = null, this._inputValue = "", this._isAnswering = !1, this._canceling = !1, this.messages = new I([]), this.referenceElement = null, this.suggestedPrompts = [], this.feedbackEnabled = !1, this.keepSuggestedPrompts = !1, this.logEnabled = !1, this.copyEnabled = !1, this.voiceInputEnabled = !1, this.readAloudEnabled = !1, this.assistantAvatarEnabled = !1, this.arcgisCancel = g(), this.arcgisError = g(), this.arcgisFeedback = g(), this.arcgisInterrupt = g(), this.arcgisInterruptCancel = g(), this.arcgisInterruptSubmit = g(), this.arcgisPromptSelect = g(), this.arcgisReady = g(), this.arcgisSubmit = g(), this.arcgisSlottableRequest = g({ bubbles: !1, composed: !1 }), this.arcgisResponse = g();
|
|
192
226
|
}
|
|
193
227
|
static {
|
|
194
|
-
this.properties = { _orchestratorController: 16, _interrupt: 16, _error: 16, _inputValue: 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 };
|
|
228
|
+
this.properties = { _orchestratorController: 16, _interrupt: 16, _interruptDetails: 16, _error: 16, _inputValue: 16, _isAnswering: 16, _canceling: 16, _user: 16, awaitingResponse: 32, awaitingResponseStep: 32, interrupt: 32, messages: 0, orchestrator: 32, entryMessage: 1, heading: 1, description: 1, referenceElement: 1, suggestedPrompts: 0, feedbackEnabled: 5, keepSuggestedPrompts: 5, logEnabled: 5, copyEnabled: 5, voiceInputEnabled: 5, readAloudEnabled: 5, assistantAvatarEnabled: 5 };
|
|
195
229
|
}
|
|
196
230
|
static {
|
|
197
|
-
this.styles =
|
|
231
|
+
this.styles = z;
|
|
198
232
|
}
|
|
199
233
|
#t;
|
|
200
234
|
#n;
|
|
201
|
-
#e;
|
|
202
235
|
#s;
|
|
236
|
+
#e;
|
|
203
237
|
#o;
|
|
204
|
-
#r;
|
|
205
238
|
#i;
|
|
239
|
+
#r;
|
|
206
240
|
#a;
|
|
207
241
|
#l;
|
|
208
242
|
#c;
|
|
209
243
|
#h;
|
|
210
244
|
#p;
|
|
211
245
|
#g;
|
|
212
|
-
async #
|
|
246
|
+
async #d() {
|
|
213
247
|
try {
|
|
214
|
-
const t =
|
|
248
|
+
const t = V(this.el, this.referenceElement);
|
|
215
249
|
await t?.componentOnReady();
|
|
216
250
|
const e = [...this.#o.values()];
|
|
217
|
-
return e.length ? (this._orchestratorController = new
|
|
251
|
+
return e.length ? (this._orchestratorController = new d({
|
|
218
252
|
agents: e,
|
|
219
|
-
portal: this.#
|
|
253
|
+
portal: this.#i,
|
|
220
254
|
view: t?.view
|
|
221
255
|
}), await this._orchestratorController.load(), !0) : (this._error = "No agents found.", !1);
|
|
222
256
|
} catch (t) {
|
|
223
|
-
return this._error = t?.message ?? "Error initializing orchestrator.",
|
|
257
|
+
return this._error = t?.message ?? "Error initializing orchestrator.", O(this)(t), !1;
|
|
224
258
|
}
|
|
225
259
|
}
|
|
226
260
|
get _user() {
|
|
227
|
-
return this.#
|
|
261
|
+
return this.#i?.user?.fullName || this.#i?.user?.username;
|
|
228
262
|
}
|
|
229
263
|
get awaitingResponse() {
|
|
230
264
|
return this._orchestratorController?.processing ?? !1;
|
|
@@ -256,35 +290,91 @@ class F extends R {
|
|
|
256
290
|
content: e
|
|
257
291
|
}), !this._orchestratorController))
|
|
258
292
|
return;
|
|
259
|
-
|
|
260
|
-
|
|
261
|
-
|
|
262
|
-
|
|
293
|
+
this.#e = new AbortController();
|
|
294
|
+
const i = this._orchestratorController.ask(e, this.#e?.signal);
|
|
295
|
+
for await (const r of i) {
|
|
296
|
+
const n = r.runId, s = this.messages.at(-1);
|
|
297
|
+
switch (r.type) {
|
|
298
|
+
case "block-start": {
|
|
299
|
+
this._isAnswering = !0;
|
|
300
|
+
const a = { type: r.blockType, isPending: !0 };
|
|
301
|
+
if (s?.role === "assistant" && s.id === n) {
|
|
302
|
+
const o = [...s.blocks ?? [], a];
|
|
303
|
+
this.messages.splice(-1, 1, { ...s, blocks: o });
|
|
304
|
+
} else
|
|
305
|
+
this.messages.push({
|
|
306
|
+
role: "assistant",
|
|
307
|
+
blocks: [a],
|
|
308
|
+
id: n,
|
|
309
|
+
isStreaming: !0,
|
|
310
|
+
interrupts: this._interruptDetails
|
|
311
|
+
}), this._interruptDetails = [];
|
|
312
|
+
break;
|
|
313
|
+
}
|
|
314
|
+
case "block-data": {
|
|
315
|
+
if (s?.role !== "assistant" || s?.id !== n)
|
|
316
|
+
break;
|
|
317
|
+
const a = [...s.blocks ?? []], o = a[a.length - 1], { blockType: h, data: p } = r;
|
|
318
|
+
if (o?.type !== h || !o.isPending)
|
|
319
|
+
break;
|
|
320
|
+
if (h === "text") {
|
|
321
|
+
const f = typeof o.data?.content == "string" ? o.data.content : "", u = typeof p?.content == "string" ? p.content : "";
|
|
322
|
+
a[a.length - 1] = { ...o, data: { ...o.data, content: f + u } };
|
|
323
|
+
} else
|
|
324
|
+
a[a.length - 1] = { ...o, data: { ...o.data, ...p ?? {} } };
|
|
325
|
+
this.messages.splice(-1, 1, { ...s, blocks: a });
|
|
326
|
+
break;
|
|
327
|
+
}
|
|
328
|
+
case "block-end": {
|
|
329
|
+
if (s?.role !== "assistant" || s?.id !== n)
|
|
330
|
+
break;
|
|
331
|
+
const a = [...s.blocks ?? []], o = a[a.length - 1];
|
|
332
|
+
if (o?.type !== r.blockType || !o.isPending)
|
|
333
|
+
break;
|
|
334
|
+
const h = o;
|
|
335
|
+
a[a.length - 1] = { ...h, data: { ...h.data }, isPending: !1 }, this.messages.splice(-1, 1, { ...s, blocks: a });
|
|
336
|
+
break;
|
|
337
|
+
}
|
|
263
338
|
case "completed":
|
|
264
|
-
this.messages.push({
|
|
339
|
+
r.error ? (this.messages.push({
|
|
265
340
|
role: "assistant",
|
|
266
|
-
|
|
267
|
-
|
|
268
|
-
|
|
269
|
-
|
|
270
|
-
|
|
271
|
-
|
|
341
|
+
log: r.log,
|
|
342
|
+
error: r.error,
|
|
343
|
+
id: n,
|
|
344
|
+
interrupts: this._interruptDetails
|
|
345
|
+
}), this._interruptDetails = []) : s?.role === "assistant" && s.id === n && this.messages.splice(-1, 1, {
|
|
346
|
+
...s,
|
|
347
|
+
content: r.response,
|
|
348
|
+
blocks: s.blocks?.map((a) => ({ ...a, isPending: !1 })) ?? [],
|
|
349
|
+
isStreaming: !1,
|
|
350
|
+
log: r.log
|
|
351
|
+
}), this._isAnswering = !1, this.#e = null, this._canceling = !1;
|
|
272
352
|
break;
|
|
273
353
|
case "interrupt":
|
|
274
|
-
this._interrupt = { ...
|
|
354
|
+
this._interrupt = { ...r.payload, id: n }, this.arcgisInterrupt.emit(this._interrupt);
|
|
275
355
|
break;
|
|
276
356
|
case "cancelled":
|
|
277
|
-
this.messages.
|
|
357
|
+
s?.role === "assistant" && s.id === n ? this.messages.splice(-1, 1, {
|
|
358
|
+
...s,
|
|
359
|
+
blocks: s.blocks?.filter((a) => a.type === "text" || !a.isPending) ?? [],
|
|
360
|
+
isStreaming: !1,
|
|
361
|
+
log: r.log,
|
|
362
|
+
error: "(Stopped by user)"
|
|
363
|
+
// TODO: use strings from t9n
|
|
364
|
+
}) : (this.messages.push({
|
|
278
365
|
role: "assistant",
|
|
279
|
-
|
|
280
|
-
|
|
281
|
-
|
|
366
|
+
log: r.log,
|
|
367
|
+
error: "(Stopped by user)",
|
|
368
|
+
// TODO: use strings from t9n
|
|
369
|
+
id: n,
|
|
370
|
+
interrupts: this._interruptDetails
|
|
371
|
+
}), this._interruptDetails = []), this._isAnswering = !1, this.#e = null, this._canceling = !1;
|
|
282
372
|
break;
|
|
283
373
|
}
|
|
284
374
|
}
|
|
285
375
|
}
|
|
286
376
|
submitInterrupt(t) {
|
|
287
|
-
this.arcgisInterruptSubmit.emit(t), this.orchestrator?.resumeInterrupt(t), this._interrupt = null;
|
|
377
|
+
this.arcgisInterruptSubmit.emit(t), this._interrupt && (this._interruptDetails = [...this._interruptDetails, { interrupt: this._interrupt, response: t }]), this.orchestrator?.resumeInterrupt(t), this._interrupt = null;
|
|
288
378
|
}
|
|
289
379
|
load() {
|
|
290
380
|
this.manager.onLifecycle(this._reset.bind(this));
|
|
@@ -292,38 +382,48 @@ class F extends R {
|
|
|
292
382
|
loaded() {
|
|
293
383
|
this.manager.onLifecycle(() => {
|
|
294
384
|
this.#t.value?.addEventListener("arcgisPromptSelect", this.#p), this.#t.value?.addEventListener("arcgisSubmit", this.#l), this.#t.value?.addEventListener("arcgisCancel", this.#c), this.#t.value?.addEventListener("arcgisFeedback", this.#h);
|
|
295
|
-
const t =
|
|
296
|
-
const
|
|
297
|
-
|
|
385
|
+
const t = x(() => !!this._interrupt && !!this.#s.value, () => {
|
|
386
|
+
const i = this.#s.value;
|
|
387
|
+
i.removeEventListener("arcgisSubmit", this.#a), i.removeEventListener("arcgisCancel", this.#r), i.addEventListener("arcgisSubmit", this.#a, { once: !0 }), i.addEventListener("arcgisCancel", this.#r, { once: !0 });
|
|
388
|
+
}), e = this.messages.on("after-add", (i) => {
|
|
389
|
+
const r = i.item;
|
|
390
|
+
r.role === "assistant" && (r.error || r.content) && this.arcgisResponse.emit(r);
|
|
298
391
|
});
|
|
299
392
|
return queueMicrotask(() => {
|
|
300
|
-
this.#
|
|
301
|
-
|
|
393
|
+
this.#d().then((i) => {
|
|
394
|
+
i ? this.arcgisReady.emit() : this._error && this.arcgisError.emit(new Error(this._error));
|
|
302
395
|
});
|
|
303
396
|
}), () => {
|
|
304
|
-
t.remove(), this.#t.value?.removeEventListener("arcgisPromptSelect", this.#p), this.#
|
|
397
|
+
t.remove(), e.remove(), this.#t.value?.removeEventListener("arcgisPromptSelect", this.#p), this.#s.value?.removeEventListener("arcgisSubmit", this.#a), this.#s.value?.removeEventListener("arcgisCancel", this.#r), this.#t.value?.removeEventListener("arcgisSubmit", this.#l), this.#t.value?.removeEventListener("arcgisCancel", this.#c), this.#t.value?.removeEventListener("arcgisFeedback", this.#h), this._orchestratorController?.destroy(), this._orchestratorController = null;
|
|
305
398
|
};
|
|
306
399
|
});
|
|
307
400
|
}
|
|
308
401
|
_reset() {
|
|
309
|
-
this.#
|
|
402
|
+
this._orchestratorController?.cancel(), this.#e?.abort(), this._interrupt = null, this.messages.removeAll(), this._error = null, this._inputValue = "";
|
|
310
403
|
}
|
|
311
404
|
_renderEntryMessage() {
|
|
312
|
-
return this.
|
|
405
|
+
return !this._user ? this._renderSignInNotice() : this._error ? this._renderErrorNotice() : this.entryMessage ? this.messages.length > 0 ? null : l`<calcite-notice open kind=brand closable icon width=full><div slot=message>${this.entryMessage}</div></calcite-notice>` : l`<slot name=entry-message></slot>`;
|
|
313
406
|
}
|
|
314
|
-
|
|
315
|
-
|
|
407
|
+
_renderSignInNotice() {
|
|
408
|
+
const t = this.#i;
|
|
409
|
+
return l`<calcite-notice slot=entry-message open kind=brand icon width=full><div slot=message>You need to sign in to use the assistant chat.</div>${t ? l`<calcite-link slot=link @click=${async () => {
|
|
410
|
+
try {
|
|
411
|
+
await T.getCredential(t.url), this._error = null, await this.#d(), this.arcgisReady.emit();
|
|
412
|
+
} catch (e) {
|
|
413
|
+
console.error("Error signing in:", e);
|
|
414
|
+
}
|
|
415
|
+
}} target=_blank title="Sign in to ArcGIS Online">Sign in</calcite-link>` : l`<div slot=link>No portal information available</div>`}</calcite-notice>`;
|
|
316
416
|
}
|
|
317
|
-
|
|
318
|
-
return this.
|
|
417
|
+
_renderErrorNotice() {
|
|
418
|
+
return this._error ? l`<calcite-notice slot=entry-message open kind=brand icon width=full>${this._error === G ? l`<div slot=message>${U}</div><calcite-link slot=link .href=${W} target=_blank title="Learn about web map embeddings">Read more</calcite-link>` : l`<div slot=message>${this._error}</div>`}</calcite-notice>` : null;
|
|
319
419
|
}
|
|
320
420
|
render() {
|
|
321
|
-
return
|
|
421
|
+
return l`<calcite-panel .loading=${!this._orchestratorController && !this._error || this._orchestratorController?.loading} .heading=${this.heading ?? this._messages.assistantLabel} .description=${this.description} ${v(this.#t)}><slot name=header-actions-start slot=header-actions-start></slot><slot name=header-actions-end slot=header-actions-end></slot><div class="content-container"><arcgis-assistant-chat .loading=${this.awaitingResponse} .messages=${this.messages} .interrupt=${this._interrupt}><slot name=message-starter slot=message-starter></slot><slot name=messages slot=messages>${this.messages.map((t) => t.role === "assistant" ? l`<arcgis-assistant-message .message=${t} .feedbackEnabled=${this.feedbackEnabled} .logEnabled=${this.logEnabled} .copyEnabled=${this.copyEnabled} .readAloudEnabled=${this.readAloudEnabled} @arcgisSlottableRequest=${this.#g} .assistantAvatarEnabled=${this.assistantAvatarEnabled}>${t.blocks?.map((e, i) => l`<slot name=${w(t.id, i) ?? k} slot=${w(t.id, i) ?? k}><arcgis-assistant-message-block .block=${e}></arcgis-assistant-message-block></slot>`)}</arcgis-assistant-message>` : l`<arcgis-assistant-user-message .message=${t} .user=${this._user}></arcgis-assistant-user-message>`)}</slot>${this._interrupt ? l`<div slot=message-loading><div class="interrupt-waiting-message">waiting for user input...</div> // TODO: use t9n strings</div>` : l`<slot name=message-loading slot=message-loading><arcgis-assistant-message-loading .loading=${this.awaitingResponse} .loadingMessage=${this.awaitingResponseStep} .assistantAvatarEnabled=${this.assistantAvatarEnabled} .interrupts=${this._interruptDetails}></arcgis-assistant-message-loading></slot>`}</arcgis-assistant-chat></div>${this._interrupt ? l`<arcgis-assistant-interrupt slot=content-bottom .type=${this._interrupt.type} .message=${this._interrupt.message} .options=${this._interrupt.options} ${v(this.#s)}></arcgis-assistant-interrupt>` : this.suggestedPrompts?.length ? l`<div class="suggested-prompts-container" slot=content-bottom><arcgis-assistant-suggested-prompts class="suggested-prompts" .prompts=${this.suggestedPrompts}></arcgis-assistant-suggested-prompts></div>` : null}<div class="footer-container" slot=footer>${this._renderEntryMessage()}<slot name=chat-entry><arcgis-assistant-chat-entry .awaitingResponse=${this.awaitingResponse || this._isAnswering} .inputValue=${this._inputValue} .messages=${this.messages} .voiceInputEnabled=${this.voiceInputEnabled} .disabled=${this._canceling || !this._user || !!this._interrupt} ${v(this.#n)}><slot name=entry-actions-start slot=entry-actions-start></slot><slot name=entry-actions-end slot=entry-actions-end><calcite-button .iconStart=${this.awaitingResponse || this._isAnswering ? "circle-stop" : "send"} @click=${() => {
|
|
322
422
|
this.#n.value?.submitMessage();
|
|
323
|
-
}} round>${this.awaitingResponse ? this._messages.stopButtonLabel : this._messages.askButtonLabel}</calcite-button></slot></arcgis-assistant-chat-entry></slot><slot name=footer-content></slot></div></calcite-panel>`;
|
|
423
|
+
}} 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>`;
|
|
324
424
|
}
|
|
325
425
|
}
|
|
326
|
-
$("arcgis-assistant",
|
|
426
|
+
$("arcgis-assistant", Y);
|
|
327
427
|
export {
|
|
328
|
-
|
|
428
|
+
Y as ArcgisAssistant
|
|
329
429
|
};
|
|
@@ -1,14 +1,13 @@
|
|
|
1
|
-
import "../arcgis-assistant-interrupt/index.js";
|
|
2
1
|
import "@esri/calcite-components/components/calcite-notice";
|
|
3
2
|
import "@esri/calcite-components/components/calcite-link";
|
|
4
|
-
import "../arcgis-assistant-suggested-prompts/index.js";
|
|
5
3
|
import "@esri/calcite-components/components/calcite-panel";
|
|
6
4
|
import "../arcgis-assistant-chat/index.js";
|
|
7
5
|
import "../arcgis-assistant-message/index.js";
|
|
8
|
-
import "../arcgis-assistant-message-text/index.js";
|
|
9
6
|
import "../arcgis-assistant-message-block/index.js";
|
|
10
7
|
import "../arcgis-assistant-user-message/index.js";
|
|
11
8
|
import "../arcgis-assistant-message-loading/index.js";
|
|
9
|
+
import "../arcgis-assistant-interrupt/index.js";
|
|
10
|
+
import "../arcgis-assistant-suggested-prompts/index.js";
|
|
12
11
|
import "../arcgis-assistant-chat-entry/index.js";
|
|
13
12
|
import "@esri/calcite-components/components/calcite-button";
|
|
14
13
|
export * from "./customElement.js";
|
|
@@ -51,7 +51,7 @@ export interface AssistantMessage extends ChatMessageBase {
|
|
|
51
51
|
* UI elements separate from the plain text transcript and can be used to display actions, follow-up prompts,
|
|
52
52
|
* or app-registered custom content.
|
|
53
53
|
*/
|
|
54
|
-
blocks?: UXSuggestion[];
|
|
54
|
+
blocks?: (UXSuggestion & { isPending?: boolean; })[];
|
|
55
55
|
/**
|
|
56
56
|
* Log messages related to the assistant's processing of the user's request. This can include information about
|
|
57
57
|
* the agents or tools it invoked, the parameters generated by the LLM, and any relevant details about how it
|
|
@@ -71,6 +71,19 @@ export interface AssistantMessage extends ChatMessageBase {
|
|
|
71
71
|
* performance over time.
|
|
72
72
|
*/
|
|
73
73
|
feedback?: Feedback;
|
|
74
|
+
/**
|
|
75
|
+
* Indicates whether the message content is still being streamed from the assistant. This can be used to show loading
|
|
76
|
+
* indicators or placeholders in the UI until the full content is received.
|
|
77
|
+
*/
|
|
78
|
+
isStreaming?: boolean;
|
|
79
|
+
/**
|
|
80
|
+
* An array of interrupts emitted by the assistant during the processing of the user's request. Each interrupt includes
|
|
81
|
+
* details about the type of interrupt, the message to display to the user, and any options for user input.
|
|
82
|
+
*/
|
|
83
|
+
interrupts?: {
|
|
84
|
+
interrupt: Interrupt;
|
|
85
|
+
response?: string[] | boolean | string;
|
|
86
|
+
}[];
|
|
74
87
|
}
|
|
75
88
|
|
|
76
89
|
/**
|
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
/// <reference path="../../index.d.ts" />
|
|
2
2
|
import type Collection from "@arcgis/core/core/Collection.js";
|
|
3
3
|
import type { PublicLitElement as LitElement } from "@arcgis/lumina";
|
|
4
|
-
import type { ChatMessage } from "../arcgis-assistant/types.js";
|
|
4
|
+
import type { ChatMessage, Interrupt } from "../arcgis-assistant/types.js";
|
|
5
5
|
|
|
6
6
|
/**
|
|
7
7
|
* Wraps and renders the conversation area. Use it as the container for message list content.
|
|
@@ -10,6 +10,7 @@ import type { ChatMessage } from "../arcgis-assistant/types.js";
|
|
|
10
10
|
* @internal
|
|
11
11
|
*/
|
|
12
12
|
export abstract class ArcgisAssistantChat extends LitElement {
|
|
13
|
+
accessor interrupt: Interrupt | null;
|
|
13
14
|
/** @default false */
|
|
14
15
|
accessor loading: boolean;
|
|
15
16
|
accessor messages: Collection<ChatMessage>;
|
|
@@ -4,17 +4,17 @@ import { css as e, html as t } from "lit";
|
|
|
4
4
|
import { LitElement as i } from "@arcgis/lumina";
|
|
5
5
|
import { createRef as a, ref as o } from "lit/directives/ref.js";
|
|
6
6
|
import l from "@arcgis/core/core/Collection.js";
|
|
7
|
-
import { watch as
|
|
8
|
-
const
|
|
7
|
+
import { watch as n } from "@arcgis/core/core/reactiveUtils.js";
|
|
8
|
+
const r = e`.messages-container{display:flex;flex:1;flex-direction:column;line-height:var(--calcite-font-line-height-relative-snug)}.messages-list{padding:var(--calcite-spacing-lg);display:flex;flex-direction:column;gap:var(--calcite-spacing-xxl);flex:1 1 auto;min-height:0;justify-content:flex-end;overflow:auto}`;
|
|
9
9
|
class c extends i {
|
|
10
10
|
constructor() {
|
|
11
|
-
super(...arguments), this.#s = a(), this.loading = !1, this.messages = new l([]);
|
|
11
|
+
super(...arguments), this.#s = a(), this.loading = !1, this.messages = new l([]), this.interrupt = null;
|
|
12
12
|
}
|
|
13
13
|
static {
|
|
14
|
-
this.properties = { loading: 5, messages: 0 };
|
|
14
|
+
this.properties = { loading: 5, messages: 0, interrupt: 0 };
|
|
15
15
|
}
|
|
16
16
|
static {
|
|
17
|
-
this.styles =
|
|
17
|
+
this.styles = r;
|
|
18
18
|
}
|
|
19
19
|
#s;
|
|
20
20
|
firstUpdated() {
|
|
@@ -23,9 +23,9 @@ class c extends i {
|
|
|
23
23
|
loaded() {
|
|
24
24
|
this.manager.onLifecycle(() => [
|
|
25
25
|
this.messages.on("change", () => {
|
|
26
|
-
this.
|
|
26
|
+
this._scrollToEnd();
|
|
27
27
|
}),
|
|
28
|
-
|
|
28
|
+
n(() => [this.loading, this.interrupt], () => {
|
|
29
29
|
this._scrollToEnd();
|
|
30
30
|
})
|
|
31
31
|
]);
|