@arcgis/ai-components 5.1.0-next.6 → 5.1.0-next.8
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/2S4DQWU7.js +2 -0
- package/dist/cdn/46Q4W2ZL.js +2 -0
- package/dist/cdn/{4Y73V2HU.js → AGZUEMOX.js} +1 -1
- package/dist/cdn/{UY4FI7AP.js → D6OOXTNF.js} +1 -1
- package/dist/cdn/I4LOCAOT.js +2 -0
- package/dist/cdn/JJPTDO6D.js +2 -0
- package/dist/cdn/JVR66VPL.js +3 -0
- package/dist/cdn/KDL663TG.js +2 -0
- package/dist/cdn/{2PLHSU7P.js → MN4FA32I.js} +65 -65
- package/dist/cdn/MYKSIL6I.js +2 -0
- package/dist/cdn/NSM3CLQ7.js +2 -0
- package/dist/cdn/OJUEJ4RT.js +2 -0
- package/dist/cdn/PQHYDFCL.js +2 -0
- package/dist/cdn/TISLVKGP.js +2 -0
- package/dist/cdn/TNI4DRHG.js +2 -0
- package/dist/cdn/{AIAY4NON.js → TTJBCQZA.js} +77 -68
- package/dist/cdn/{26V7SXDR.js → VG7GKLZR.js} +1 -1
- package/dist/cdn/{NKNUZCLA.js → W2A22QZU.js} +15 -0
- package/dist/cdn/WAO4LVNK.js +67 -0
- package/dist/cdn/WFEBJPQ4.js +2 -0
- package/dist/cdn/WTK5H7Z6.js +2 -0
- package/dist/cdn/ZGRFMSA2.js +2 -0
- 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 -125
- 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/GCFT45CD.js +0 -2
- package/dist/cdn/GN2HYJJX.js +0 -4
- package/dist/cdn/I22GHLAO.js +0 -2
- package/dist/cdn/IFSNQY7L.js +0 -2
- package/dist/cdn/IFWK7P7O.js +0 -2
- package/dist/cdn/J35M7O4J.js +0 -2
- package/dist/cdn/JABDBJPC.js +0 -2
- package/dist/cdn/KJZARHAM.js +0 -2
- package/dist/cdn/M672SFG6.js +0 -2
- package/dist/cdn/Q674OE2M.js +0 -2
- package/dist/cdn/VUHDKXFM.js +0 -2
- package/dist/cdn/XGVAPO3I.js +0 -2
- package/dist/cdn/XVUE27HC.js +0 -2
- package/dist/cdn/Y7UZYXEV.js +0 -2
|
@@ -0,0 +1,117 @@
|
|
|
1
|
+
/* COPYRIGHT Esri - https://js.arcgis.com/5.1/LICENSE.txt */
|
|
2
|
+
import g from "@esri/arcgis-html-sanitizer";
|
|
3
|
+
import { marked as S } from "marked";
|
|
4
|
+
S.use({
|
|
5
|
+
gfm: !0,
|
|
6
|
+
breaks: !0,
|
|
7
|
+
async: !1
|
|
8
|
+
});
|
|
9
|
+
const C = new g(
|
|
10
|
+
{
|
|
11
|
+
whiteList: {
|
|
12
|
+
// LLMs sometimes return lists like "- 2) Foo". `marked` parses that into a nested ordered list
|
|
13
|
+
// (`<ol start="2">...`), so we keep `start`/`value` to avoid everything rendering as "1.".
|
|
14
|
+
ol: ["start"],
|
|
15
|
+
li: ["value"],
|
|
16
|
+
"calcite-table": ["caption", "bordered", "striped", "layout", "scale", "class"],
|
|
17
|
+
"calcite-table-row": ["slot", "class"],
|
|
18
|
+
"calcite-table-header": ["heading", "alignment", "description", "class"],
|
|
19
|
+
"calcite-table-cell": ["alignment", "colspan", "rowspan", "class"],
|
|
20
|
+
// Allow markdown code blocks to render as <pre><code>…</code></pre>.
|
|
21
|
+
pre: ["class"],
|
|
22
|
+
code: ["class"]
|
|
23
|
+
}
|
|
24
|
+
},
|
|
25
|
+
!0
|
|
26
|
+
);
|
|
27
|
+
function T(e) {
|
|
28
|
+
return C.sanitize(e);
|
|
29
|
+
}
|
|
30
|
+
function A(e, t) {
|
|
31
|
+
const r = e.indexOf("{", t), a = e.indexOf("[", t);
|
|
32
|
+
return r === -1 ? a : a === -1 ? r : Math.min(r, a);
|
|
33
|
+
}
|
|
34
|
+
function x(e) {
|
|
35
|
+
if (e.trimStart().startsWith("```"))
|
|
36
|
+
return null;
|
|
37
|
+
for (let r = A(e, 0); r !== -1; r = A(e, r + 1)) {
|
|
38
|
+
let a = 0, c = 0;
|
|
39
|
+
for (let l = r; l < e.length; l++) {
|
|
40
|
+
const n = e[l];
|
|
41
|
+
if (n === "{" ? a++ : n === "}" ? a-- : n === "[" ? c++ : n === "]" && c--, a < 0 || c < 0)
|
|
42
|
+
break;
|
|
43
|
+
if (a === 0 && c === 0 && l > r)
|
|
44
|
+
return e.slice(r, l + 1);
|
|
45
|
+
}
|
|
46
|
+
}
|
|
47
|
+
return null;
|
|
48
|
+
}
|
|
49
|
+
function H(e) {
|
|
50
|
+
if (!e)
|
|
51
|
+
return "";
|
|
52
|
+
let t = e;
|
|
53
|
+
const r = x(e);
|
|
54
|
+
if (r)
|
|
55
|
+
try {
|
|
56
|
+
const l = JSON.parse(r), f = `
|
|
57
|
+
|
|
58
|
+
\`\`\`json
|
|
59
|
+
${JSON.stringify(l, null, 2)}
|
|
60
|
+
\`\`\`
|
|
61
|
+
|
|
62
|
+
`;
|
|
63
|
+
t = e.replace(r, f);
|
|
64
|
+
} catch {
|
|
65
|
+
}
|
|
66
|
+
const a = q(t), c = E(a);
|
|
67
|
+
return T(c);
|
|
68
|
+
}
|
|
69
|
+
function q(e) {
|
|
70
|
+
return e ? S.parse(e, { async: !1 }) : "";
|
|
71
|
+
}
|
|
72
|
+
function E(e) {
|
|
73
|
+
if (!e || typeof DOMParser > "u")
|
|
74
|
+
return e;
|
|
75
|
+
try {
|
|
76
|
+
const t = new DOMParser().parseFromString(e, "text/html");
|
|
77
|
+
return Array.from(t.querySelectorAll("table")).forEach((a, c) => {
|
|
78
|
+
const l = t.createElement("calcite-table");
|
|
79
|
+
l.setAttribute("caption", `Table ${c + 1}`), l.setAttribute("striped", "true");
|
|
80
|
+
const n = a.querySelector("thead");
|
|
81
|
+
if (n) {
|
|
82
|
+
const d = Array.from(n.querySelectorAll("tr"));
|
|
83
|
+
for (const h of d) {
|
|
84
|
+
const o = t.createElement("calcite-table-row");
|
|
85
|
+
o.setAttribute("slot", "table-header");
|
|
86
|
+
const u = Array.from(h.querySelectorAll("th, td"));
|
|
87
|
+
for (const b of u) {
|
|
88
|
+
const s = (b.textContent ?? "").trim(), i = t.createElement("calcite-table-header");
|
|
89
|
+
i.setAttribute("heading", s), o.appendChild(i);
|
|
90
|
+
}
|
|
91
|
+
l.appendChild(o);
|
|
92
|
+
}
|
|
93
|
+
}
|
|
94
|
+
const f = a.querySelector("tbody");
|
|
95
|
+
(f ? Array.from(f.querySelectorAll("tr")) : Array.from(a.querySelectorAll("tr")).filter((d) => !n?.contains(d))).forEach((d, h) => {
|
|
96
|
+
const o = t.createElement("calcite-table-row"), u = !n && h === 0 && d.querySelectorAll("th").length > 0;
|
|
97
|
+
u && o.setAttribute("slot", "table-header");
|
|
98
|
+
const b = Array.from(d.querySelectorAll("th, td"));
|
|
99
|
+
for (const s of b) {
|
|
100
|
+
if (u && s.localName === "th") {
|
|
101
|
+
const w = (s.textContent ?? "").trim(), y = t.createElement("calcite-table-header");
|
|
102
|
+
y.setAttribute("heading", w), o.appendChild(y);
|
|
103
|
+
return;
|
|
104
|
+
}
|
|
105
|
+
const i = t.createElement("calcite-table-cell"), p = s.getAttribute("colspan"), m = s.getAttribute("rowspan");
|
|
106
|
+
p && i.setAttribute("colspan", p), m && i.setAttribute("rowspan", m), i.innerHTML = s.innerHTML, o.appendChild(i);
|
|
107
|
+
}
|
|
108
|
+
l.appendChild(o);
|
|
109
|
+
}), a.replaceWith(l);
|
|
110
|
+
}), t.body.innerHTML;
|
|
111
|
+
} catch {
|
|
112
|
+
return e;
|
|
113
|
+
}
|
|
114
|
+
}
|
|
115
|
+
export {
|
|
116
|
+
H as p
|
|
117
|
+
};
|
package/dist/chunks/utils.js
CHANGED
|
@@ -1,25 +1,23 @@
|
|
|
1
1
|
/* COPYRIGHT Esri - https://js.arcgis.com/5.1/LICENSE.txt */
|
|
2
|
-
import { getClosestElement as
|
|
3
|
-
import { g as
|
|
2
|
+
import { getClosestElement as a } from "@arcgis/toolkit/dom";
|
|
3
|
+
import { g as i } from "./utils2.js";
|
|
4
4
|
function o(e, t) {
|
|
5
|
-
const
|
|
6
|
-
if (
|
|
7
|
-
return
|
|
8
|
-
const
|
|
5
|
+
const s = i(e.el, e.referenceElement);
|
|
6
|
+
if (s)
|
|
7
|
+
return s;
|
|
8
|
+
const n = a(e.el, "arcgis-assistant"), r = i(e.el, n?.referenceElement);
|
|
9
9
|
if (r)
|
|
10
10
|
return r;
|
|
11
11
|
throw new Error(`${t}: Reference element not found`);
|
|
12
12
|
}
|
|
13
|
-
|
|
14
|
-
const n = o(e, t);
|
|
15
|
-
|
|
16
|
-
const s = n.view;
|
|
17
|
-
if (!s)
|
|
13
|
+
function f(e, t) {
|
|
14
|
+
const n = o(e, t).view;
|
|
15
|
+
if (!n)
|
|
18
16
|
throw new Error(`${t}: Reference element does not have a view`);
|
|
19
|
-
return
|
|
17
|
+
return n;
|
|
20
18
|
}
|
|
21
19
|
function m(e) {
|
|
22
|
-
const t =
|
|
20
|
+
const t = a(e.el, "arcgis-assistant");
|
|
23
21
|
if (t === void 0)
|
|
24
22
|
throw new Error("arcgis-assistant-agent must be used within an arcgis-assistant element");
|
|
25
23
|
t.register({
|
|
@@ -29,5 +27,5 @@ function m(e) {
|
|
|
29
27
|
}
|
|
30
28
|
export {
|
|
31
29
|
m as i,
|
|
32
|
-
|
|
30
|
+
f as r
|
|
33
31
|
};
|
package/dist/chunks/utils2.js
CHANGED
|
@@ -1,6 +1,7 @@
|
|
|
1
1
|
/* COPYRIGHT Esri - https://js.arcgis.com/5.1/LICENSE.txt */
|
|
2
|
-
|
|
3
|
-
|
|
2
|
+
import { getClosestElement as o } from "@arcgis/toolkit/dom";
|
|
3
|
+
function u(r, t) {
|
|
4
|
+
return t ? typeof t == "string" ? document.querySelector(t) : t : o(r, "arcgis-map") ?? null;
|
|
4
5
|
}
|
|
5
6
|
export {
|
|
6
7
|
u as g
|
|
@@ -1,6 +1,7 @@
|
|
|
1
1
|
/// <reference path="../../index.d.ts" />
|
|
2
|
-
import type
|
|
2
|
+
import type Collection from "@arcgis/core/core/Collection.js";
|
|
3
3
|
import type { PublicLitElement as LitElement } from "@arcgis/lumina";
|
|
4
|
+
import type { ChatMessage, Feedback, Interrupt } from "./types.js";
|
|
4
5
|
import type { T9nMeta } from "@arcgis/lumina/controllers";
|
|
5
6
|
import type { ArcgisMap as ArcgisMap } from "@arcgis/map-components/components/arcgis-map";
|
|
6
7
|
|
|
@@ -48,6 +49,8 @@ import type { ArcgisMap as ArcgisMap } from "@arcgis/map-components/components/a
|
|
|
48
49
|
export abstract class ArcgisAssistant extends LitElement {
|
|
49
50
|
/** @internal */
|
|
50
51
|
protected _messages: { assistantLabel: string; } & T9nMeta<{ assistantLabel: string; }>;
|
|
52
|
+
/** @default false */
|
|
53
|
+
accessor copyEnabled: boolean;
|
|
51
54
|
/**
|
|
52
55
|
* The description text displayed below the heading in the assistant. This text provides additional
|
|
53
56
|
* context about the assistant's capabilities and how users can interact with it.
|
|
@@ -77,6 +80,8 @@ export abstract class ArcgisAssistant extends LitElement {
|
|
|
77
80
|
* ```
|
|
78
81
|
*/
|
|
79
82
|
accessor entryMessage: string | undefined;
|
|
83
|
+
/** @default false */
|
|
84
|
+
accessor feedbackEnabled: boolean;
|
|
80
85
|
/**
|
|
81
86
|
* The heading text displayed at the top of the assistant. This name should be concise and
|
|
82
87
|
* descriptive of the assistant's purpose.
|
|
@@ -92,16 +97,9 @@ export abstract class ArcgisAssistant extends LitElement {
|
|
|
92
97
|
* ```
|
|
93
98
|
*/
|
|
94
99
|
accessor heading: string | undefined;
|
|
95
|
-
/**
|
|
96
|
-
|
|
97
|
-
|
|
98
|
-
* @example
|
|
99
|
-
* ```js
|
|
100
|
-
* const assistant = document.querySelector("arcgis-assistant");
|
|
101
|
-
* assistant.portal = new Portal({ url: "https://www.arcgis.com" });
|
|
102
|
-
* ```
|
|
103
|
-
*/
|
|
104
|
-
accessor portal: Portal;
|
|
100
|
+
/** @default false */
|
|
101
|
+
accessor logEnabled: boolean;
|
|
102
|
+
accessor messages: Collection<ChatMessage>;
|
|
105
103
|
/**
|
|
106
104
|
* The reference element to the map that provides context for the assistant and its agents. Currently,
|
|
107
105
|
* this is only scoped to `arcgis-map` elements, but may be extended to support other elements in
|
|
@@ -129,4 +127,24 @@ export abstract class ArcgisAssistant extends LitElement {
|
|
|
129
127
|
* ```
|
|
130
128
|
*/
|
|
131
129
|
accessor suggestedPrompts: string[];
|
|
130
|
+
/** @param message */
|
|
131
|
+
submitMessage(message: string): Promise<void>;
|
|
132
|
+
readonly arcgisCancel: import("@arcgis/lumina").TargetedEvent<this, void>;
|
|
133
|
+
readonly arcgisError: import("@arcgis/lumina").TargetedEvent<this, Error>;
|
|
134
|
+
readonly arcgisFeedback: import("@arcgis/lumina").TargetedEvent<this, Feedback>;
|
|
135
|
+
readonly arcgisInterrupt: import("@arcgis/lumina").TargetedEvent<this, Interrupt>;
|
|
136
|
+
readonly arcgisInterruptCancel: import("@arcgis/lumina").TargetedEvent<this, void>;
|
|
137
|
+
readonly arcgisInterruptSubmit: import("@arcgis/lumina").TargetedEvent<this, string[] | boolean | string>;
|
|
138
|
+
readonly arcgisReady: import("@arcgis/lumina").TargetedEvent<this, void>;
|
|
139
|
+
readonly arcgisSubmit: import("@arcgis/lumina").TargetedEvent<this, string>;
|
|
140
|
+
readonly "@eventTypes": {
|
|
141
|
+
arcgisCancel: ArcgisAssistant["arcgisCancel"]["detail"];
|
|
142
|
+
arcgisError: ArcgisAssistant["arcgisError"]["detail"];
|
|
143
|
+
arcgisFeedback: ArcgisAssistant["arcgisFeedback"]["detail"];
|
|
144
|
+
arcgisInterrupt: ArcgisAssistant["arcgisInterrupt"]["detail"];
|
|
145
|
+
arcgisInterruptCancel: ArcgisAssistant["arcgisInterruptCancel"]["detail"];
|
|
146
|
+
arcgisInterruptSubmit: ArcgisAssistant["arcgisInterruptSubmit"]["detail"];
|
|
147
|
+
arcgisReady: ArcgisAssistant["arcgisReady"]["detail"];
|
|
148
|
+
arcgisSubmit: ArcgisAssistant["arcgisSubmit"]["detail"];
|
|
149
|
+
};
|
|
132
150
|
}
|
|
@@ -1,25 +1,26 @@
|
|
|
1
1
|
/* COPYRIGHT Esri - https://js.arcgis.com/5.1/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,67 @@ 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
41
|
portal: this.portal,
|
|
41
42
|
view: this.view ?? void 0
|
|
42
43
|
})
|
|
43
44
|
), this.addHandles([
|
|
44
|
-
|
|
45
|
+
E(
|
|
45
46
|
() => [this.view, this.agents],
|
|
46
47
|
() => void this._initialize()
|
|
47
48
|
)
|
|
48
49
|
]);
|
|
49
50
|
}
|
|
50
|
-
async *ask(
|
|
51
|
+
async *ask(c, t) {
|
|
51
52
|
if (!this.orchestrator)
|
|
52
53
|
throw new Error("Orchestrator not initialized yet.");
|
|
53
54
|
this._set("processing", !0), this._set("processingStep", "");
|
|
54
|
-
|
|
55
|
+
const e = [];
|
|
55
56
|
try {
|
|
56
|
-
const
|
|
57
|
-
for await (const s of
|
|
57
|
+
const i = this.orchestrator.ask(c);
|
|
58
|
+
for await (const s of i) {
|
|
59
|
+
const r = s.runId;
|
|
58
60
|
if (t?.aborted) {
|
|
59
|
-
yield { type: "cancelled" };
|
|
61
|
+
yield { type: "cancelled", runId: r };
|
|
60
62
|
break;
|
|
61
63
|
}
|
|
62
64
|
switch (s.type) {
|
|
63
65
|
case "trace": {
|
|
64
|
-
this._set("processingStep", s.data.text), e
|
|
65
|
-
|
|
66
|
-
`;
|
|
66
|
+
this._set("processingStep", s.data.text), e.push(s.data.text);
|
|
67
67
|
break;
|
|
68
68
|
}
|
|
69
69
|
case "completed": {
|
|
70
70
|
if (!s.result.content.length) {
|
|
71
|
-
yield { type: "completed", error: "Could not process the request.", log: e };
|
|
71
|
+
yield { type: "completed", error: "Could not process the request.", log: e, runId: r };
|
|
72
72
|
return;
|
|
73
73
|
}
|
|
74
74
|
const n = s.result.content;
|
|
75
|
-
this._set("processingStep", ""), yield { type: "completed", response: n, log: e };
|
|
75
|
+
this._set("processingStep", ""), yield { type: "completed", response: n, log: e, runId: r };
|
|
76
76
|
return;
|
|
77
77
|
}
|
|
78
78
|
case "interrupt": {
|
|
79
|
-
|
|
80
|
-
const { kind: n, message: o, metadata: u } = s.interrupt, h = Array.isArray(u) ? [...u] : [], d = (() => {
|
|
79
|
+
const { kind: n, message: p, metadata: d } = s.interrupt, g = Array.isArray(d) ? [...d] : [], f = (() => {
|
|
81
80
|
switch (n) {
|
|
82
81
|
case "booleanChoice":
|
|
83
|
-
return { type: "boolean-choice", message:
|
|
82
|
+
return { type: "boolean-choice", message: p, options: g };
|
|
84
83
|
case "singleSelection":
|
|
85
|
-
return { type: "single-select", message:
|
|
84
|
+
return { type: "single-select", message: p, options: g };
|
|
86
85
|
case "multipleSelection":
|
|
87
|
-
return { type: "multi-select", message:
|
|
86
|
+
return { type: "multi-select", message: p, options: g };
|
|
88
87
|
case "textInput":
|
|
89
|
-
return { type: "text-input", message:
|
|
88
|
+
return { type: "text-input", message: p };
|
|
90
89
|
default:
|
|
91
|
-
return { type: n, message:
|
|
90
|
+
return { type: n, message: p, options: g };
|
|
92
91
|
}
|
|
93
92
|
})();
|
|
94
|
-
this._set("processingStep", "Waiting for user input..."), yield { type: "interrupt", payload:
|
|
93
|
+
this._set("processingStep", "Waiting for user input..."), yield { type: "interrupt", payload: f, runId: r };
|
|
95
94
|
break;
|
|
96
95
|
}
|
|
97
96
|
case "cancelled": {
|
|
98
|
-
yield { type: "cancelled" };
|
|
97
|
+
yield { type: "cancelled", runId: r };
|
|
99
98
|
return;
|
|
100
99
|
}
|
|
101
100
|
default: {
|
|
@@ -104,145 +103,164 @@ let i = class extends L {
|
|
|
104
103
|
}
|
|
105
104
|
}
|
|
106
105
|
}
|
|
107
|
-
} catch (
|
|
108
|
-
console.warn("Error during message processing:",
|
|
106
|
+
} catch (i) {
|
|
107
|
+
console.warn("Error during message processing:", i), yield { type: "completed", error: "An error occurred during message processing.", log: e, runId: "error" };
|
|
109
108
|
return;
|
|
110
109
|
} finally {
|
|
111
110
|
this._set("processing", !1);
|
|
112
111
|
}
|
|
113
112
|
}
|
|
114
113
|
};
|
|
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
|
|
114
|
+
l([
|
|
115
|
+
h({ readOnly: !0 })
|
|
116
|
+
], a.prototype, "orchestrator", 2);
|
|
117
|
+
l([
|
|
118
|
+
h()
|
|
119
|
+
], a.prototype, "agents", 2);
|
|
120
|
+
l([
|
|
121
|
+
h()
|
|
122
|
+
], a.prototype, "portal", 2);
|
|
123
|
+
l([
|
|
124
|
+
h()
|
|
125
|
+
], a.prototype, "view", 2);
|
|
126
|
+
l([
|
|
127
|
+
h({ readOnly: !0 })
|
|
128
|
+
], a.prototype, "loading", 2);
|
|
129
|
+
l([
|
|
130
|
+
h({ readOnly: !0 })
|
|
131
|
+
], a.prototype, "processing", 2);
|
|
132
|
+
l([
|
|
133
|
+
h({ readOnly: !0 })
|
|
134
|
+
], a.prototype, "processingStep", 2);
|
|
135
|
+
a = l([
|
|
136
|
+
I("OrchestratorController")
|
|
137
|
+
], a);
|
|
138
|
+
class z extends C {
|
|
140
139
|
constructor() {
|
|
141
|
-
super(...arguments), this._messages =
|
|
142
|
-
t.stopPropagation(), this.orchestrator?.cancelInterrupt(), this._interrupt = null;
|
|
143
|
-
}, this.#
|
|
140
|
+
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) => {
|
|
141
|
+
t.stopPropagation(), this.arcgisInterruptCancel.emit(), this.orchestrator?.cancelInterrupt(), this._interrupt = null;
|
|
142
|
+
}, this.#n = (t) => {
|
|
144
143
|
t.stopPropagation();
|
|
145
144
|
const e = t.detail;
|
|
146
|
-
this.orchestrator?.resumeInterrupt(e), this._interrupt = null;
|
|
147
|
-
}, this.#
|
|
145
|
+
this.arcgisInterruptSubmit.emit(e), this.orchestrator?.resumeInterrupt(e), this._interrupt = null;
|
|
146
|
+
}, this.#l = (t) => {
|
|
148
147
|
t.stopPropagation(), this.suggestedPrompts = [];
|
|
149
148
|
const e = t.detail;
|
|
150
|
-
this
|
|
151
|
-
}, this.#
|
|
152
|
-
if (t.stopPropagation(), this._interrupt) {
|
|
149
|
+
this.arcgisSubmit.emit(e), this.submitMessage(e);
|
|
150
|
+
}, this.#c = (t) => {
|
|
151
|
+
if (t.stopPropagation(), this.arcgisCancel.emit(), this._interrupt) {
|
|
153
152
|
this.orchestrator?.cancelInterrupt(), this._interrupt = null;
|
|
154
153
|
return;
|
|
155
154
|
}
|
|
156
155
|
this.#r?.abort();
|
|
157
|
-
}, this
|
|
156
|
+
}, this.#h = (t) => {
|
|
157
|
+
t.stopPropagation();
|
|
158
|
+
const e = t.detail;
|
|
159
|
+
this.arcgisFeedback.emit(e);
|
|
160
|
+
}, 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
161
|
}
|
|
159
162
|
static {
|
|
160
|
-
this.properties = { _interrupt: 16,
|
|
163
|
+
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
164
|
}
|
|
162
165
|
static {
|
|
163
|
-
this.styles =
|
|
166
|
+
this.styles = x;
|
|
164
167
|
}
|
|
165
168
|
#e;
|
|
166
169
|
#s;
|
|
167
170
|
#t;
|
|
168
171
|
#r;
|
|
169
|
-
#n;
|
|
170
|
-
#i;
|
|
171
172
|
#o;
|
|
173
|
+
#i;
|
|
172
174
|
#a;
|
|
175
|
+
#n;
|
|
173
176
|
#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() {
|
|
177
|
+
#c;
|
|
178
|
+
#h;
|
|
179
|
+
async #p() {
|
|
198
180
|
try {
|
|
199
|
-
const t = P(this.referenceElement);
|
|
181
|
+
const t = P(this.el, this.referenceElement);
|
|
200
182
|
await t?.componentOnReady();
|
|
201
|
-
const e = [...this.#
|
|
202
|
-
this.#t = new
|
|
183
|
+
const e = [...this.#o.values()];
|
|
184
|
+
return e.length ? (this.#t = new a({
|
|
203
185
|
agents: e,
|
|
204
|
-
portal: this
|
|
186
|
+
portal: this.#i,
|
|
205
187
|
view: t?.view
|
|
206
|
-
}), await this.#t.load();
|
|
188
|
+
}), await this.#t.load(), !0) : (this._error = "No agents found.", !1);
|
|
207
189
|
} catch (t) {
|
|
208
|
-
|
|
190
|
+
return this._error = "Error initializing orchestrator.", M(this)(t), !1;
|
|
209
191
|
}
|
|
210
192
|
}
|
|
211
|
-
|
|
193
|
+
get _user() {
|
|
194
|
+
return this.#i?.user?.fullName || this.#i?.user?.username;
|
|
195
|
+
}
|
|
196
|
+
get orchestrator() {
|
|
197
|
+
return this.#t?.orchestrator;
|
|
198
|
+
}
|
|
199
|
+
register(t) {
|
|
200
|
+
this.#o.set(t.agent.id, t);
|
|
201
|
+
}
|
|
202
|
+
async submitMessage(t) {
|
|
212
203
|
const e = t.trim();
|
|
213
|
-
if (!e || (this.
|
|
214
|
-
|
|
204
|
+
if (!e || (this.messages.push({
|
|
205
|
+
id: Date.now().toString(),
|
|
206
|
+
// TODO: Replace with a more robust ID generation method or get from orchestrator
|
|
207
|
+
role: "user",
|
|
215
208
|
content: e
|
|
216
209
|
}), !this.#t))
|
|
217
210
|
return;
|
|
218
211
|
this.#r = new AbortController();
|
|
219
|
-
const
|
|
220
|
-
for await (const s of
|
|
212
|
+
const i = this.#t.ask(e, this.#r.signal);
|
|
213
|
+
for await (const s of i) {
|
|
214
|
+
const r = s.runId;
|
|
221
215
|
switch (s.type) {
|
|
222
216
|
case "completed":
|
|
223
|
-
this.
|
|
224
|
-
|
|
217
|
+
this.messages.push({
|
|
218
|
+
role: "assistant",
|
|
225
219
|
content: s.response,
|
|
226
220
|
log: s.log,
|
|
227
|
-
error: s.error
|
|
221
|
+
error: s.error,
|
|
222
|
+
id: r
|
|
228
223
|
});
|
|
229
224
|
break;
|
|
230
225
|
case "interrupt":
|
|
231
|
-
this._interrupt = s.payload;
|
|
226
|
+
this._interrupt = { ...s.payload, id: r };
|
|
232
227
|
break;
|
|
233
228
|
case "cancelled":
|
|
234
|
-
this.
|
|
235
|
-
|
|
236
|
-
error: "Request cancelled."
|
|
229
|
+
this.messages.push({
|
|
230
|
+
role: "assistant",
|
|
231
|
+
error: "Request cancelled.",
|
|
232
|
+
id: r
|
|
237
233
|
});
|
|
238
234
|
break;
|
|
239
235
|
}
|
|
236
|
+
}
|
|
237
|
+
}
|
|
238
|
+
load() {
|
|
239
|
+
this.manager.onLifecycle(() => () => {
|
|
240
|
+
this.#r?.abort(), this._interrupt = null, this.messages.removeAll(), this._error = null;
|
|
241
|
+
});
|
|
242
|
+
}
|
|
243
|
+
loaded() {
|
|
244
|
+
this.manager.onLifecycle(() => {
|
|
245
|
+
this.#e.value?.addEventListener("arcgisSubmit", this.#l), this.#e.value?.addEventListener("arcgisCancel", this.#c), this.#e.value?.addEventListener("arcgisFeedback", this.#h);
|
|
246
|
+
const t = $(() => !!this._interrupt && !!this.#s.value, () => {
|
|
247
|
+
const e = this.#s.value;
|
|
248
|
+
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);
|
|
249
|
+
});
|
|
250
|
+
return queueMicrotask(() => {
|
|
251
|
+
this.#p().then((e) => {
|
|
252
|
+
e ? this.arcgisReady.emit() : this.arcgisError.emit(new Error(this._error || "Unknown error initializing assistant."));
|
|
253
|
+
});
|
|
254
|
+
}), () => {
|
|
255
|
+
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;
|
|
256
|
+
};
|
|
257
|
+
});
|
|
240
258
|
}
|
|
241
259
|
render() {
|
|
242
|
-
return
|
|
260
|
+
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
261
|
}
|
|
244
262
|
}
|
|
245
|
-
|
|
263
|
+
v("arcgis-assistant", z);
|
|
246
264
|
export {
|
|
247
|
-
|
|
265
|
+
z as ArcgisAssistant
|
|
248
266
|
};
|
|
@@ -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
|
+
}
|