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