@arcgis/ai-components 5.0.0-next.157 → 5.0.0-next.159
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/2GPJGYOJ.js +2 -0
- package/dist/cdn/3PHWKSJZ.js +3 -0
- package/dist/cdn/4GEEK3VW.js +2 -0
- package/dist/cdn/6QV3RIYZ.js +2 -0
- package/dist/cdn/{V32SS7PJ.js → 7GTFRRWF.js} +1 -1
- package/dist/cdn/7KB4R4Z2.js +2 -0
- package/dist/cdn/D3UKS3CK.js +254 -0
- package/dist/cdn/EJ4UHNLB.js +67 -0
- package/dist/cdn/EM4MVN4S.js +2 -0
- package/dist/cdn/FEJ3AX3C.js +2 -0
- package/dist/cdn/GIZ3VXFU.js +2 -0
- package/dist/cdn/JA77AZOL.js +2 -0
- package/dist/cdn/{IZ4NSOIH.js → JHKPM4IQ.js} +1 -0
- package/dist/cdn/L3SDV3SP.js +3 -0
- package/dist/cdn/OB2ZDIKI.js +2 -0
- package/dist/cdn/PFUFVETM.js +2 -0
- package/dist/cdn/PYBMDANL.js +2 -0
- package/dist/cdn/QVENTNWP.js +2 -0
- package/dist/cdn/{LDS4EYQM.js → QYS2QVQH.js} +15 -0
- package/dist/cdn/VPBE5KOZ.js +2 -0
- package/dist/cdn/{AF63DSCU.js → VQLOUYPX.js} +82 -83
- package/dist/cdn/VXUGI6TV.js +2 -0
- package/dist/cdn/{AHBZA3FR.js → WWTWOB2N.js} +1 -1
- package/dist/cdn/{OEDEKAJJ.js → XJBDOKVO.js} +1 -1
- package/dist/cdn/{GXFH7ZNV.js → YNQSQY4Y.js} +3 -3
- package/dist/cdn/index.js +1 -1
- package/dist/cdn/main.css +1 -1
- package/dist/chunks/converterUtils.js +117 -0
- package/dist/chunks/utils.js +12 -14
- package/dist/chunks/utils2.js +3 -2
- package/dist/components/arcgis-assistant/customElement.d.ts +29 -11
- package/dist/components/arcgis-assistant/customElement.js +143 -126
- package/dist/components/arcgis-assistant/types.d.ts +29 -0
- package/dist/components/arcgis-assistant-chat/customElement.d.ts +8 -6
- package/dist/components/arcgis-assistant-chat/customElement.js +12 -12
- package/dist/components/arcgis-assistant-chat-card/customElement.d.ts +12 -5
- package/dist/components/arcgis-assistant-chat-card/customElement.js +59 -25
- package/dist/components/arcgis-assistant-chat-card/index.js +2 -0
- package/dist/components/arcgis-assistant-chat-card-content/customElement.js +14 -12
- package/dist/components/arcgis-assistant-chat-card-content/index.js +1 -0
- package/dist/components/arcgis-assistant-chat-entry/customElement.d.ts +5 -2
- package/dist/components/arcgis-assistant-chat-entry/customElement.js +42 -20
- package/dist/components/arcgis-assistant-data-exploration-agent/customElement.js +5 -5
- package/dist/components/arcgis-assistant-help-agent/customElement.d.ts +33 -0
- package/dist/components/arcgis-assistant-help-agent/customElement.js +26 -0
- package/dist/components/arcgis-assistant-help-agent/index.d.ts +1 -0
- package/dist/components/arcgis-assistant-help-agent/index.js +1 -0
- package/dist/components/arcgis-assistant-interrupt/customElement.d.ts +1 -1
- package/dist/components/arcgis-assistant-interrupt/customElement.js +8 -8
- package/dist/components/arcgis-assistant-layer-filter-agent/customElement.js +2 -2
- package/dist/components/arcgis-assistant-layer-query-agent/customElement.js +11 -11
- package/dist/components/arcgis-assistant-layer-styling-agent/customElement.js +6 -6
- package/dist/components/arcgis-assistant-navigation-agent/customElement.js +5 -5
- package/dist/components/arcgis-assistant-shell/customElement.d.ts +3 -0
- package/dist/components/arcgis-assistant-shell/customElement.js +12 -11
- 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/index.d.ts +16 -0
- package/dist/loader.js +8 -7
- package/dist/types/lumina.d.ts +19 -5
- package/dist/types/preact.d.ts +20 -5
- package/dist/types/react.d.ts +21 -5
- package/dist/types/stencil.d.ts +19 -5
- package/package.json +8 -6
- package/dist/cdn/2EP62G3F.js +0 -2
- package/dist/cdn/33UOPY5K.js +0 -2
- package/dist/cdn/5HW2GXLG.js +0 -2
- package/dist/cdn/67C4OJGP.js +0 -4
- package/dist/cdn/7DTHEDCA.js +0 -245
- package/dist/cdn/7JQF7K4O.js +0 -2
- package/dist/cdn/7TOMVUR3.js +0 -2
- package/dist/cdn/CFWC26EG.js +0 -2
- package/dist/cdn/EF43HQG4.js +0 -2
- package/dist/cdn/JMVSBIZH.js +0 -2
- package/dist/cdn/JYMBSYZP.js +0 -2
- package/dist/cdn/QJ3OZMLS.js +0 -2
- package/dist/cdn/QWUKKFEV.js +0 -2
- package/dist/cdn/RFHHK4CN.js +0 -2
- package/dist/cdn/TFSGIS6Z.js +0 -2
- package/dist/cdn/W5WKMUAF.js +0 -2
|
@@ -1,25 +1,26 @@
|
|
|
1
1
|
/* COPYRIGHT Esri - https://js.arcgis.com/5.0/LICENSE.txt */
|
|
2
|
-
import { c as
|
|
3
|
-
import { css as
|
|
4
|
-
import
|
|
5
|
-
import { whenOnce as
|
|
6
|
-
import
|
|
7
|
-
import { LitElement as
|
|
8
|
-
import { createRef as
|
|
9
|
-
import { Orchestrator as
|
|
2
|
+
import { c as v } from "../../chunks/runtime.js";
|
|
3
|
+
import { css as b, html as u } from "lit";
|
|
4
|
+
import _ from "@arcgis/core/core/Collection.js";
|
|
5
|
+
import { whenOnce as w, watch as E, when as $ } from "@arcgis/core/core/reactiveUtils.js";
|
|
6
|
+
import k from "@arcgis/core/portal/Portal.js";
|
|
7
|
+
import { LitElement as C, createEvent as o } from "@arcgis/lumina";
|
|
8
|
+
import { createRef as m, ref as y } from "lit/directives/ref.js";
|
|
9
|
+
import { Orchestrator as S } from "@arcgis/ai-orchestrator";
|
|
10
10
|
import L from "@arcgis/core/core/Accessor.js";
|
|
11
|
-
import { property as
|
|
11
|
+
import { property as h, subclass as I } from "@arcgis/core/core/accessorSupport/decorators.js";
|
|
12
12
|
import { g as P } from "../../chunks/utils2.js";
|
|
13
|
-
import { u as
|
|
14
|
-
|
|
15
|
-
|
|
16
|
-
|
|
17
|
-
|
|
18
|
-
|
|
13
|
+
import { u as O } from "../../chunks/useT9n.js";
|
|
14
|
+
import { rethrowError as M } from "@arcgis/toolkit/log";
|
|
15
|
+
const x = b`:host{display:block;height:var(--arcgis-internal-expand-max-height, 100%)}`;
|
|
16
|
+
var A = Object.defineProperty, R = Object.getOwnPropertyDescriptor, l = (c, t, e, i) => {
|
|
17
|
+
for (var s = i > 1 ? void 0 : i ? R(t, e) : t, r = c.length - 1, n; r >= 0; r--)
|
|
18
|
+
(n = c[r]) && (s = (i ? n(t, e, s) : n(s)) || s);
|
|
19
|
+
return i && s && A(t, e, s), s;
|
|
19
20
|
};
|
|
20
|
-
let
|
|
21
|
-
constructor(
|
|
22
|
-
super(
|
|
21
|
+
let a = class extends L {
|
|
22
|
+
constructor(c) {
|
|
23
|
+
super(c), this.view = null, this.loading = !1, this.processing = !1, this.processingStep = "";
|
|
23
24
|
}
|
|
24
25
|
async load() {
|
|
25
26
|
this._set("loading", !0);
|
|
@@ -33,69 +34,66 @@ let i = class extends L {
|
|
|
33
34
|
this.orchestrator?.dispose(), super.destroy();
|
|
34
35
|
}
|
|
35
36
|
async _initialize() {
|
|
36
|
-
this.removeHandles(), await Promise.all([this.portal.load(), this.view?.when()]), this.view && await
|
|
37
|
+
this.removeHandles(), await Promise.all([this.portal.load(), this.view?.when()]), this.view && await w(() => !this.view.updating), this._set(
|
|
37
38
|
"orchestrator",
|
|
38
|
-
await
|
|
39
|
+
await S.init({
|
|
39
40
|
agents: [...this.agents],
|
|
40
|
-
portal: this.portal,
|
|
41
41
|
view: this.view ?? void 0
|
|
42
42
|
})
|
|
43
43
|
), this.addHandles([
|
|
44
|
-
|
|
44
|
+
E(
|
|
45
45
|
() => [this.view, this.agents],
|
|
46
46
|
() => void this._initialize()
|
|
47
47
|
)
|
|
48
48
|
]);
|
|
49
49
|
}
|
|
50
|
-
async *ask(
|
|
50
|
+
async *ask(c, t) {
|
|
51
51
|
if (!this.orchestrator)
|
|
52
52
|
throw new Error("Orchestrator not initialized yet.");
|
|
53
53
|
this._set("processing", !0), this._set("processingStep", "");
|
|
54
|
-
|
|
54
|
+
const e = [];
|
|
55
55
|
try {
|
|
56
|
-
const
|
|
57
|
-
for await (const s of
|
|
56
|
+
const i = this.orchestrator.ask(c);
|
|
57
|
+
for await (const s of i) {
|
|
58
|
+
const r = s.runId;
|
|
58
59
|
if (t?.aborted) {
|
|
59
|
-
yield { type: "cancelled" };
|
|
60
|
+
yield { type: "cancelled", runId: r };
|
|
60
61
|
break;
|
|
61
62
|
}
|
|
62
63
|
switch (s.type) {
|
|
63
64
|
case "trace": {
|
|
64
|
-
this._set("processingStep", s.data.text), e
|
|
65
|
-
|
|
66
|
-
`;
|
|
65
|
+
this._set("processingStep", s.data.text), e.push(s.data.text);
|
|
67
66
|
break;
|
|
68
67
|
}
|
|
69
68
|
case "completed": {
|
|
70
69
|
if (!s.result.content.length) {
|
|
71
|
-
yield { type: "completed", error: "Could not process the request.", log: e };
|
|
70
|
+
yield { type: "completed", error: "Could not process the request.", log: e, runId: r };
|
|
72
71
|
return;
|
|
73
72
|
}
|
|
74
73
|
const n = s.result.content;
|
|
75
|
-
this._set("processingStep", ""), yield { type: "completed", response: n, log: e };
|
|
74
|
+
this._set("processingStep", ""), yield { type: "completed", response: n, log: e, runId: r };
|
|
76
75
|
return;
|
|
77
76
|
}
|
|
78
77
|
case "interrupt": {
|
|
79
|
-
|
|
80
|
-
const { kind: n, message: o, metadata: u } = s.interrupt, h = Array.isArray(u) ? [...u] : [], d = (() => {
|
|
78
|
+
const { kind: n, message: p, metadata: d } = s.interrupt, g = Array.isArray(d) ? [...d] : [], f = (() => {
|
|
81
79
|
switch (n) {
|
|
82
80
|
case "booleanChoice":
|
|
83
|
-
return { type: "boolean-choice", message:
|
|
81
|
+
return { type: "boolean-choice", message: p, options: g };
|
|
84
82
|
case "singleSelection":
|
|
85
|
-
return { type: "single-select", message:
|
|
83
|
+
return { type: "single-select", message: p, options: g };
|
|
86
84
|
case "multipleSelection":
|
|
87
|
-
return { type: "multi-select", message:
|
|
85
|
+
return { type: "multi-select", message: p, options: g };
|
|
88
86
|
case "textInput":
|
|
89
|
-
return { type: "text-input", message:
|
|
87
|
+
return { type: "text-input", message: p };
|
|
90
88
|
default:
|
|
91
|
-
return { type: n, message:
|
|
89
|
+
return { type: n, message: p, options: g };
|
|
92
90
|
}
|
|
93
91
|
})();
|
|
94
|
-
this._set("processingStep", "Waiting for user input..."), yield { type: "interrupt", payload:
|
|
92
|
+
this._set("processingStep", "Waiting for user input..."), yield { type: "interrupt", payload: f, runId: r };
|
|
95
93
|
break;
|
|
96
94
|
}
|
|
97
95
|
case "cancelled": {
|
|
98
|
-
yield { type: "cancelled" };
|
|
96
|
+
yield { type: "cancelled", runId: r };
|
|
99
97
|
return;
|
|
100
98
|
}
|
|
101
99
|
default: {
|
|
@@ -104,145 +102,164 @@ let i = class extends L {
|
|
|
104
102
|
}
|
|
105
103
|
}
|
|
106
104
|
}
|
|
107
|
-
} catch (
|
|
108
|
-
console.warn("Error during message processing:",
|
|
105
|
+
} catch (i) {
|
|
106
|
+
console.warn("Error during message processing:", i), yield { type: "completed", error: "An error occurred during message processing.", log: e, runId: "error" };
|
|
109
107
|
return;
|
|
110
108
|
} finally {
|
|
111
109
|
this._set("processing", !1);
|
|
112
110
|
}
|
|
113
111
|
}
|
|
114
112
|
};
|
|
115
|
-
|
|
116
|
-
|
|
117
|
-
],
|
|
118
|
-
|
|
119
|
-
|
|
120
|
-
],
|
|
121
|
-
|
|
122
|
-
|
|
123
|
-
],
|
|
124
|
-
|
|
125
|
-
|
|
126
|
-
],
|
|
127
|
-
|
|
128
|
-
|
|
129
|
-
],
|
|
130
|
-
|
|
131
|
-
|
|
132
|
-
],
|
|
133
|
-
|
|
134
|
-
|
|
135
|
-
],
|
|
136
|
-
|
|
137
|
-
|
|
138
|
-
],
|
|
139
|
-
class
|
|
113
|
+
l([
|
|
114
|
+
h({ readOnly: !0 })
|
|
115
|
+
], a.prototype, "orchestrator", 2);
|
|
116
|
+
l([
|
|
117
|
+
h()
|
|
118
|
+
], a.prototype, "agents", 2);
|
|
119
|
+
l([
|
|
120
|
+
h()
|
|
121
|
+
], a.prototype, "portal", 2);
|
|
122
|
+
l([
|
|
123
|
+
h()
|
|
124
|
+
], a.prototype, "view", 2);
|
|
125
|
+
l([
|
|
126
|
+
h({ readOnly: !0 })
|
|
127
|
+
], a.prototype, "loading", 2);
|
|
128
|
+
l([
|
|
129
|
+
h({ readOnly: !0 })
|
|
130
|
+
], a.prototype, "processing", 2);
|
|
131
|
+
l([
|
|
132
|
+
h({ readOnly: !0 })
|
|
133
|
+
], a.prototype, "processingStep", 2);
|
|
134
|
+
a = l([
|
|
135
|
+
I("OrchestratorController")
|
|
136
|
+
], a);
|
|
137
|
+
class z extends C {
|
|
140
138
|
constructor() {
|
|
141
|
-
super(...arguments), this._messages =
|
|
142
|
-
t.stopPropagation(), this.orchestrator?.cancelInterrupt(), this._interrupt = null;
|
|
143
|
-
}, this.#
|
|
139
|
+
super(...arguments), this._messages = O({ blocking: !0 }), this.#e = m(), this.#s = m(), this.#t = null, this.#r = null, this.#o = /* @__PURE__ */ new Map(), this.#i = k.getDefault(), this.#a = (t) => {
|
|
140
|
+
t.stopPropagation(), this.arcgisInterruptCancel.emit(), this.orchestrator?.cancelInterrupt(), this._interrupt = null;
|
|
141
|
+
}, this.#n = (t) => {
|
|
144
142
|
t.stopPropagation();
|
|
145
143
|
const e = t.detail;
|
|
146
|
-
this.orchestrator?.resumeInterrupt(e), this._interrupt = null;
|
|
147
|
-
}, this.#
|
|
144
|
+
this.arcgisInterruptSubmit.emit(e), this.orchestrator?.resumeInterrupt(e), this._interrupt = null;
|
|
145
|
+
}, this.#l = (t) => {
|
|
148
146
|
t.stopPropagation(), this.suggestedPrompts = [];
|
|
149
147
|
const e = t.detail;
|
|
150
|
-
this
|
|
151
|
-
}, this.#
|
|
152
|
-
if (t.stopPropagation(), this._interrupt) {
|
|
148
|
+
this.arcgisSubmit.emit(e), this.submitMessage(e);
|
|
149
|
+
}, this.#c = (t) => {
|
|
150
|
+
if (t.stopPropagation(), this.arcgisCancel.emit(), this._interrupt) {
|
|
153
151
|
this.orchestrator?.cancelInterrupt(), this._interrupt = null;
|
|
154
152
|
return;
|
|
155
153
|
}
|
|
156
154
|
this.#r?.abort();
|
|
157
|
-
}, this
|
|
155
|
+
}, this.#h = (t) => {
|
|
156
|
+
t.stopPropagation();
|
|
157
|
+
const e = t.detail;
|
|
158
|
+
this.arcgisFeedback.emit(e);
|
|
159
|
+
}, this._interrupt = null, this._error = null, this.messages = new _([]), this.referenceElement = null, this.suggestedPrompts = [], this.feedbackEnabled = !1, this.logEnabled = !1, this.copyEnabled = !1, this.arcgisCancel = o(), this.arcgisError = o(), this.arcgisInterrupt = o(), this.arcgisInterruptCancel = o(), this.arcgisInterruptSubmit = o(), this.arcgisReady = o(), this.arcgisSubmit = o(), this.arcgisFeedback = o();
|
|
158
160
|
}
|
|
159
161
|
static {
|
|
160
|
-
this.properties = { _interrupt: 16,
|
|
162
|
+
this.properties = { _interrupt: 16, _error: 16, _user: 16, messages: 0, orchestrator: 32, entryMessage: 1, heading: 1, description: 1, referenceElement: 1, suggestedPrompts: 0, feedbackEnabled: 5, logEnabled: 5, copyEnabled: 5 };
|
|
161
163
|
}
|
|
162
164
|
static {
|
|
163
|
-
this.styles =
|
|
165
|
+
this.styles = x;
|
|
164
166
|
}
|
|
165
167
|
#e;
|
|
166
168
|
#s;
|
|
167
169
|
#t;
|
|
168
170
|
#r;
|
|
169
|
-
#n;
|
|
170
|
-
#i;
|
|
171
171
|
#o;
|
|
172
|
+
#i;
|
|
172
173
|
#a;
|
|
174
|
+
#n;
|
|
173
175
|
#l;
|
|
174
|
-
|
|
175
|
-
|
|
176
|
-
|
|
177
|
-
register(t) {
|
|
178
|
-
this.#n.set(t.agent.id, t);
|
|
179
|
-
}
|
|
180
|
-
load() {
|
|
181
|
-
this.manager.onLifecycle(() => () => {
|
|
182
|
-
this.#r?.abort(), this._interrupt = null, this._chatHistory.removeAll(), this._error = null;
|
|
183
|
-
});
|
|
184
|
-
}
|
|
185
|
-
loaded() {
|
|
186
|
-
this.manager.onLifecycle(() => {
|
|
187
|
-
this.#e.value?.addEventListener("arcgisSubmit", this.#a), this.#e.value?.addEventListener("arcgisCancel", this.#l);
|
|
188
|
-
const t = b(() => !!this._interrupt && !!this.#s.value, () => {
|
|
189
|
-
const e = this.#s.value;
|
|
190
|
-
e.removeEventListener("arcgisSubmit", this.#o), e.removeEventListener("arcgisCancel", this.#i), e.addEventListener("arcgisSubmit", this.#o, { once: !0 }), e.addEventListener("arcgisCancel", this.#i, { once: !0 });
|
|
191
|
-
});
|
|
192
|
-
return queueMicrotask(() => void this.#c()), () => {
|
|
193
|
-
t.remove(), this.#s.value?.removeEventListener("arcgisSubmit", this.#o), this.#s.value?.removeEventListener("arcgisCancel", this.#i), this.#e.value?.removeEventListener("arcgisSubmit", this.#a), this.#e.value?.removeEventListener("arcgisCancel", this.#l), this.#t?.destroy(), this.#t = null;
|
|
194
|
-
};
|
|
195
|
-
});
|
|
196
|
-
}
|
|
197
|
-
async #c() {
|
|
176
|
+
#c;
|
|
177
|
+
#h;
|
|
178
|
+
async #p() {
|
|
198
179
|
try {
|
|
199
|
-
const t = P(this.referenceElement);
|
|
180
|
+
const t = P(this.el, this.referenceElement);
|
|
200
181
|
await t?.componentOnReady();
|
|
201
|
-
const e = [...this.#
|
|
202
|
-
this.#t = new
|
|
182
|
+
const e = [...this.#o.values()];
|
|
183
|
+
return e.length ? (this.#t = new a({
|
|
203
184
|
agents: e,
|
|
204
|
-
portal: this
|
|
185
|
+
portal: this.#i,
|
|
205
186
|
view: t?.view
|
|
206
|
-
}), await this.#t.load();
|
|
187
|
+
}), await this.#t.load(), !0) : (this._error = "No agents found.", !1);
|
|
207
188
|
} catch (t) {
|
|
208
|
-
|
|
189
|
+
return this._error = "Error initializing orchestrator.", M(this)(t), !1;
|
|
209
190
|
}
|
|
210
191
|
}
|
|
211
|
-
|
|
192
|
+
get _user() {
|
|
193
|
+
return this.#i?.user?.fullName || this.#i?.user?.username;
|
|
194
|
+
}
|
|
195
|
+
get orchestrator() {
|
|
196
|
+
return this.#t?.orchestrator;
|
|
197
|
+
}
|
|
198
|
+
register(t) {
|
|
199
|
+
this.#o.set(t.agent.id, t);
|
|
200
|
+
}
|
|
201
|
+
async submitMessage(t) {
|
|
212
202
|
const e = t.trim();
|
|
213
|
-
if (!e || (this.
|
|
214
|
-
|
|
203
|
+
if (!e || (this.messages.push({
|
|
204
|
+
id: Date.now().toString(),
|
|
205
|
+
// TODO: Replace with a more robust ID generation method or get from orchestrator
|
|
206
|
+
role: "user",
|
|
215
207
|
content: e
|
|
216
208
|
}), !this.#t))
|
|
217
209
|
return;
|
|
218
210
|
this.#r = new AbortController();
|
|
219
|
-
const
|
|
220
|
-
for await (const s of
|
|
211
|
+
const i = this.#t.ask(e, this.#r.signal);
|
|
212
|
+
for await (const s of i) {
|
|
213
|
+
const r = s.runId;
|
|
221
214
|
switch (s.type) {
|
|
222
215
|
case "completed":
|
|
223
|
-
this.
|
|
224
|
-
|
|
216
|
+
this.messages.push({
|
|
217
|
+
role: "assistant",
|
|
225
218
|
content: s.response,
|
|
226
219
|
log: s.log,
|
|
227
|
-
error: s.error
|
|
220
|
+
error: s.error,
|
|
221
|
+
id: r
|
|
228
222
|
});
|
|
229
223
|
break;
|
|
230
224
|
case "interrupt":
|
|
231
|
-
this._interrupt = s.payload;
|
|
225
|
+
this._interrupt = { ...s.payload, id: r };
|
|
232
226
|
break;
|
|
233
227
|
case "cancelled":
|
|
234
|
-
this.
|
|
235
|
-
|
|
236
|
-
error: "Request cancelled."
|
|
228
|
+
this.messages.push({
|
|
229
|
+
role: "assistant",
|
|
230
|
+
error: "Request cancelled.",
|
|
231
|
+
id: r
|
|
237
232
|
});
|
|
238
233
|
break;
|
|
239
234
|
}
|
|
235
|
+
}
|
|
236
|
+
}
|
|
237
|
+
load() {
|
|
238
|
+
this.manager.onLifecycle(() => () => {
|
|
239
|
+
this.#r?.abort(), this._interrupt = null, this.messages.removeAll(), this._error = null;
|
|
240
|
+
});
|
|
241
|
+
}
|
|
242
|
+
loaded() {
|
|
243
|
+
this.manager.onLifecycle(() => {
|
|
244
|
+
this.#e.value?.addEventListener("arcgisSubmit", this.#l), this.#e.value?.addEventListener("arcgisCancel", this.#c), this.#e.value?.addEventListener("arcgisFeedback", this.#h);
|
|
245
|
+
const t = $(() => !!this._interrupt && !!this.#s.value, () => {
|
|
246
|
+
const e = this.#s.value;
|
|
247
|
+
e.removeEventListener("arcgisSubmit", this.#n), e.removeEventListener("arcgisCancel", this.#a), e.addEventListener("arcgisSubmit", this.#n, { once: !0 }), e.addEventListener("arcgisCancel", this.#a, { once: !0 }), this._interrupt && this.arcgisInterrupt.emit(this._interrupt);
|
|
248
|
+
});
|
|
249
|
+
return queueMicrotask(() => {
|
|
250
|
+
this.#p().then((e) => {
|
|
251
|
+
e ? this.arcgisReady.emit() : this.arcgisError.emit(new Error(this._error || "Unknown error initializing assistant."));
|
|
252
|
+
});
|
|
253
|
+
}), () => {
|
|
254
|
+
t.remove(), this.#s.value?.removeEventListener("arcgisSubmit", this.#n), this.#s.value?.removeEventListener("arcgisCancel", this.#a), this.#e.value?.removeEventListener("arcgisSubmit", this.#l), this.#e.value?.removeEventListener("arcgisCancel", this.#c), this.#e.value?.removeEventListener("arcgisFeedback", this.#h), this.#t?.destroy(), this.#t = null;
|
|
255
|
+
};
|
|
256
|
+
});
|
|
240
257
|
}
|
|
241
258
|
render() {
|
|
242
|
-
return
|
|
259
|
+
return u`<arcgis-assistant-shell .loading=${!this.#t || this.#t?.loading} .heading=${this.heading ?? this._messages.assistantLabel} .description=${this.description} .entryMessage=${this.entryMessage} .entryMessageClosed=${this.messages.length > 0} .awaitingResponse=${this.#t?.processing} .suggestedPrompts=${this.suggestedPrompts} .status=${this.#t?.processing ? "working" : this._error ? "error" : "ready"} .messages=${this.messages} ${y(this.#e)}>${this._error ? u`<calcite-notice slot=entry-message open kind=danger icon width=full><div slot=message>${this._error}</div></calcite-notice>` : null}${this._interrupt ? u`<arcgis-assistant-interrupt slot=entry-message .type=${this._interrupt.type} .message=${this._interrupt.message} .options=${this._interrupt.options} ${y(this.#s)}></arcgis-assistant-interrupt>` : null}<arcgis-assistant-chat .loading=${this.#t?.processing} .loadingMessage=${this.#t?.processingStep || ""} .messages=${this.messages} .user=${this._user} .feedbackEnabled=${this.feedbackEnabled} .logEnabled=${this.logEnabled} .copyEnabled=${this.copyEnabled}><slot></slot><slot name=chat-card-footer-actions-start slot=chat-card-footer-actions-start></slot><slot name=chat-card-footer-actions-end slot=chat-card-footer-actions-end></slot></arcgis-assistant-chat><slot name=header-actions-end slot=header-actions-end></slot>${this.entryMessage ? null : u`<slot name=entry-message slot=entry-message></slot>`}<slot name=entry-actions-start slot=entry-actions-start></slot><slot name=footer-content slot=footer-content></slot></arcgis-assistant-shell>`;
|
|
243
260
|
}
|
|
244
261
|
}
|
|
245
|
-
|
|
262
|
+
v("arcgis-assistant", z);
|
|
246
263
|
export {
|
|
247
|
-
|
|
264
|
+
z as ArcgisAssistant
|
|
248
265
|
};
|
|
@@ -0,0 +1,29 @@
|
|
|
1
|
+
export interface Interrupt {
|
|
2
|
+
id?: string;
|
|
3
|
+
type: "boolean-choice" | "multi-select" | "single-select" | "text-input";
|
|
4
|
+
message?: string;
|
|
5
|
+
options?: string[];
|
|
6
|
+
}
|
|
7
|
+
|
|
8
|
+
export interface AssistantMessage extends ChatMessageBase {
|
|
9
|
+
role: "assistant";
|
|
10
|
+
content?: string;
|
|
11
|
+
log?: string[];
|
|
12
|
+
error?: string;
|
|
13
|
+
feedback?: Feedback;
|
|
14
|
+
}
|
|
15
|
+
|
|
16
|
+
export type ChatMessage = AssistantMessage | UserMessage;
|
|
17
|
+
|
|
18
|
+
export interface Feedback {
|
|
19
|
+
positive: boolean;
|
|
20
|
+
}
|
|
21
|
+
|
|
22
|
+
export interface ChatMessageBase {
|
|
23
|
+
id: string;
|
|
24
|
+
}
|
|
25
|
+
|
|
26
|
+
export interface UserMessage extends ChatMessageBase {
|
|
27
|
+
role: "user";
|
|
28
|
+
content: string;
|
|
29
|
+
}
|
|
@@ -1,18 +1,20 @@
|
|
|
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
5
|
|
|
5
6
|
/** @internal */
|
|
6
7
|
export abstract class ArcgisAssistantChat extends LitElement {
|
|
8
|
+
/** @default false */
|
|
9
|
+
accessor copyEnabled: boolean;
|
|
10
|
+
/** @default false */
|
|
11
|
+
accessor feedbackEnabled: boolean;
|
|
7
12
|
/** @default false */
|
|
8
13
|
accessor loading: boolean;
|
|
9
14
|
/** @default "" */
|
|
10
15
|
accessor loadingMessage: string;
|
|
11
|
-
|
|
12
|
-
|
|
13
|
-
|
|
14
|
-
log?: string;
|
|
15
|
-
error?: string;
|
|
16
|
-
}>;
|
|
16
|
+
/** @default false */
|
|
17
|
+
accessor logEnabled: boolean;
|
|
18
|
+
accessor messages: Collection<ChatMessage>;
|
|
17
19
|
accessor user: string | undefined;
|
|
18
20
|
}
|
|
@@ -1,20 +1,20 @@
|
|
|
1
1
|
/* COPYRIGHT Esri - https://js.arcgis.com/5.0/LICENSE.txt */
|
|
2
|
-
import { c as
|
|
3
|
-
import { css as e, html as
|
|
2
|
+
import { c as t } from "../../chunks/runtime.js";
|
|
3
|
+
import { css as e, html as s } from "lit";
|
|
4
4
|
import { LitElement as i } from "@arcgis/lumina";
|
|
5
|
-
import { createRef as o, ref as
|
|
6
|
-
import
|
|
7
|
-
import { watch as
|
|
8
|
-
const
|
|
5
|
+
import { createRef as o, ref as l } from "lit/directives/ref.js";
|
|
6
|
+
import n from "@arcgis/core/core/Collection.js";
|
|
7
|
+
import { watch as c } from "@arcgis/core/core/reactiveUtils.js";
|
|
8
|
+
const r = e`.assistant-chat__messages-container{display:flex;flex:1;flex-direction:column}.assistant-chat__messages-list{padding:var(--calcite-spacing-lg);display:flex;flex-direction:column;gap:var(--calcite-spacing-md);flex:1 1 auto;min-height:0;justify-content:flex-end;overflow:auto}`;
|
|
9
9
|
class d extends i {
|
|
10
10
|
constructor() {
|
|
11
|
-
super(...arguments), this.#s = o(), this.loading = !1, this.loadingMessage = "", this.messages = new
|
|
11
|
+
super(...arguments), this.#s = o(), this.feedbackEnabled = !1, this.logEnabled = !1, this.copyEnabled = !1, this.loading = !1, this.loadingMessage = "", this.messages = new n([]);
|
|
12
12
|
}
|
|
13
13
|
static {
|
|
14
|
-
this.properties = { loading: 5, loadingMessage: 1, user: 1, messages: 0 };
|
|
14
|
+
this.properties = { feedbackEnabled: 5, logEnabled: 5, copyEnabled: 5, loading: 5, loadingMessage: 1, user: 1, messages: 0 };
|
|
15
15
|
}
|
|
16
16
|
static {
|
|
17
|
-
this.styles =
|
|
17
|
+
this.styles = r;
|
|
18
18
|
}
|
|
19
19
|
#s;
|
|
20
20
|
firstUpdated() {
|
|
@@ -25,7 +25,7 @@ class d extends i {
|
|
|
25
25
|
this.messages.on("change", () => {
|
|
26
26
|
this.requestUpdate(), this._scrollToEnd();
|
|
27
27
|
}),
|
|
28
|
-
|
|
28
|
+
c(() => this.loading, () => {
|
|
29
29
|
this._scrollToEnd();
|
|
30
30
|
})
|
|
31
31
|
]);
|
|
@@ -36,10 +36,10 @@ class d extends i {
|
|
|
36
36
|
});
|
|
37
37
|
}
|
|
38
38
|
render() {
|
|
39
|
-
return
|
|
39
|
+
return s`<div class="assistant-chat__messages-container"><div class="assistant-chat__messages-list"><slot></slot>${this.messages.map((a) => s`<arcgis-assistant-chat-card .message=${a} .user=${this.user} .feedbackEnabled=${this.feedbackEnabled} .logEnabled=${this.logEnabled} .copyEnabled=${this.copyEnabled}><slot name=chat-card-footer-actions-start slot=footer-actions-start></slot><slot name=chat-card-footer-actions-end slot=footer-actions-end></slot></arcgis-assistant-chat-card>`)}${this.loading ? s`<arcgis-assistant-chat-card .loading=${this.loading} .loadingMessage=${this.loadingMessage} .message=${{ id: "loading", role: "assistant", content: this.loadingMessage }}></arcgis-assistant-chat-card>` : null}</div><div ${l(this.#s)}></div></div>`;
|
|
40
40
|
}
|
|
41
41
|
}
|
|
42
|
-
|
|
42
|
+
t("arcgis-assistant-chat", d);
|
|
43
43
|
export {
|
|
44
44
|
d as ArcgisAssistantChat
|
|
45
45
|
};
|
|
@@ -1,5 +1,6 @@
|
|
|
1
1
|
/// <reference path="../../index.d.ts" />
|
|
2
2
|
import type { PublicLitElement as LitElement } from "@arcgis/lumina";
|
|
3
|
+
import type { AssistantMessage, ChatMessage } from "../arcgis-assistant/types.js";
|
|
3
4
|
import type { T9nMeta } from "@arcgis/lumina/controllers";
|
|
4
5
|
|
|
5
6
|
/** @internal */
|
|
@@ -17,16 +18,22 @@ export abstract class ArcgisAssistantChatCard extends LitElement {
|
|
|
17
18
|
logButtonLabel: string;
|
|
18
19
|
}>;
|
|
19
20
|
accessor content: string | undefined;
|
|
21
|
+
/** @default false */
|
|
22
|
+
accessor copyEnabled: boolean;
|
|
20
23
|
accessor error: string | undefined;
|
|
21
24
|
/** @default false */
|
|
22
|
-
accessor
|
|
25
|
+
accessor feedbackEnabled: boolean;
|
|
23
26
|
/** @default false */
|
|
24
27
|
accessor loading: boolean;
|
|
25
28
|
accessor loadingMessage: string | undefined;
|
|
26
|
-
accessor log: string | undefined;
|
|
29
|
+
accessor log: string[] | undefined;
|
|
27
30
|
/** @default false */
|
|
28
|
-
accessor
|
|
29
|
-
|
|
30
|
-
accessor
|
|
31
|
+
accessor logEnabled: boolean;
|
|
32
|
+
accessor message: ChatMessage | undefined;
|
|
33
|
+
accessor messageRole: ChatMessage["role"] | undefined;
|
|
31
34
|
accessor user: string | undefined;
|
|
35
|
+
readonly arcgisFeedback: import("@arcgis/lumina").TargetedEvent<this, AssistantMessage>;
|
|
36
|
+
readonly "@eventTypes": {
|
|
37
|
+
arcgisFeedback: ArcgisAssistantChatCard["arcgisFeedback"]["detail"];
|
|
38
|
+
};
|
|
32
39
|
}
|