@arcgis/ai-components 5.2.0-next.87 → 5.2.0-next.88
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/{PNFK73E5.js → 64K5QGMS.js} +1 -1
- package/dist/cdn/7FY7WAA5.js +2 -0
- package/dist/cdn/{7XY54M57.js → APDJ4EPR.js} +1 -1
- package/dist/cdn/{NTBDGSXI.js → C4MALUDF.js} +1 -1
- package/dist/cdn/{IOKXNJWG.js → ESHAIDS7.js} +1 -1
- package/dist/cdn/{HNL4WZKH.js → EUM4DZDR.js} +1 -1
- package/dist/cdn/{WPKGJJ57.js → GPXL4CYF.js} +1 -1
- package/dist/cdn/{LF2LOV25.js → HJEYVERV.js} +1 -1
- package/dist/cdn/{TAJLCMAG.js → MBBDTSIF.js} +1 -1
- package/dist/cdn/{CF6ZLMFG.js → PQ5HW7F5.js} +1 -1
- package/dist/cdn/{B3YSZHAE.js → PULEMR55.js} +1 -1
- package/dist/cdn/{JKMZQOJQ.js → R7CCQNIY.js} +1 -1
- package/dist/cdn/{Y2776DWQ.js → YNWG4AIR.js} +14 -14
- package/dist/cdn/agent-utils/index.js +1 -1
- package/dist/cdn/index.js +1 -1
- package/dist/chunks/adapter.js +5 -1
- package/dist/components/arcgis-assistant-agent/customElement.js +208 -208
- 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/W5G35GO4.js +0 -2
|
@@ -1,19 +1,19 @@
|
|
|
1
1
|
/* COPYRIGHT Esri - https://js.arcgis.com/5.2/LICENSE.txt */
|
|
2
2
|
import { c as q } from "../../chunks/runtime.js";
|
|
3
|
-
import { LitElement as
|
|
4
|
-
import { b as
|
|
5
|
-
import
|
|
3
|
+
import { LitElement as M } from "@arcgis/lumina";
|
|
4
|
+
import { b as W, i as L } from "../../chunks/utils2.js";
|
|
5
|
+
import C from "@arcgis/core/portal/PortalItem.js";
|
|
6
6
|
import j from "@arcgis/core/portal/Portal.js";
|
|
7
7
|
import { property as n, subclass as l } from "@arcgis/core/core/accessorSupport/decorators.js";
|
|
8
8
|
import { BaseAgent as G } from "../../agent-utils/BaseAgent.js";
|
|
9
9
|
import b from "@arcgis/core/core/Error.js";
|
|
10
10
|
import { z as c } from "zod";
|
|
11
11
|
import { c as B } from "../../chunks/graph.js";
|
|
12
|
-
import
|
|
13
|
-
import { LLMAgent as
|
|
14
|
-
import { PromptTemplate as
|
|
12
|
+
import T from "@arcgis/core/core/Accessor.js";
|
|
13
|
+
import { LLMAgent as z } from "../../agent-utils/LLMAgent.js";
|
|
14
|
+
import { PromptTemplate as Z } from "@langchain/core/prompts";
|
|
15
15
|
import { Annotation as x } from "@langchain/langgraph";
|
|
16
|
-
import { b as H, d as
|
|
16
|
+
import { b as H, d as U } from "../../chunks/state.js";
|
|
17
17
|
import "@arcgis/core/identity/IdentityManager.js";
|
|
18
18
|
import "@arcgis/core/request.js";
|
|
19
19
|
import "@langchain/langgraph/web";
|
|
@@ -25,26 +25,26 @@ import "@langchain/openai";
|
|
|
25
25
|
import "@arcgis/core/config.js";
|
|
26
26
|
import "@arcgis/core/core/reactiveUtils.js";
|
|
27
27
|
import "@arcgis/core/layers/FeatureLayer.js";
|
|
28
|
-
import { a as
|
|
29
|
-
var K = Object.defineProperty, Q = Object.getOwnPropertyDescriptor, f = (
|
|
30
|
-
for (var o = s > 1 ? void 0 : s ? Q(
|
|
31
|
-
(i =
|
|
32
|
-
return s && o && K(
|
|
28
|
+
import { a as V } from "../../chunks/baseAgentState.js";
|
|
29
|
+
var K = Object.defineProperty, Q = Object.getOwnPropertyDescriptor, f = (t, e, r, s) => {
|
|
30
|
+
for (var o = s > 1 ? void 0 : s ? Q(e, r) : e, a = t.length - 1, i; a >= 0; a--)
|
|
31
|
+
(i = t[a]) && (o = (s ? i(e, r, o) : i(o)) || o);
|
|
32
|
+
return s && o && K(e, r, o), o;
|
|
33
33
|
};
|
|
34
|
-
let p = class extends
|
|
34
|
+
let p = class extends T {
|
|
35
35
|
//#region Lifecycle
|
|
36
|
-
constructor(
|
|
37
|
-
super(
|
|
36
|
+
constructor(t) {
|
|
37
|
+
super(t);
|
|
38
38
|
}
|
|
39
39
|
//#endregion
|
|
40
40
|
//#region Public Methods
|
|
41
|
-
static fromJSON(
|
|
41
|
+
static fromJSON(t) {
|
|
42
42
|
return new p({
|
|
43
|
-
id:
|
|
44
|
-
sourceAnchorId:
|
|
45
|
-
sourceNodeId:
|
|
46
|
-
targetAnchorId:
|
|
47
|
-
targetNodeId:
|
|
43
|
+
id: t.id,
|
|
44
|
+
sourceAnchorId: t.source_anchor_id,
|
|
45
|
+
sourceNodeId: t.source_node_id,
|
|
46
|
+
targetAnchorId: t.target_anchor_id,
|
|
47
|
+
targetNodeId: t.target_node_id
|
|
48
48
|
});
|
|
49
49
|
}
|
|
50
50
|
//#endregion
|
|
@@ -67,31 +67,31 @@ f([
|
|
|
67
67
|
p = f([
|
|
68
68
|
l("Edge")
|
|
69
69
|
], p);
|
|
70
|
-
var X = Object.defineProperty, Y = Object.getOwnPropertyDescriptor, v = (
|
|
71
|
-
for (var o = s > 1 ? void 0 : s ? Y(
|
|
72
|
-
(i =
|
|
73
|
-
return s && o && X(
|
|
70
|
+
var X = Object.defineProperty, Y = Object.getOwnPropertyDescriptor, v = (t, e, r, s) => {
|
|
71
|
+
for (var o = s > 1 ? void 0 : s ? Y(e, r) : e, a = t.length - 1, i; a >= 0; a--)
|
|
72
|
+
(i = t[a]) && (o = (s ? i(e, r, o) : i(o)) || o);
|
|
73
|
+
return s && o && X(e, r, o), o;
|
|
74
74
|
};
|
|
75
|
-
let m = class extends
|
|
75
|
+
let m = class extends T {
|
|
76
76
|
//#region Lifecycle
|
|
77
|
-
constructor(
|
|
78
|
-
super(
|
|
77
|
+
constructor(t) {
|
|
78
|
+
super(t);
|
|
79
79
|
}
|
|
80
80
|
//#endregion
|
|
81
81
|
//#region Public Methods
|
|
82
82
|
async load() {
|
|
83
83
|
return await Promise.resolve(this);
|
|
84
84
|
}
|
|
85
|
-
compile(
|
|
85
|
+
compile(t) {
|
|
86
86
|
return {
|
|
87
87
|
runtimeNode: this.createRuntimeNode(),
|
|
88
|
-
edges:
|
|
88
|
+
edges: t.outgoingEdges.map((e) => ({
|
|
89
89
|
from: this.id,
|
|
90
|
-
to:
|
|
90
|
+
to: e.targetNodeId
|
|
91
91
|
}))
|
|
92
92
|
};
|
|
93
93
|
}
|
|
94
|
-
static fromJSON(
|
|
94
|
+
static fromJSON(t) {
|
|
95
95
|
throw new Error("BaseNode is abstract and cannot be instantiated directly.");
|
|
96
96
|
}
|
|
97
97
|
//#endregion
|
|
@@ -110,144 +110,144 @@ v([
|
|
|
110
110
|
m = v([
|
|
111
111
|
l("BaseNode")
|
|
112
112
|
], m);
|
|
113
|
-
function
|
|
114
|
-
const
|
|
115
|
-
Object.entries(
|
|
116
|
-
const a =
|
|
117
|
-
return [s,
|
|
113
|
+
function I(t) {
|
|
114
|
+
const e = new Set(t.required), r = Object.fromEntries(
|
|
115
|
+
Object.entries(t.properties).map(([s, o]) => {
|
|
116
|
+
const a = $(o);
|
|
117
|
+
return [s, e.has(s) ? a : a.optional()];
|
|
118
118
|
})
|
|
119
119
|
);
|
|
120
120
|
return c.object(r);
|
|
121
121
|
}
|
|
122
|
-
function
|
|
123
|
-
let
|
|
124
|
-
switch (
|
|
122
|
+
function $(t) {
|
|
123
|
+
let e;
|
|
124
|
+
switch (t.type) {
|
|
125
125
|
case "array":
|
|
126
|
-
|
|
126
|
+
e = c.array(t.items ? $(t.items) : c.unknown());
|
|
127
127
|
break;
|
|
128
128
|
case "boolean":
|
|
129
|
-
|
|
129
|
+
e = c.boolean();
|
|
130
130
|
break;
|
|
131
131
|
case "number":
|
|
132
|
-
|
|
132
|
+
e = c.number();
|
|
133
133
|
break;
|
|
134
134
|
case "object":
|
|
135
|
-
|
|
136
|
-
properties:
|
|
137
|
-
required:
|
|
135
|
+
e = I({
|
|
136
|
+
properties: t.properties ?? {},
|
|
137
|
+
required: t.required
|
|
138
138
|
});
|
|
139
139
|
break;
|
|
140
140
|
case "string":
|
|
141
|
-
|
|
141
|
+
e = t.enum?.length ? c.enum(t.enum) : c.string();
|
|
142
142
|
break;
|
|
143
143
|
}
|
|
144
|
-
return
|
|
144
|
+
return t.description ? e.describe(t.description) : e;
|
|
145
145
|
}
|
|
146
146
|
const k = /* @__PURE__ */ new Map([
|
|
147
147
|
[
|
|
148
|
-
"
|
|
148
|
+
"clear_filters",
|
|
149
149
|
async () => (await import("../../agents/tools/filter/clearFilters/adapter.js")).clearFiltersTool
|
|
150
150
|
],
|
|
151
151
|
[
|
|
152
|
-
"
|
|
152
|
+
"reset_map",
|
|
153
153
|
async () => (await import("../../agents/tools/filter/resetMap/adapter.js")).resetMapTool
|
|
154
154
|
],
|
|
155
155
|
[
|
|
156
|
-
"
|
|
156
|
+
"set_feature_effect",
|
|
157
157
|
async () => (await import("../../agents/tools/filter/setFeatureEffect/adapter.js")).setFeatureEffectTool
|
|
158
158
|
],
|
|
159
159
|
[
|
|
160
|
-
"
|
|
160
|
+
"list_layer_fields",
|
|
161
161
|
async () => (await import("../../agents/tools/help/listFields/adapter.js")).listLayerFieldsTool
|
|
162
162
|
],
|
|
163
163
|
[
|
|
164
|
-
"
|
|
164
|
+
"go_to_address",
|
|
165
165
|
async () => (await import("../../agents/tools/navigation/goToAddress/adapter.js")).goToAddressTool
|
|
166
166
|
],
|
|
167
167
|
[
|
|
168
|
-
"
|
|
168
|
+
"go_to_bookmark",
|
|
169
169
|
async () => (await import("../../agents/tools/navigation/goToBookmark/adapter.js")).goToBookmarkTool
|
|
170
170
|
],
|
|
171
171
|
[
|
|
172
|
-
"
|
|
172
|
+
"go_to_features",
|
|
173
173
|
async () => (await import("../../agents/tools/navigation/goToFeatures/adapter.js")).goToFeaturesTool
|
|
174
174
|
],
|
|
175
175
|
[
|
|
176
|
-
"
|
|
176
|
+
"go_to_full_extent",
|
|
177
177
|
async () => (await import("../../agents/tools/navigation/goToFullExtent/adapter.js")).goToFullExtentTool
|
|
178
178
|
],
|
|
179
179
|
[
|
|
180
|
-
"
|
|
180
|
+
"go_to_home_extent",
|
|
181
181
|
async () => (await import("../../agents/tools/navigation/goToHomeExtent/adapter.js")).goToHomeExtentTool
|
|
182
182
|
],
|
|
183
183
|
[
|
|
184
|
-
"
|
|
184
|
+
"go_to_layer",
|
|
185
185
|
async () => (await import("../../agents/tools/navigation/goToLayer/adapter.js")).goToLayerTool
|
|
186
186
|
],
|
|
187
187
|
[
|
|
188
|
-
"
|
|
188
|
+
"go_to_scale",
|
|
189
189
|
async () => (await import("../../agents/tools/navigation/goToScale/adapter.js")).goToScaleTool
|
|
190
190
|
],
|
|
191
191
|
[
|
|
192
|
-
"
|
|
192
|
+
"go_to_viewpoint",
|
|
193
193
|
async () => (await import("../../agents/tools/navigation/goToViewpoint/adapter.js")).goToViewpointTool
|
|
194
194
|
],
|
|
195
195
|
[
|
|
196
|
-
"
|
|
196
|
+
"go_to_zoom",
|
|
197
197
|
async () => (await import("../../agents/tools/navigation/goToZoom/adapter.js")).goToZoomTool
|
|
198
198
|
],
|
|
199
199
|
[
|
|
200
|
-
"
|
|
200
|
+
"find_relevant_fields",
|
|
201
201
|
async () => (await import("../../agents/tools/search/findRelevantFields/adapter.js")).findRelevantFieldsTool
|
|
202
202
|
],
|
|
203
203
|
[
|
|
204
|
-
"
|
|
204
|
+
"find_relevant_layers",
|
|
205
205
|
async () => (await import("../../agents/tools/search/findRelevantLayers/adapter.js")).findRelevantLayersTool
|
|
206
206
|
],
|
|
207
207
|
[
|
|
208
|
-
"
|
|
208
|
+
"get_attribute",
|
|
209
209
|
async () => (await import("../../agents/tools/query/getAttribute/adapter.js")).getAttributeTool
|
|
210
210
|
],
|
|
211
211
|
[
|
|
212
|
-
"
|
|
212
|
+
"get_statistics",
|
|
213
213
|
async () => (await import("../../agents/tools/query/getStatistics/adapter.js")).getStatisticsTool
|
|
214
214
|
],
|
|
215
215
|
[
|
|
216
|
-
"
|
|
216
|
+
"get_top_features",
|
|
217
217
|
async () => (await import("../../agents/tools/query/getTopFeatures/adapter.js")).getTopFeaturesTool
|
|
218
218
|
],
|
|
219
219
|
[
|
|
220
|
-
"
|
|
220
|
+
"query_features",
|
|
221
221
|
async () => (await import("../../agents/tools/query/queryFeatures/adapter.js")).queryFeaturesTool
|
|
222
222
|
]
|
|
223
223
|
]);
|
|
224
|
-
async function
|
|
225
|
-
const
|
|
226
|
-
if (!
|
|
227
|
-
throw new Error(`ArcGIS tool is not supported in the browser runtime: ${
|
|
228
|
-
return await
|
|
224
|
+
async function tt(t) {
|
|
225
|
+
const e = k.get(t);
|
|
226
|
+
if (!e)
|
|
227
|
+
throw new Error(`ArcGIS tool is not supported in the browser runtime: ${t}`);
|
|
228
|
+
return await e();
|
|
229
229
|
}
|
|
230
|
-
var
|
|
231
|
-
for (var o = s > 1 ? void 0 : s ?
|
|
232
|
-
(i =
|
|
233
|
-
return s && o &&
|
|
230
|
+
var et = Object.defineProperty, ot = Object.getOwnPropertyDescriptor, N = (t, e, r, s) => {
|
|
231
|
+
for (var o = s > 1 ? void 0 : s ? ot(e, r) : e, a = t.length - 1, i; a >= 0; a--)
|
|
232
|
+
(i = t[a]) && (o = (s ? i(e, r, o) : i(o)) || o);
|
|
233
|
+
return s && o && et(e, r, o), o;
|
|
234
234
|
};
|
|
235
|
-
let d = class extends
|
|
235
|
+
let d = class extends T {
|
|
236
236
|
//#region Lifecycle
|
|
237
|
-
constructor(
|
|
238
|
-
super(
|
|
237
|
+
constructor(t) {
|
|
238
|
+
super(t), this.type = "arcgis-tool";
|
|
239
239
|
}
|
|
240
240
|
//#endregion
|
|
241
241
|
//#region Public Methods
|
|
242
242
|
async createRuntimeTools() {
|
|
243
243
|
if (!this.name)
|
|
244
244
|
throw new Error("ArcgisTool name is required");
|
|
245
|
-
return [await
|
|
245
|
+
return [await tt(this.name)];
|
|
246
246
|
}
|
|
247
|
-
static fromJSON(
|
|
247
|
+
static fromJSON(t) {
|
|
248
248
|
return new d({
|
|
249
|
-
name:
|
|
250
|
-
requireApproval:
|
|
249
|
+
name: t.name,
|
|
250
|
+
requireApproval: t.require_approval
|
|
251
251
|
});
|
|
252
252
|
}
|
|
253
253
|
//#endregion
|
|
@@ -264,25 +264,25 @@ N([
|
|
|
264
264
|
d = N([
|
|
265
265
|
l("ArcgisTool")
|
|
266
266
|
], d);
|
|
267
|
-
var
|
|
268
|
-
throw TypeError(
|
|
269
|
-
},
|
|
270
|
-
for (var o = s > 1 ? void 0 : s ?
|
|
271
|
-
(i =
|
|
272
|
-
return s && o &&
|
|
273
|
-
},
|
|
267
|
+
var rt = Object.defineProperty, st = Object.getOwnPropertyDescriptor, J = (t) => {
|
|
268
|
+
throw TypeError(t);
|
|
269
|
+
}, w = (t, e, r, s) => {
|
|
270
|
+
for (var o = s > 1 ? void 0 : s ? st(e, r) : e, a = t.length - 1, i; a >= 0; a--)
|
|
271
|
+
(i = t[a]) && (o = (s ? i(e, r, o) : i(o)) || o);
|
|
272
|
+
return s && o && rt(e, r, o), o;
|
|
273
|
+
}, at = (t, e, r) => e.has(t) || J("Cannot " + r), it = (t, e, r) => e.has(t) ? J("Cannot add the same private member more than once") : e instanceof WeakSet ? e.add(t) : e.set(t, r), nt = (t, e, r) => (at(t, e, "access private method"), r), S, R;
|
|
274
274
|
let u = class extends m {
|
|
275
275
|
//#region Lifecycle
|
|
276
|
-
constructor(
|
|
277
|
-
super(
|
|
276
|
+
constructor(t) {
|
|
277
|
+
super(t), it(this, S), this.type = "agent-node";
|
|
278
278
|
}
|
|
279
279
|
//#endregion
|
|
280
280
|
//#region Public Methods
|
|
281
281
|
createRuntimeNode() {
|
|
282
|
-
let
|
|
283
|
-
return async (
|
|
284
|
-
|
|
285
|
-
const o = await (await
|
|
282
|
+
let t;
|
|
283
|
+
return async (e, r) => {
|
|
284
|
+
t ??= nt(this, S, R).call(this);
|
|
285
|
+
const o = await (await t).run(e, r), a = this.outputSchema?.safeParse(o);
|
|
286
286
|
if (a && !a.success)
|
|
287
287
|
throw a.error;
|
|
288
288
|
const i = a?.data, O = i ?? o.outputMessage;
|
|
@@ -297,14 +297,14 @@ let u = class extends m {
|
|
|
297
297
|
};
|
|
298
298
|
};
|
|
299
299
|
}
|
|
300
|
-
compile(
|
|
301
|
-
const
|
|
300
|
+
compile(t) {
|
|
301
|
+
const e = t.outgoingEdges[0]?.targetNodeId;
|
|
302
302
|
return {
|
|
303
303
|
runtimeNode: this.createRuntimeNode(),
|
|
304
304
|
edges: [
|
|
305
305
|
{
|
|
306
306
|
from: this.id,
|
|
307
|
-
decide: (r) => r.status === "failed" ? void 0 :
|
|
307
|
+
decide: (r) => r.status === "failed" ? void 0 : e
|
|
308
308
|
}
|
|
309
309
|
],
|
|
310
310
|
schemas: [
|
|
@@ -314,86 +314,86 @@ let u = class extends m {
|
|
|
314
314
|
]
|
|
315
315
|
};
|
|
316
316
|
}
|
|
317
|
-
static fromJSON(
|
|
318
|
-
const
|
|
319
|
-
id:
|
|
320
|
-
label:
|
|
321
|
-
prompt:
|
|
317
|
+
static fromJSON(t) {
|
|
318
|
+
const e = new u({
|
|
319
|
+
id: t.id,
|
|
320
|
+
label: t.label,
|
|
321
|
+
prompt: t.prompt?.content,
|
|
322
322
|
type: "agent-node"
|
|
323
323
|
});
|
|
324
|
-
return
|
|
324
|
+
return t.structured_output && (e.outputSchema = I(t.structured_output)), e.tools = t.tools?.filter((r) => r.type === "arcgis_tool").map((r) => d.fromJSON(r)), e;
|
|
325
325
|
}
|
|
326
326
|
//#endregion
|
|
327
327
|
};
|
|
328
|
-
|
|
329
|
-
|
|
330
|
-
const
|
|
331
|
-
if (!
|
|
328
|
+
S = /* @__PURE__ */ new WeakSet();
|
|
329
|
+
R = async function() {
|
|
330
|
+
const t = this.prompt;
|
|
331
|
+
if (!t?.trim())
|
|
332
332
|
throw new Error(`WebAgent agent node "${this.id}" requires a prompt.`);
|
|
333
|
-
const
|
|
333
|
+
const e = [];
|
|
334
334
|
if (this.tools)
|
|
335
335
|
for (const r of this.tools) {
|
|
336
336
|
const s = await r.createRuntimeTools();
|
|
337
|
-
|
|
337
|
+
e.push(...s);
|
|
338
338
|
}
|
|
339
|
-
return new
|
|
339
|
+
return new z({
|
|
340
340
|
name: this.id,
|
|
341
341
|
// TODO: change to label
|
|
342
342
|
outputSchema: this.outputSchema,
|
|
343
|
-
prompt:
|
|
344
|
-
tools:
|
|
343
|
+
prompt: t,
|
|
344
|
+
tools: e
|
|
345
345
|
});
|
|
346
346
|
};
|
|
347
|
-
|
|
347
|
+
w([
|
|
348
348
|
n()
|
|
349
349
|
], u.prototype, "type", 2);
|
|
350
|
-
|
|
350
|
+
w([
|
|
351
351
|
n()
|
|
352
352
|
], u.prototype, "prompt", 2);
|
|
353
|
-
|
|
353
|
+
w([
|
|
354
354
|
n()
|
|
355
355
|
], u.prototype, "outputSchema", 2);
|
|
356
|
-
|
|
356
|
+
w([
|
|
357
357
|
n()
|
|
358
358
|
], u.prototype, "tools", 2);
|
|
359
|
-
u =
|
|
359
|
+
u = w([
|
|
360
360
|
l("AgentNode")
|
|
361
361
|
], u);
|
|
362
|
-
var
|
|
363
|
-
for (var o = s > 1 ? void 0 : s ?
|
|
364
|
-
(i =
|
|
365
|
-
return s && o &&
|
|
362
|
+
var ct = Object.defineProperty, pt = Object.getOwnPropertyDescriptor, A = (t, e, r, s) => {
|
|
363
|
+
for (var o = s > 1 ? void 0 : s ? pt(e, r) : e, a = t.length - 1, i; a >= 0; a--)
|
|
364
|
+
(i = t[a]) && (o = (s ? i(e, r, o) : i(o)) || o);
|
|
365
|
+
return s && o && ct(e, r, o), o;
|
|
366
366
|
};
|
|
367
367
|
let h = class extends m {
|
|
368
368
|
//#region Lifecycle
|
|
369
|
-
constructor(
|
|
370
|
-
super(
|
|
369
|
+
constructor(t) {
|
|
370
|
+
super(t), this.type = "end-message-node";
|
|
371
371
|
}
|
|
372
372
|
//#endregion
|
|
373
373
|
//#region Public Methods
|
|
374
374
|
createRuntimeNode() {
|
|
375
|
-
return async (
|
|
376
|
-
const
|
|
375
|
+
return async (t) => {
|
|
376
|
+
const e = await Z.fromTemplate(this.message, { templateFormat: "mustache" }).format(t);
|
|
377
377
|
return {
|
|
378
|
-
outputMessage:
|
|
378
|
+
outputMessage: e,
|
|
379
379
|
status: "success",
|
|
380
|
-
summary:
|
|
380
|
+
summary: e
|
|
381
381
|
};
|
|
382
382
|
};
|
|
383
383
|
}
|
|
384
|
-
compile(
|
|
384
|
+
compile(t) {
|
|
385
385
|
return {
|
|
386
386
|
runtimeNode: this.createRuntimeNode(),
|
|
387
387
|
edges: []
|
|
388
388
|
};
|
|
389
389
|
}
|
|
390
|
-
static fromJSON(
|
|
391
|
-
const
|
|
392
|
-
id:
|
|
393
|
-
label:
|
|
390
|
+
static fromJSON(t) {
|
|
391
|
+
const e = new h({
|
|
392
|
+
id: t.id,
|
|
393
|
+
label: t.label,
|
|
394
394
|
type: "end-message-node"
|
|
395
395
|
});
|
|
396
|
-
return
|
|
396
|
+
return e.message = t.message, e;
|
|
397
397
|
}
|
|
398
398
|
//#endregion
|
|
399
399
|
//#region Private Methods
|
|
@@ -408,25 +408,25 @@ A([
|
|
|
408
408
|
h = A([
|
|
409
409
|
l("EndMessageNode")
|
|
410
410
|
], h);
|
|
411
|
-
var
|
|
412
|
-
for (var o = s > 1 ? void 0 : s ?
|
|
413
|
-
(i =
|
|
414
|
-
return s && o &&
|
|
411
|
+
var mt = Object.defineProperty, ut = Object.getOwnPropertyDescriptor, D = (t, e, r, s) => {
|
|
412
|
+
for (var o = s > 1 ? void 0 : s ? ut(e, r) : e, a = t.length - 1, i; a >= 0; a--)
|
|
413
|
+
(i = t[a]) && (o = (s ? i(e, r, o) : i(o)) || o);
|
|
414
|
+
return s && o && mt(e, r, o), o;
|
|
415
415
|
};
|
|
416
|
-
let
|
|
416
|
+
let _ = class extends m {
|
|
417
417
|
//#region Lifecycle
|
|
418
|
-
constructor(
|
|
419
|
-
super(
|
|
418
|
+
constructor(t) {
|
|
419
|
+
super(t), this.type = "start-node";
|
|
420
420
|
}
|
|
421
421
|
//#endregion
|
|
422
422
|
//#region Public Methods
|
|
423
423
|
createRuntimeNode() {
|
|
424
|
-
return (
|
|
424
|
+
return (t) => ({ question: t.agentExecutionContext.userRequest });
|
|
425
425
|
}
|
|
426
|
-
static fromJSON(
|
|
427
|
-
return new
|
|
428
|
-
id:
|
|
429
|
-
label:
|
|
426
|
+
static fromJSON(t) {
|
|
427
|
+
return new _({
|
|
428
|
+
id: t.id,
|
|
429
|
+
label: t.label,
|
|
430
430
|
type: "start-node"
|
|
431
431
|
});
|
|
432
432
|
}
|
|
@@ -434,68 +434,68 @@ let w = class extends m {
|
|
|
434
434
|
//#region Private Methods
|
|
435
435
|
//#endregion
|
|
436
436
|
};
|
|
437
|
-
|
|
437
|
+
D([
|
|
438
438
|
n()
|
|
439
|
-
],
|
|
440
|
-
|
|
439
|
+
], _.prototype, "type", 2);
|
|
440
|
+
_ = D([
|
|
441
441
|
l("StartNode")
|
|
442
|
-
],
|
|
443
|
-
function
|
|
444
|
-
switch (
|
|
442
|
+
], _);
|
|
443
|
+
function dt(t) {
|
|
444
|
+
switch (t.type) {
|
|
445
445
|
case "agent_node":
|
|
446
|
-
return u.fromJSON(
|
|
446
|
+
return u.fromJSON(t);
|
|
447
447
|
case "end_message_node":
|
|
448
|
-
return h.fromJSON(
|
|
448
|
+
return h.fromJSON(t);
|
|
449
449
|
case "start_node":
|
|
450
|
-
return
|
|
450
|
+
return _.fromJSON(t);
|
|
451
451
|
default:
|
|
452
|
-
throw new Error(`WebAgent node "${
|
|
452
|
+
throw new Error(`WebAgent node "${t.id}" uses unsupported type "${t.type}".`);
|
|
453
453
|
}
|
|
454
454
|
}
|
|
455
|
-
function
|
|
456
|
-
const
|
|
457
|
-
if (H(
|
|
455
|
+
function lt(t = {}) {
|
|
456
|
+
const e = Object.keys(t);
|
|
457
|
+
if (H(e), e.includes("nodes"))
|
|
458
458
|
throw new Error("node state cannot define reserved field: nodes.");
|
|
459
|
-
const r =
|
|
459
|
+
const r = U(t);
|
|
460
460
|
return x.Root({
|
|
461
461
|
...r,
|
|
462
462
|
nodes: x({
|
|
463
463
|
reducer: (s, o) => ({ ...s, ...o }),
|
|
464
464
|
default: () => ({})
|
|
465
465
|
}),
|
|
466
|
-
...
|
|
466
|
+
...V()
|
|
467
467
|
});
|
|
468
468
|
}
|
|
469
|
-
function
|
|
470
|
-
const
|
|
471
|
-
for (const s of
|
|
469
|
+
function F(t) {
|
|
470
|
+
const e = /* @__PURE__ */ new Set();
|
|
471
|
+
for (const s of t)
|
|
472
472
|
for (const o of Object.keys(s.shape ?? {}))
|
|
473
|
-
o !== "nodes" &&
|
|
474
|
-
const r = Object.fromEntries([...
|
|
475
|
-
return
|
|
473
|
+
o !== "nodes" && e.add(o);
|
|
474
|
+
const r = Object.fromEntries([...e].map((s) => [s, void 0]));
|
|
475
|
+
return lt(r);
|
|
476
476
|
}
|
|
477
477
|
class P {
|
|
478
478
|
//#endregion Private Properties
|
|
479
479
|
//#region Lifecycle
|
|
480
|
-
constructor(
|
|
481
|
-
this.sourceJSON =
|
|
480
|
+
constructor(e, r, s) {
|
|
481
|
+
this.sourceJSON = e, this.edges = r, this.nodes = s, this._loaded = !1;
|
|
482
482
|
}
|
|
483
483
|
//#endregion Lifecycle
|
|
484
484
|
//#region Public Methods
|
|
485
|
-
static fromJSON(
|
|
485
|
+
static fromJSON(e) {
|
|
486
486
|
return new P(
|
|
487
|
-
|
|
488
|
-
|
|
489
|
-
|
|
487
|
+
e,
|
|
488
|
+
e.graph.edges.map((r) => p.fromJSON(r)),
|
|
489
|
+
e.graph.nodes.map((r) => dt(r))
|
|
490
490
|
);
|
|
491
491
|
}
|
|
492
492
|
async load() {
|
|
493
|
-
return this._loadPromise ??= Promise.all(this.nodes.map(async (
|
|
493
|
+
return this._loadPromise ??= Promise.all(this.nodes.map(async (e) => await e.load())).then(() => {
|
|
494
494
|
this._loaded = !0;
|
|
495
495
|
}), await this._loadPromise, this;
|
|
496
496
|
}
|
|
497
497
|
getSchemas() {
|
|
498
|
-
const
|
|
498
|
+
const e = Object.fromEntries(
|
|
499
499
|
this._getNodeCompilations().flatMap((s, o) => {
|
|
500
500
|
const a = this.nodes[o];
|
|
501
501
|
return s.schemas?.map((i) => [a.id, i]) ?? [];
|
|
@@ -503,16 +503,16 @@ class P {
|
|
|
503
503
|
);
|
|
504
504
|
return [c.object({
|
|
505
505
|
loopCounts: c.record(c.string(), c.number()).optional(),
|
|
506
|
-
nodes: c.object(
|
|
506
|
+
nodes: c.object(e).partial().optional(),
|
|
507
507
|
question: c.string().optional()
|
|
508
508
|
})];
|
|
509
509
|
}
|
|
510
510
|
generate() {
|
|
511
511
|
this._assertLoaded(), this._nodeCompilations = void 0;
|
|
512
|
-
const
|
|
512
|
+
const e = this._getNodeCompilations(), r = F(this.getSchemas()), s = this.nodes.find((i) => i.type === "start-node")?.id, o = {}, a = [];
|
|
513
513
|
for (const [i, O] of this.nodes.entries()) {
|
|
514
|
-
const
|
|
515
|
-
|
|
514
|
+
const y = e[i];
|
|
515
|
+
y && (y.runtimeNode && (o[O.id] = y.runtimeNode), a.push(...y.edges));
|
|
516
516
|
}
|
|
517
517
|
return {
|
|
518
518
|
createGraph: () => B(o, a, r, { entryNode: s }),
|
|
@@ -527,25 +527,25 @@ class P {
|
|
|
527
527
|
}
|
|
528
528
|
_getNodeCompilations() {
|
|
529
529
|
return this._assertLoaded(), this._nodeCompilations ??= this.nodes.map(
|
|
530
|
-
(
|
|
531
|
-
outgoingEdges: this.edges.filter((r) => r.sourceNodeId ===
|
|
530
|
+
(e) => e.compile({
|
|
531
|
+
outgoingEdges: this.edges.filter((r) => r.sourceNodeId === e.id)
|
|
532
532
|
})
|
|
533
533
|
);
|
|
534
534
|
}
|
|
535
535
|
//#endregion Private Methods
|
|
536
536
|
}
|
|
537
|
-
var
|
|
538
|
-
for (var o = s > 1 ? void 0 : s ?
|
|
539
|
-
(i =
|
|
540
|
-
return s && o &&
|
|
537
|
+
var ht = Object.defineProperty, gt = Object.getOwnPropertyDescriptor, E = (t, e, r, s) => {
|
|
538
|
+
for (var o = s > 1 ? void 0 : s ? gt(e, r) : e, a = t.length - 1, i; a >= 0; a--)
|
|
539
|
+
(i = t[a]) && (o = (s ? i(e, r, o) : i(o)) || o);
|
|
540
|
+
return s && o && ht(e, r, o), o;
|
|
541
541
|
};
|
|
542
|
-
const
|
|
542
|
+
const ft = () => {
|
|
543
543
|
throw new Error("WebAgent must be loaded before it can run.");
|
|
544
544
|
};
|
|
545
545
|
let g = class extends G {
|
|
546
546
|
//#region Lifecycle
|
|
547
|
-
constructor(
|
|
548
|
-
super(
|
|
547
|
+
constructor(t) {
|
|
548
|
+
super(t);
|
|
549
549
|
}
|
|
550
550
|
//#endregion
|
|
551
551
|
//#region Public Methods
|
|
@@ -556,32 +556,32 @@ let g = class extends G {
|
|
|
556
556
|
} catch (r) {
|
|
557
557
|
throw new b("web-agent:load-portal-item", "Failed to load portal item", { error: r });
|
|
558
558
|
}
|
|
559
|
-
const
|
|
560
|
-
if (this.sourceJSON =
|
|
559
|
+
const e = await this.portalItem.fetchData();
|
|
560
|
+
if (this.sourceJSON = e, !this.portalItem.title)
|
|
561
561
|
throw new b("web-agent:missing-title", "The portal item is missing a title");
|
|
562
562
|
}
|
|
563
563
|
if (!this.sourceJSON)
|
|
564
564
|
throw new b("web-agent:missing-source-json", "The source JSON is missing");
|
|
565
565
|
if (!this.sourceJSON.description)
|
|
566
566
|
throw new b("web-agent:missing-description", "The source JSON is missing a description");
|
|
567
|
-
const
|
|
568
|
-
return await
|
|
567
|
+
const t = P.fromJSON(this.sourceJSON);
|
|
568
|
+
return await t.load(), this._runtime = t, this.description = this.sourceJSON.description, this.name = this.portalItem?.title ?? `web-agent-${Date.now()}`, this.generate(), this;
|
|
569
569
|
}
|
|
570
570
|
getSchemas() {
|
|
571
571
|
return this._runtime?.getSchemas() ?? [];
|
|
572
572
|
}
|
|
573
573
|
generate() {
|
|
574
574
|
if (!this._runtime) {
|
|
575
|
-
this._set("workspace",
|
|
575
|
+
this._set("workspace", F([])), this._set("createGraph", ft);
|
|
576
576
|
return;
|
|
577
577
|
}
|
|
578
|
-
const { createGraph:
|
|
579
|
-
this._set("workspace",
|
|
578
|
+
const { createGraph: t, workspace: e } = this._runtime.generate();
|
|
579
|
+
this._set("workspace", e), this._set("createGraph", t);
|
|
580
580
|
}
|
|
581
581
|
//#endregion
|
|
582
582
|
};
|
|
583
583
|
E([
|
|
584
|
-
n({ type:
|
|
584
|
+
n({ type: C })
|
|
585
585
|
], g.prototype, "portalItem", 2);
|
|
586
586
|
E([
|
|
587
587
|
n()
|
|
@@ -589,29 +589,29 @@ E([
|
|
|
589
589
|
g = E([
|
|
590
590
|
l("WebAgent")
|
|
591
591
|
], g);
|
|
592
|
-
class
|
|
592
|
+
class _t extends M {
|
|
593
593
|
static {
|
|
594
594
|
this.properties = { agent: 0, context: 0, itemId: 1, workflow: 0 };
|
|
595
595
|
}
|
|
596
|
-
#
|
|
596
|
+
#t;
|
|
597
597
|
async getContext() {
|
|
598
|
-
return
|
|
598
|
+
return W(this.context) ? await this.context() : this.context;
|
|
599
599
|
}
|
|
600
600
|
async load() {
|
|
601
|
-
let
|
|
601
|
+
let e;
|
|
602
602
|
if (this.itemId) {
|
|
603
603
|
const r = j.getDefault();
|
|
604
|
-
|
|
605
|
-
} else this.workflow && (
|
|
606
|
-
if (
|
|
604
|
+
e = new g({ portalItem: new C({ id: this.itemId, portal: r }) });
|
|
605
|
+
} else this.workflow && (e = new g({ sourceJSON: this.workflow }));
|
|
606
|
+
if (e && (await e.load(), this.agent = e.registration), !this.agent)
|
|
607
607
|
throw new Error("Failed to initialize the assistant agent because the agent registration is missing.");
|
|
608
|
-
this.#
|
|
608
|
+
this.#t = L(this);
|
|
609
609
|
}
|
|
610
610
|
disconnectedCallback() {
|
|
611
|
-
this.#
|
|
611
|
+
this.#t?.unregister(this.agent.id), super.disconnectedCallback();
|
|
612
612
|
}
|
|
613
613
|
}
|
|
614
|
-
q("arcgis-assistant-agent",
|
|
614
|
+
q("arcgis-assistant-agent", _t);
|
|
615
615
|
export {
|
|
616
|
-
|
|
616
|
+
_t as ArcgisAssistantAgent
|
|
617
617
|
};
|