@arcgis/ai-components 5.2.0-next.12 → 5.2.0-next.14
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/dist/agent-utils/LLMAgent.js +1 -0
- package/dist/cdn/{5CV7R5IS.js → 22IT5TDB.js} +2 -2
- package/dist/cdn/{EBISDZ5H.js → 4UDYY3HL.js} +1 -1
- package/dist/cdn/7PANDHIL.js +16 -0
- package/dist/cdn/ADYIXCSG.js +2 -0
- package/dist/cdn/CAECQD75.js +2 -0
- package/dist/cdn/{34SG44C3.js → CE6VDP2D.js} +1 -1
- package/dist/cdn/CI3QSFPS.js +2 -0
- package/dist/cdn/DEAYZ3MK.js +2 -0
- package/dist/cdn/{YLN2BZ5J.js → E2HENO3T.js} +1 -1
- package/dist/cdn/FWU6DFIB.js +2 -0
- package/dist/cdn/GBYLKQIL.js +2 -0
- package/dist/cdn/GPYYAQVI.js +2 -0
- package/dist/cdn/{ERL2CB2Y.js → I2Y67HBL.js} +5 -5
- package/dist/cdn/JG2BIENI.js +3 -0
- package/dist/cdn/JN744CAW.js +2 -0
- package/dist/cdn/K475UT3E.js +2 -0
- package/dist/cdn/{JLKGS6Y5.js → L4XF4H6V.js} +1 -1
- package/dist/cdn/M3SWPT3M.js +2 -0
- package/dist/cdn/MAV3DW27.js +4 -0
- package/dist/cdn/PB2ODJC7.js +2 -0
- package/dist/cdn/{QCSN44H4.js → QSA4T3BU.js} +1 -1
- package/dist/cdn/{R56X6ZKR.js → QYR3NSF2.js} +3 -3
- package/dist/cdn/RMLXVQZ5.js +2 -0
- package/dist/cdn/{T43LEBBE.js → S75VFYR4.js} +18 -18
- package/dist/cdn/SBHLUL3Q.js +2 -0
- package/dist/cdn/{X2ZDYHCG.js → TNMXWUXU.js} +9 -4
- package/dist/cdn/WH6QQK6N.js +2 -0
- package/dist/cdn/XBW4MWQR.js +2 -0
- package/dist/cdn/{Z2G7MP5L.js → XU6NCSE2.js} +1 -1
- package/dist/cdn/Z7UWJ4AI.js +3 -0
- package/dist/cdn/ZOSUDIJH.js +2 -0
- package/dist/cdn/ZPLFFLPF.js +2 -0
- package/dist/cdn/agent-utils/index.js +1 -1
- package/dist/cdn/index.js +1 -1
- package/dist/chunks/adapter.js +170 -169
- package/dist/chunks/arcgisKnowledgeGraph.js +8 -7
- package/dist/chunks/dataExplorationGraph.js +88 -76
- package/dist/chunks/data_explore_query_prompt.js +9 -4
- package/dist/chunks/generateLayerDescriptions.js +161 -159
- package/dist/chunks/helpGraph.js +3 -2
- package/dist/chunks/layerStylingGraph.js +1 -0
- package/dist/chunks/navigationGraph.js +3 -2
- package/dist/chunks/orchestrator.js +108 -107
- package/dist/chunks/toolCallResponse.js +10 -9
- package/dist/components/arcgis-assistant/customElement.js +136 -124
- package/dist/components/arcgis-assistant-data-exploration-agent/customElement.js +3 -2
- package/dist/components/arcgis-assistant-help-agent/customElement.js +1 -0
- package/dist/components/arcgis-assistant-knowledge-agent/customElement.js +4 -3
- package/dist/components/arcgis-assistant-layer-styling-agent/customElement.js +1 -0
- package/dist/components/arcgis-assistant-navigation-agent/customElement.js +1 -0
- package/dist/docs/api.json +1 -1
- package/dist/docs/docs.json +1 -1
- package/dist/docs/web-types.json +1 -1
- package/package.json +5 -5
- package/dist/cdn/24QNMEFG.js +0 -2
- package/dist/cdn/3NBDVZ2I.js +0 -2
- package/dist/cdn/53NTYC4I.js +0 -2
- package/dist/cdn/AZGGTNA3.js +0 -2
- package/dist/cdn/B7WJFBOZ.js +0 -2
- package/dist/cdn/DZ2QWNUA.js +0 -3
- package/dist/cdn/F6QHMKF5.js +0 -2
- package/dist/cdn/H2CHHGGH.js +0 -2
- package/dist/cdn/HWKDNS4K.js +0 -4
- package/dist/cdn/IMQ4TVHF.js +0 -16
- package/dist/cdn/IRZDTYO2.js +0 -2
- package/dist/cdn/KHXUWZHB.js +0 -2
- package/dist/cdn/LIFK3QSD.js +0 -2
- package/dist/cdn/O3EN27N5.js +0 -2
- package/dist/cdn/PBO6FZN6.js +0 -2
- package/dist/cdn/Q3ZW4FYA.js +0 -3
- package/dist/cdn/UPEEHMSY.js +0 -2
- package/dist/cdn/WAIFKDR3.js +0 -2
- package/dist/cdn/XON27U6U.js +0 -2
- package/dist/cdn/YUKR4AZW.js +0 -2
|
@@ -1,56 +1,58 @@
|
|
|
1
1
|
/* COPYRIGHT Esri - https://js.arcgis.com/5.2/LICENSE.txt */
|
|
2
|
-
import { c as
|
|
3
|
-
import { css as C, html as
|
|
4
|
-
import
|
|
5
|
-
import { whenOnce as
|
|
6
|
-
import
|
|
7
|
-
import { LitElement as
|
|
8
|
-
import
|
|
2
|
+
import { c as I } from "../../chunks/runtime.js";
|
|
3
|
+
import { css as C, html as c } from "lit";
|
|
4
|
+
import P from "@arcgis/core/core/Collection.js";
|
|
5
|
+
import { whenOnce as A, watch as L, when as x } from "@arcgis/core/core/reactiveUtils.js";
|
|
6
|
+
import R from "@arcgis/core/portal/Portal.js";
|
|
7
|
+
import { LitElement as M, createEvent as p, nothing as k } from "@arcgis/lumina";
|
|
8
|
+
import * as O from "@arcgis/toolkit/log";
|
|
9
|
+
import { rethrowError as D } from "@arcgis/toolkit/log";
|
|
9
10
|
import { createRef as _, ref as v } from "lit/directives/ref.js";
|
|
10
|
-
import { u as
|
|
11
|
-
import { O as
|
|
11
|
+
import { u as T } from "../../chunks/useT9n.js";
|
|
12
|
+
import { O as N } from "../../chunks/orchestrator.js";
|
|
12
13
|
import "@langchain/core/callbacks/dispatch/web";
|
|
13
14
|
import "@langchain/core/prompts";
|
|
14
15
|
import "@langchain/openai";
|
|
15
|
-
import
|
|
16
|
+
import z from "@arcgis/core/identity/IdentityManager.js";
|
|
17
|
+
import "@arcgis/toolkit/string";
|
|
16
18
|
import "@arcgis/core/config.js";
|
|
17
19
|
import "@langchain/core/messages";
|
|
18
20
|
import "@arcgis/core/layers/FeatureLayer.js";
|
|
19
21
|
import "../../chunks/generateLayerDescriptions.js";
|
|
20
22
|
import "@langchain/langgraph/web";
|
|
21
|
-
import
|
|
22
|
-
import { property as b, subclass as
|
|
23
|
-
import { g as
|
|
23
|
+
import B from "@arcgis/core/core/Accessor.js";
|
|
24
|
+
import { property as b, subclass as V } from "@arcgis/core/core/accessorSupport/decorators.js";
|
|
25
|
+
import { g as j } from "../../chunks/utils3.js";
|
|
24
26
|
import { g as w } from "../../chunks/slottableRequestUtils.js";
|
|
25
|
-
const
|
|
26
|
-
var H = Object.defineProperty,
|
|
27
|
-
for (var
|
|
28
|
-
(
|
|
29
|
-
return i &&
|
|
27
|
+
const q = C`:host{display:block;width:var(--arcgis-internal-panel-width, 100%);height:var(--arcgis-internal-expand-max-height, 100%);--calcite-panel-content-bottom-space: 0}.footer-container{display:flex;flex-direction:column;flex:1 1 0;gap:var(--calcite-spacing-md)}.content-container{display:flex;flex-direction:column;flex:1 1 0;min-height:0;position:relative;overflow:auto}.suggested-prompts-container{display:flex;justify-content:center;width:100%;background:var(--calcite-panel-background-color, var(--calcite-color-background))}.suggested-prompts{display:block;padding:var(--calcite-spacing-md);max-width:100%;box-sizing:border-box}.error-notice{padding:var(--calcite-spacing-sm)}.interrupt-waiting-message{font-style:italic;color:var(--calcite-color-text-2)}`;
|
|
28
|
+
var H = Object.defineProperty, U = Object.getOwnPropertyDescriptor, m = (o, t, e, i) => {
|
|
29
|
+
for (var s = i > 1 ? void 0 : i ? U(t, e) : t, l = o.length - 1, r; l >= 0; l--)
|
|
30
|
+
(r = o[l]) && (s = (i ? r(t, e, s) : r(s)) || s);
|
|
31
|
+
return i && s && H(t, e, s), s;
|
|
30
32
|
};
|
|
31
|
-
const
|
|
32
|
-
async function*
|
|
33
|
+
const F = async (o) => await new Promise((t) => setTimeout(t, o)), E = (o) => !o || typeof o != "object" ? !1 : o.name === "AbortError";
|
|
34
|
+
async function* G(o, {
|
|
33
35
|
chunkSize: t = 5,
|
|
34
36
|
// chars per "token"
|
|
35
37
|
delay: e = 20
|
|
36
38
|
// ms between chunks
|
|
37
39
|
} = {}) {
|
|
38
40
|
let i = 0;
|
|
39
|
-
for (; i <
|
|
40
|
-
yield
|
|
41
|
+
for (; i < o.length; )
|
|
42
|
+
yield o.slice(i, i + t), i += t, await F(e);
|
|
41
43
|
}
|
|
42
|
-
async function*
|
|
43
|
-
for await (const
|
|
44
|
+
async function* S(o, t, e, i) {
|
|
45
|
+
for await (const s of G(o)) {
|
|
44
46
|
if (i?.aborted) {
|
|
45
47
|
yield { type: "cancelled", log: e, runId: t };
|
|
46
48
|
return;
|
|
47
49
|
}
|
|
48
|
-
yield { type: "block-data", blockType: "text", data: { content:
|
|
50
|
+
yield { type: "block-data", blockType: "text", data: { content: s }, runId: t };
|
|
49
51
|
}
|
|
50
52
|
}
|
|
51
|
-
let d = class extends
|
|
52
|
-
constructor(
|
|
53
|
-
super(
|
|
53
|
+
let d = class extends B {
|
|
54
|
+
constructor(o) {
|
|
55
|
+
super(o), this.view = null, this.loading = !1, this.processing = !1, this.processingStep = "";
|
|
54
56
|
}
|
|
55
57
|
async load() {
|
|
56
58
|
this._set("loading", !0);
|
|
@@ -64,14 +66,14 @@ let d = class extends N {
|
|
|
64
66
|
this.orchestrator?.dispose(), super.destroy();
|
|
65
67
|
}
|
|
66
68
|
async _initialize() {
|
|
67
|
-
this.removeHandles(), await Promise.all([this.portal.load(), this.view?.when()]), this.view && await
|
|
69
|
+
this.removeHandles(), await Promise.all([this.portal.load(), this.view?.when()]), this.view && await A(() => !this.view.updating), this._set(
|
|
68
70
|
"orchestrator",
|
|
69
|
-
await
|
|
71
|
+
await N.init({
|
|
70
72
|
agents: [...this.agents],
|
|
71
73
|
view: this.view ?? void 0
|
|
72
74
|
})
|
|
73
75
|
), this.addHandles([
|
|
74
|
-
|
|
76
|
+
L(
|
|
75
77
|
() => [this.view, this.agents],
|
|
76
78
|
() => {
|
|
77
79
|
this._initialize();
|
|
@@ -82,30 +84,29 @@ let d = class extends N {
|
|
|
82
84
|
clearChatHistory() {
|
|
83
85
|
this.orchestrator?.newConversation();
|
|
84
86
|
}
|
|
85
|
-
async *ask(
|
|
87
|
+
async *ask(o, t) {
|
|
86
88
|
if (!this.orchestrator)
|
|
87
89
|
throw new Error("Orchestrator not initialized yet.");
|
|
88
90
|
this._set("processing", !0), this._set("processingStep", "");
|
|
89
91
|
const e = [];
|
|
90
|
-
let i;
|
|
92
|
+
let i, s = "pending";
|
|
91
93
|
try {
|
|
92
|
-
const
|
|
93
|
-
for await (const
|
|
94
|
-
|
|
95
|
-
switch (n.type) {
|
|
94
|
+
const l = this.orchestrator.ask(o);
|
|
95
|
+
for await (const r of l)
|
|
96
|
+
switch (s = r.runId, r.type) {
|
|
96
97
|
case "trace": {
|
|
97
|
-
this._set("processingStep",
|
|
98
|
+
this._set("processingStep", r.data.text), e.push(r.data.text);
|
|
98
99
|
break;
|
|
99
100
|
}
|
|
100
101
|
case "completed": {
|
|
101
102
|
this._set("processing", !1), this._set("processingStep", "");
|
|
102
|
-
const a =
|
|
103
|
-
if (!
|
|
103
|
+
const a = r.result, n = !!a.content.length, h = !!i?.length;
|
|
104
|
+
if (!n && !h) {
|
|
104
105
|
yield { type: "completed", error: "No response received.", log: e, runId: s };
|
|
105
106
|
return;
|
|
106
107
|
}
|
|
107
|
-
const
|
|
108
|
-
if (yield { type: "block-start", blockType: "text", runId: s }, yield*
|
|
108
|
+
const g = a.content;
|
|
109
|
+
if (yield { type: "block-start", blockType: "text", runId: s }, yield* S(g, s, e, t), yield { type: "block-end", blockType: "text", runId: s }, h)
|
|
109
110
|
for (const f of i) {
|
|
110
111
|
if (t?.aborted) {
|
|
111
112
|
yield { type: "cancelled", log: e, runId: s };
|
|
@@ -113,33 +114,33 @@ let d = class extends N {
|
|
|
113
114
|
}
|
|
114
115
|
const { type: u, data: y } = f;
|
|
115
116
|
if (yield { type: "block-start", blockType: u, runId: s }, u === "text") {
|
|
116
|
-
const
|
|
117
|
-
yield*
|
|
117
|
+
const $ = typeof y?.content == "string" ? y.content : "";
|
|
118
|
+
yield* S($, s, e, t);
|
|
118
119
|
} else
|
|
119
120
|
yield { type: "block-data", blockType: u, data: y, runId: s };
|
|
120
121
|
yield { type: "block-end", blockType: u, runId: s };
|
|
121
122
|
}
|
|
122
|
-
yield { type: "completed", response:
|
|
123
|
+
yield { type: "completed", response: g, blocks: i, log: e, runId: s };
|
|
123
124
|
return;
|
|
124
125
|
}
|
|
125
126
|
case "ux-suggestion": {
|
|
126
|
-
const a =
|
|
127
|
+
const a = r.suggestion;
|
|
127
128
|
i = i ? [...i, a] : [a];
|
|
128
129
|
break;
|
|
129
130
|
}
|
|
130
131
|
case "interrupt": {
|
|
131
|
-
const { kind: a, message:
|
|
132
|
+
const { kind: a, message: n, metadata: h } = r.interrupt, g = Array.isArray(h) ? h.filter((u) => typeof u == "string") : [], f = (() => {
|
|
132
133
|
switch (a) {
|
|
133
134
|
case "booleanChoice":
|
|
134
|
-
return { type: "boolean-choice", message:
|
|
135
|
+
return { type: "boolean-choice", message: n, options: g };
|
|
135
136
|
case "singleSelection":
|
|
136
|
-
return { type: "single-select", message:
|
|
137
|
+
return { type: "single-select", message: n, options: g };
|
|
137
138
|
case "multipleSelection":
|
|
138
|
-
return { type: "multi-select", message:
|
|
139
|
+
return { type: "multi-select", message: n, options: g };
|
|
139
140
|
case "textInput":
|
|
140
|
-
return { type: "text-input", message:
|
|
141
|
+
return { type: "text-input", message: n };
|
|
141
142
|
default:
|
|
142
|
-
return { type: a, message:
|
|
143
|
+
return { type: a, message: n, options: g };
|
|
143
144
|
}
|
|
144
145
|
})();
|
|
145
146
|
this._set("processingStep", "Waiting for user input..."), yield { type: "interrupt", payload: f, runId: s };
|
|
@@ -150,17 +151,24 @@ let d = class extends N {
|
|
|
150
151
|
return;
|
|
151
152
|
}
|
|
152
153
|
case "error": {
|
|
153
|
-
|
|
154
|
+
if (t?.aborted || E(r.error)) {
|
|
155
|
+
yield { type: "cancelled", log: e, runId: s };
|
|
156
|
+
return;
|
|
157
|
+
}
|
|
158
|
+
yield { type: "completed", error: r.error.message, log: e, runId: s };
|
|
154
159
|
return;
|
|
155
160
|
}
|
|
156
161
|
default: {
|
|
157
|
-
console.warn("Unknown event type:",
|
|
162
|
+
console.warn("Unknown event type:", r);
|
|
158
163
|
break;
|
|
159
164
|
}
|
|
160
165
|
}
|
|
166
|
+
} catch (l) {
|
|
167
|
+
if (t?.aborted || E(l)) {
|
|
168
|
+
yield { type: "cancelled", log: e, runId: s };
|
|
169
|
+
return;
|
|
161
170
|
}
|
|
162
|
-
|
|
163
|
-
console.warn("Error during message processing:", r), yield { type: "completed", error: "An error occurred during message processing.", log: e, runId: "error" };
|
|
171
|
+
console.warn("Error during message processing:", l), yield { type: "completed", error: "An error occurred during message processing.", log: e, runId: "error" };
|
|
164
172
|
return;
|
|
165
173
|
} finally {
|
|
166
174
|
this._set("processing", !1);
|
|
@@ -192,12 +200,12 @@ m([
|
|
|
192
200
|
b({ readOnly: !0 })
|
|
193
201
|
], d.prototype, "processingStep", 2);
|
|
194
202
|
d = m([
|
|
195
|
-
|
|
203
|
+
V("OrchestratorController")
|
|
196
204
|
], d);
|
|
197
|
-
const
|
|
198
|
-
class
|
|
205
|
+
const W = "Embeddings resource 'embeddings-v01.json' not found in the webmap portal item.", Y = "Embeddings not found for this web map.", J = "https://developers.arcgis.com/javascript/latest/agentic-apps/ai-webmap-setup/#embeddings";
|
|
206
|
+
class K extends M {
|
|
199
207
|
constructor() {
|
|
200
|
-
super(...arguments), this._messages =
|
|
208
|
+
super(...arguments), this._messages = T({ blocking: !0 }), this.#t = _(), this.#n = _(), this.#s = _(), this.#e = null, this.#o = /* @__PURE__ */ new Map(), this.#r = R.getDefault(), this.#i = (t) => {
|
|
201
209
|
t.stopPropagation(), this.cancelInterrupt();
|
|
202
210
|
}, this.#a = (t) => {
|
|
203
211
|
t.stopPropagation();
|
|
@@ -217,49 +225,52 @@ class Y extends R {
|
|
|
217
225
|
t.stopPropagation();
|
|
218
226
|
const e = t.detail;
|
|
219
227
|
this.arcgisFeedback.emit(e);
|
|
220
|
-
}, this.#
|
|
228
|
+
}, this.#g = (t) => {
|
|
221
229
|
t.stopPropagation();
|
|
222
230
|
const e = t.detail;
|
|
223
231
|
this._inputValue = e.prompt, this.arcgisPromptSelect.emit(e);
|
|
224
|
-
}, this.#
|
|
232
|
+
}, this.#p = (t) => {
|
|
225
233
|
this.arcgisSlottableRequest.emit(t.detail);
|
|
226
|
-
}, this._orchestratorController = null, this._interrupt = null, this._interruptDetails = [], this._error = null, this._inputValue = "", this._isAnswering = !1, this._canceling = !1, this.messages = new
|
|
234
|
+
}, this._orchestratorController = null, this._interrupt = null, this._interruptDetails = [], this._error = null, this._inputValue = "", this._isAnswering = !1, this._canceling = !1, this.messages = new P([]), this.referenceElement = null, this.suggestedPrompts = [], this.feedbackEnabled = !1, this.keepSuggestedPrompts = !1, this.logEnabled = !1, this.copyEnabled = !1, this.voiceInputEnabled = !1, this.readAloudEnabled = !1, this.assistantAvatarEnabled = !1, this.arcgisCancel = p(), this.arcgisError = p(), this.arcgisFeedback = p(), this.arcgisInterrupt = p(), this.arcgisInterruptCancel = p(), this.arcgisInterruptSubmit = p(), this.arcgisPromptSelect = p(), this.arcgisReady = p(), this.arcgisSubmit = p(), this.arcgisSlottableRequest = p({ bubbles: !1, composed: !1 }), this.arcgisResponse = p();
|
|
227
235
|
}
|
|
228
236
|
static {
|
|
229
|
-
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 };
|
|
237
|
+
this.properties = { _orchestratorController: 16, _interrupt: 16, _interruptDetails: 16, _error: 16, _inputValue: 16, _isAnswering: 16, _signedInUserId: 16, _canceling: 16, _isSignedIn: 16, _user: 16, awaitingResponse: 32, awaitingResponseStep: 32, interrupt: 32, messages: 0, orchestrator: 32, entryMessage: 1, heading: 1, description: 1, referenceElement: 1, suggestedPrompts: 0, feedbackEnabled: 5, keepSuggestedPrompts: 5, logEnabled: 5, copyEnabled: 5, voiceInputEnabled: 5, readAloudEnabled: 5, assistantAvatarEnabled: 5 };
|
|
230
238
|
}
|
|
231
239
|
static {
|
|
232
|
-
this.styles =
|
|
240
|
+
this.styles = q;
|
|
233
241
|
}
|
|
234
242
|
#t;
|
|
235
243
|
#n;
|
|
236
244
|
#s;
|
|
237
245
|
#e;
|
|
238
246
|
#o;
|
|
239
|
-
#i;
|
|
240
247
|
#r;
|
|
248
|
+
#i;
|
|
241
249
|
#a;
|
|
242
250
|
#l;
|
|
243
251
|
#c;
|
|
244
252
|
#h;
|
|
245
|
-
#p;
|
|
246
253
|
#g;
|
|
254
|
+
#p;
|
|
247
255
|
async #d() {
|
|
248
256
|
try {
|
|
249
|
-
const t =
|
|
257
|
+
const t = j(this.el, this.referenceElement);
|
|
250
258
|
await t?.componentOnReady();
|
|
251
259
|
const e = [...this.#o.values()];
|
|
252
|
-
return e.length ? (this._orchestratorController = new d({
|
|
260
|
+
return e.length ? (this._orchestratorController?.destroy(), this._orchestratorController = new d({
|
|
253
261
|
agents: e,
|
|
254
|
-
portal: this.#
|
|
262
|
+
portal: this.#r,
|
|
255
263
|
view: t?.view
|
|
256
264
|
}), await this._orchestratorController.load(), !0) : (this._error = "No agents found.", !1);
|
|
257
265
|
} catch (t) {
|
|
258
|
-
return this._error = t?.message ?? "Error initializing orchestrator.",
|
|
266
|
+
return this._error = t?.message ?? "Error initializing orchestrator.", D(this)(t), !1;
|
|
259
267
|
}
|
|
260
268
|
}
|
|
269
|
+
get _isSignedIn() {
|
|
270
|
+
return !!this.#r?.user || !!this._signedInUserId;
|
|
271
|
+
}
|
|
261
272
|
get _user() {
|
|
262
|
-
return this.#
|
|
273
|
+
return this.#r?.user?.fullName || this.#r?.user?.username;
|
|
263
274
|
}
|
|
264
275
|
get awaitingResponse() {
|
|
265
276
|
return this._orchestratorController?.processing ?? !1;
|
|
@@ -293,81 +304,81 @@ class Y extends R {
|
|
|
293
304
|
return;
|
|
294
305
|
this.#e = new AbortController();
|
|
295
306
|
const i = this._orchestratorController.ask(e, this.#e?.signal);
|
|
296
|
-
for await (const
|
|
297
|
-
const
|
|
298
|
-
switch (
|
|
307
|
+
for await (const s of i) {
|
|
308
|
+
const l = s.runId, r = this.messages.at(-1);
|
|
309
|
+
switch (s.type) {
|
|
299
310
|
case "block-start": {
|
|
300
311
|
this._isAnswering = !0;
|
|
301
|
-
const a = { type:
|
|
302
|
-
if (
|
|
303
|
-
const
|
|
304
|
-
this.messages.splice(-1, 1, { ...
|
|
312
|
+
const a = { type: s.blockType, isPending: !0 };
|
|
313
|
+
if (r?.role === "assistant" && r.id === l) {
|
|
314
|
+
const n = [...r.blocks ?? [], a];
|
|
315
|
+
this.messages.splice(-1, 1, { ...r, blocks: n });
|
|
305
316
|
} else
|
|
306
317
|
this.messages.push({
|
|
307
318
|
role: "assistant",
|
|
308
319
|
blocks: [a],
|
|
309
|
-
id:
|
|
320
|
+
id: l,
|
|
310
321
|
isStreaming: !0,
|
|
311
322
|
interrupts: this._interruptDetails
|
|
312
323
|
}), this._interruptDetails = [];
|
|
313
324
|
break;
|
|
314
325
|
}
|
|
315
326
|
case "block-data": {
|
|
316
|
-
if (
|
|
327
|
+
if (r?.role !== "assistant" || r?.id !== l)
|
|
317
328
|
break;
|
|
318
|
-
const a = [...
|
|
319
|
-
if (
|
|
329
|
+
const a = [...r.blocks ?? []], n = a[a.length - 1], { blockType: h, data: g } = s;
|
|
330
|
+
if (n?.type !== h || !n.isPending)
|
|
320
331
|
break;
|
|
321
332
|
if (h === "text") {
|
|
322
|
-
const f = typeof
|
|
323
|
-
a[a.length - 1] = { ...
|
|
333
|
+
const f = typeof n.data?.content == "string" ? n.data.content : "", u = typeof g?.content == "string" ? g.content : "";
|
|
334
|
+
a[a.length - 1] = { ...n, data: { ...n.data, content: f + u } };
|
|
324
335
|
} else
|
|
325
|
-
a[a.length - 1] = { ...
|
|
326
|
-
this.messages.splice(-1, 1, { ...
|
|
336
|
+
a[a.length - 1] = { ...n, data: { ...n.data, ...g ?? {} } };
|
|
337
|
+
this.messages.splice(-1, 1, { ...r, blocks: a });
|
|
327
338
|
break;
|
|
328
339
|
}
|
|
329
340
|
case "block-end": {
|
|
330
|
-
if (
|
|
341
|
+
if (r?.role !== "assistant" || r?.id !== l)
|
|
331
342
|
break;
|
|
332
|
-
const a = [...
|
|
333
|
-
if (
|
|
343
|
+
const a = [...r.blocks ?? []], n = a[a.length - 1];
|
|
344
|
+
if (n?.type !== s.blockType || !n.isPending)
|
|
334
345
|
break;
|
|
335
|
-
const h =
|
|
336
|
-
a[a.length - 1] = { ...h, data: { ...h.data }, isPending: !1 }, this.messages.splice(-1, 1, { ...
|
|
346
|
+
const h = n;
|
|
347
|
+
a[a.length - 1] = { ...h, data: { ...h.data }, isPending: !1 }, this.messages.splice(-1, 1, { ...r, blocks: a });
|
|
337
348
|
break;
|
|
338
349
|
}
|
|
339
350
|
case "completed":
|
|
340
|
-
|
|
351
|
+
s.error ? (this.messages.push({
|
|
341
352
|
role: "assistant",
|
|
342
|
-
log:
|
|
343
|
-
error:
|
|
344
|
-
id:
|
|
353
|
+
log: s.log,
|
|
354
|
+
error: s.error,
|
|
355
|
+
id: l,
|
|
345
356
|
interrupts: this._interruptDetails
|
|
346
|
-
}), this._interruptDetails = []) :
|
|
347
|
-
...
|
|
348
|
-
content:
|
|
349
|
-
blocks:
|
|
357
|
+
}), this._interruptDetails = []) : r?.role === "assistant" && r.id === l && this.messages.splice(-1, 1, {
|
|
358
|
+
...r,
|
|
359
|
+
content: s.response,
|
|
360
|
+
blocks: r.blocks?.map((a) => ({ ...a, isPending: !1 })) ?? [],
|
|
350
361
|
isStreaming: !1,
|
|
351
|
-
log:
|
|
362
|
+
log: s.log
|
|
352
363
|
}), this._isAnswering = !1, this.#e = null, this._canceling = !1;
|
|
353
364
|
break;
|
|
354
365
|
case "interrupt":
|
|
355
|
-
this._interrupt = { ...
|
|
366
|
+
this._interrupt = { ...s.payload, id: l }, this.arcgisInterrupt.emit(this._interrupt);
|
|
356
367
|
break;
|
|
357
368
|
case "cancelled":
|
|
358
|
-
|
|
359
|
-
...
|
|
360
|
-
blocks:
|
|
369
|
+
r?.role === "assistant" && r.id === l ? this.messages.splice(-1, 1, {
|
|
370
|
+
...r,
|
|
371
|
+
blocks: r.blocks?.filter((a) => a.type === "text" || !a.isPending) ?? [],
|
|
361
372
|
isStreaming: !1,
|
|
362
|
-
log:
|
|
373
|
+
log: s.log,
|
|
363
374
|
error: "(Stopped by user)"
|
|
364
375
|
// TODO: use strings from t9n
|
|
365
376
|
}) : (this.messages.push({
|
|
366
377
|
role: "assistant",
|
|
367
|
-
log:
|
|
378
|
+
log: s.log,
|
|
368
379
|
error: "(Stopped by user)",
|
|
369
380
|
// TODO: use strings from t9n
|
|
370
|
-
id:
|
|
381
|
+
id: l,
|
|
371
382
|
interrupts: this._interruptDetails
|
|
372
383
|
}), this._interruptDetails = []), this._isAnswering = !1, this.#e = null, this._canceling = !1;
|
|
373
384
|
break;
|
|
@@ -382,49 +393,50 @@ class Y extends R {
|
|
|
382
393
|
}
|
|
383
394
|
loaded() {
|
|
384
395
|
this.manager.onLifecycle(() => {
|
|
385
|
-
this.#t.value?.addEventListener("arcgisPromptSelect", this.#
|
|
396
|
+
this.#t.value?.addEventListener("arcgisPromptSelect", this.#g), this.#t.value?.addEventListener("arcgisSubmit", this.#l), this.#t.value?.addEventListener("arcgisCancel", this.#c), this.#t.value?.addEventListener("arcgisFeedback", this.#h);
|
|
386
397
|
const t = x(() => !!this._interrupt && !!this.#s.value, () => {
|
|
387
398
|
const i = this.#s.value;
|
|
388
|
-
i.removeEventListener("arcgisSubmit", this.#a), i.removeEventListener("arcgisCancel", this.#
|
|
399
|
+
i.removeEventListener("arcgisSubmit", this.#a), i.removeEventListener("arcgisCancel", this.#i), i.addEventListener("arcgisSubmit", this.#a, { once: !0 }), i.addEventListener("arcgisCancel", this.#i, { once: !0 });
|
|
389
400
|
}), e = this.messages.on("after-add", (i) => {
|
|
390
|
-
const
|
|
391
|
-
|
|
401
|
+
const s = i.item;
|
|
402
|
+
s.role === "assistant" && (s.error || s.content) && this.arcgisResponse.emit(s);
|
|
392
403
|
});
|
|
393
404
|
return queueMicrotask(() => {
|
|
394
405
|
this.#d().then((i) => {
|
|
395
406
|
i ? this.arcgisReady.emit() : this._error && this.arcgisError.emit(new Error(this._error));
|
|
396
407
|
});
|
|
397
408
|
}), () => {
|
|
398
|
-
t.remove(), e.remove(), this.#t.value?.removeEventListener("arcgisPromptSelect", this.#
|
|
409
|
+
t.remove(), e.remove(), this.#t.value?.removeEventListener("arcgisPromptSelect", this.#g), this.#s.value?.removeEventListener("arcgisSubmit", this.#a), this.#s.value?.removeEventListener("arcgisCancel", this.#i), this.#t.value?.removeEventListener("arcgisSubmit", this.#l), this.#t.value?.removeEventListener("arcgisCancel", this.#c), this.#t.value?.removeEventListener("arcgisFeedback", this.#h), this._orchestratorController?.destroy(), this._orchestratorController = null;
|
|
399
410
|
};
|
|
400
411
|
});
|
|
401
412
|
}
|
|
402
413
|
_reset() {
|
|
403
|
-
this._orchestratorController?.cancel(), this.#e?.abort(), this._interrupt = null, this.messages.removeAll(), this._error = null, this._inputValue = "";
|
|
414
|
+
this._orchestratorController?.cancel(), this.#e?.abort(), this._interrupt = null, this.messages.removeAll(), this._error = null, this._inputValue = "", this._signedInUserId = void 0;
|
|
404
415
|
}
|
|
405
416
|
_renderEntryMessage() {
|
|
406
|
-
return
|
|
417
|
+
return this._isSignedIn ? this._error ? this._renderErrorNotice() : this.entryMessage ? this.messages.length > 0 ? null : c`<calcite-notice open kind=brand closable icon width=full><div slot=message>${this.entryMessage}</div></calcite-notice>` : c`<slot name=entry-message></slot>` : this._renderSignInNotice();
|
|
407
418
|
}
|
|
408
419
|
_renderSignInNotice() {
|
|
409
|
-
const t = this.#
|
|
410
|
-
return
|
|
420
|
+
const t = this.#r;
|
|
421
|
+
return c`<calcite-notice slot=entry-message open kind=brand icon width=full><div slot=message>You need to sign in to use the assistant chat.</div>${t ? c`<calcite-link slot=link @click=${async () => {
|
|
411
422
|
try {
|
|
412
|
-
await
|
|
423
|
+
const e = await z.getCredential(`${t.url}/sharing`);
|
|
424
|
+
this._signedInUserId = e.userId, this._error = null, this.requestUpdate(), await this.#d() ? this.arcgisReady.emit() : this._error && this.arcgisError.emit(new Error(this._error));
|
|
413
425
|
} catch (e) {
|
|
414
|
-
|
|
426
|
+
this._error = e?.message ?? "Error signing in.", this.arcgisError.emit(new Error(this._error)), O.log("error", this, "Error signing in:", { detail: { error: e } });
|
|
415
427
|
}
|
|
416
|
-
}} target=_blank title="Sign in to ArcGIS Online">Sign in</calcite-link>` :
|
|
428
|
+
}} target=_blank title="Sign in to ArcGIS Online">Sign in</calcite-link>` : c`<div slot=link>No portal information available</div>`}</calcite-notice>`;
|
|
417
429
|
}
|
|
418
430
|
_renderErrorNotice() {
|
|
419
|
-
return this._error ?
|
|
431
|
+
return this._error ? c`<calcite-notice slot=entry-message open kind=brand icon width=full>${this._error === W ? c`<div slot=message>${Y}</div><calcite-link slot=link .href=${J} target=_blank title="Learn about web map embeddings">Read more</calcite-link>` : c`<div slot=message>${this._error}</div>`}</calcite-notice>` : null;
|
|
420
432
|
}
|
|
421
433
|
render() {
|
|
422
|
-
return
|
|
434
|
+
return c`<calcite-panel .loading=${!this._orchestratorController && !this._error || this._orchestratorController?.loading} .heading=${this.heading ?? this._messages.assistantLabel} .description=${this.description} ${v(this.#t)}><slot name=header-actions-start slot=header-actions-start></slot><slot name=header-actions-end slot=header-actions-end></slot><div class="content-container"><arcgis-assistant-chat .loading=${this.awaitingResponse} .messages=${this.messages} .interrupt=${this._interrupt}><slot name=message-starter slot=message-starter></slot><slot name=messages slot=messages>${this.messages.map((t) => t.role === "assistant" ? c`<arcgis-assistant-message .message=${t} .feedbackEnabled=${this.feedbackEnabled} .logEnabled=${this.logEnabled} .copyEnabled=${this.copyEnabled} .readAloudEnabled=${this.readAloudEnabled} @arcgisSlottableRequest=${this.#p} .assistantAvatarEnabled=${this.assistantAvatarEnabled}>${t.blocks?.map((e, i) => c`<slot name=${w(t.id, i) ?? k} slot=${w(t.id, i) ?? k}><arcgis-assistant-message-block .block=${e}></arcgis-assistant-message-block></slot>`)}</arcgis-assistant-message>` : c`<arcgis-assistant-user-message .message=${t} .user=${this._user}></arcgis-assistant-user-message>`)}</slot>${this._interrupt ? c`<div slot=message-loading><div class="interrupt-waiting-message">waiting for user input...</div></div>` : c`<slot name=message-loading slot=message-loading><arcgis-assistant-message-loading .loading=${this.awaitingResponse} .loadingMessage=${this.awaitingResponseStep} .assistantAvatarEnabled=${this.assistantAvatarEnabled} .interrupts=${this._interruptDetails}></arcgis-assistant-message-loading></slot>`}</arcgis-assistant-chat></div>${this._interrupt ? c`<slot name=interrupt><arcgis-assistant-interrupt slot=content-bottom .type=${this._interrupt.type} .message=${this._interrupt.message} .options=${this._interrupt.options} ${v(this.#s)}></arcgis-assistant-interrupt></slot>` : this.suggestedPrompts?.length ? c`<div class="suggested-prompts-container" slot=content-bottom><arcgis-assistant-suggested-prompts class="suggested-prompts" .prompts=${this.suggestedPrompts}></arcgis-assistant-suggested-prompts></div>` : null}<div class="footer-container" slot=footer>${this._renderEntryMessage()}<slot name=chat-entry><arcgis-assistant-chat-entry .awaitingResponse=${this.awaitingResponse || this._isAnswering} .inputValue=${this._inputValue} .messages=${this.messages} .voiceInputEnabled=${this.voiceInputEnabled} .disabled=${this._canceling || !this._isSignedIn || !!this._interrupt} ${v(this.#n)}><slot name=entry-actions-start slot=entry-actions-start></slot><slot name=entry-actions-end slot=entry-actions-end><calcite-button .iconStart=${this.awaitingResponse || this._isAnswering ? "circle-stop" : "send"} @click=${() => {
|
|
423
435
|
this.#n.value?.submitMessage();
|
|
424
436
|
}} round>${this.awaitingResponse || this._isAnswering ? this._messages.stopButtonLabel : this._messages.askButtonLabel}</calcite-button></slot></arcgis-assistant-chat-entry></slot><slot name=footer-content></slot></div></calcite-panel>`;
|
|
425
437
|
}
|
|
426
438
|
}
|
|
427
|
-
|
|
439
|
+
I("arcgis-assistant", K);
|
|
428
440
|
export {
|
|
429
|
-
|
|
441
|
+
K as ArcgisAssistant
|
|
430
442
|
};
|
|
@@ -5,6 +5,7 @@ import "@langchain/langgraph/web";
|
|
|
5
5
|
import "../../chunks/adapter.js";
|
|
6
6
|
import "@arcgis/core/identity/IdentityManager.js";
|
|
7
7
|
import "@arcgis/core/portal/Portal.js";
|
|
8
|
+
import "@arcgis/toolkit/string";
|
|
8
9
|
import "../../chunks/generateLayerDescriptions.js";
|
|
9
10
|
import "@langchain/core/messages";
|
|
10
11
|
import "@langchain/core/callbacks/dispatch/web";
|
|
@@ -19,7 +20,7 @@ import "zod";
|
|
|
19
20
|
import { D as r } from "../../chunks/dataExplorationGraph.js";
|
|
20
21
|
import "@arcgis/core/views/LinkChartView.js";
|
|
21
22
|
import "@arcgis/core/rest/knowledgeGraphService.js";
|
|
22
|
-
import { r as
|
|
23
|
+
import { r as o, a } from "../../chunks/utils2.js";
|
|
23
24
|
class s extends i {
|
|
24
25
|
constructor() {
|
|
25
26
|
super(...arguments), this.agent = r;
|
|
@@ -34,7 +35,7 @@ class s extends i {
|
|
|
34
35
|
return { mapView: this.#t };
|
|
35
36
|
}
|
|
36
37
|
load() {
|
|
37
|
-
this.#t =
|
|
38
|
+
this.#t = o(this, "arcgis-assistant-data-exploration-agent"), a(this);
|
|
38
39
|
}
|
|
39
40
|
}
|
|
40
41
|
t("arcgis-assistant-data-exploration-agent", s);
|
|
@@ -5,6 +5,7 @@ import "@langchain/langgraph/web";
|
|
|
5
5
|
import "../../chunks/adapter.js";
|
|
6
6
|
import "@arcgis/core/identity/IdentityManager.js";
|
|
7
7
|
import "@arcgis/core/portal/Portal.js";
|
|
8
|
+
import "@arcgis/toolkit/string";
|
|
8
9
|
import "../../chunks/generateLayerDescriptions.js";
|
|
9
10
|
import "@langchain/core/messages";
|
|
10
11
|
import "@langchain/core/callbacks/dispatch/web";
|
|
@@ -5,6 +5,7 @@ import "@langchain/langgraph/web";
|
|
|
5
5
|
import "../../chunks/adapter.js";
|
|
6
6
|
import "@arcgis/core/identity/IdentityManager.js";
|
|
7
7
|
import "@arcgis/core/portal/Portal.js";
|
|
8
|
+
import "@arcgis/toolkit/string";
|
|
8
9
|
import "../../chunks/generateLayerDescriptions.js";
|
|
9
10
|
import "@langchain/core/messages";
|
|
10
11
|
import "@langchain/core/callbacks/dispatch/web";
|
|
@@ -22,7 +23,7 @@ import "@arcgis/core/smartMapping/statistics/uniqueValues.js";
|
|
|
22
23
|
import { A as o } from "../../chunks/arcgisKnowledgeGraph.js";
|
|
23
24
|
import { b as s, a as n } from "../../chunks/utils2.js";
|
|
24
25
|
import { fetchKnowledgeGraph as a } from "@arcgis/core/rest/knowledgeGraphService.js";
|
|
25
|
-
class
|
|
26
|
+
class p extends i {
|
|
26
27
|
constructor() {
|
|
27
28
|
super(...arguments), this.agent = o;
|
|
28
29
|
}
|
|
@@ -63,7 +64,7 @@ class c extends i {
|
|
|
63
64
|
this.#e = s(this) ?? void 0, n(this);
|
|
64
65
|
}
|
|
65
66
|
}
|
|
66
|
-
r("arcgis-assistant-knowledge-agent",
|
|
67
|
+
r("arcgis-assistant-knowledge-agent", p);
|
|
67
68
|
export {
|
|
68
|
-
|
|
69
|
+
p as ArcgisAssistantKnowledgeAgent
|
|
69
70
|
};
|
|
@@ -5,6 +5,7 @@ import "@langchain/langgraph/web";
|
|
|
5
5
|
import "../../chunks/adapter.js";
|
|
6
6
|
import "@arcgis/core/identity/IdentityManager.js";
|
|
7
7
|
import "@arcgis/core/portal/Portal.js";
|
|
8
|
+
import "@arcgis/toolkit/string";
|
|
8
9
|
import "../../chunks/generateLayerDescriptions.js";
|
|
9
10
|
import "@langchain/core/messages";
|
|
10
11
|
import "@langchain/core/callbacks/dispatch/web";
|
|
@@ -6,6 +6,7 @@ import "@langchain/langgraph/web";
|
|
|
6
6
|
import "../../chunks/adapter.js";
|
|
7
7
|
import "@arcgis/core/identity/IdentityManager.js";
|
|
8
8
|
import "@arcgis/core/portal/Portal.js";
|
|
9
|
+
import "@arcgis/toolkit/string";
|
|
9
10
|
import "../../chunks/generateLayerDescriptions.js";
|
|
10
11
|
import "@langchain/core/messages";
|
|
11
12
|
import "@langchain/core/callbacks/dispatch/web";
|