@arcgis/ai-components 5.2.0-next.71 → 5.2.0-next.72
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/LICENSE.md +4 -2
- package/dist/agent-utils/types.d.ts +1 -1
- package/dist/agentic-workflow/AgenticWorkflowRuntime.d.ts +24 -0
- package/dist/agentic-workflow/Edge.d.ts +16 -0
- package/dist/agentic-workflow/WebAgent.d.ts +39 -0
- package/dist/agentic-workflow/jsonTypes.d.ts +186 -0
- package/dist/agentic-workflow/nodes/AgentNode.d.ts +26 -0
- package/dist/agentic-workflow/nodes/BaseNode.d.ts +35 -0
- package/dist/agentic-workflow/nodes/EndMessageNode.d.ts +25 -0
- package/dist/agentic-workflow/nodes/StartNode.d.ts +21 -0
- package/dist/agentic-workflow/nodes/support/Prompt.d.ts +20 -0
- package/dist/agentic-workflow/types.d.ts +29 -0
- package/dist/cdn/{PUFTYLJ2.js → 33BF35AO.js} +1 -1
- package/dist/cdn/55M2HE4U.js +2 -0
- package/dist/cdn/5RZGG4F2.js +2 -0
- package/dist/cdn/5SF6DEMO.js +2 -0
- package/dist/cdn/{MW5S2XCB.js → 5SFZS2RD.js} +1 -1
- package/dist/cdn/6QJFOL6M.js +2 -0
- package/dist/cdn/BAB3MK4Y.js +2 -0
- package/dist/cdn/BMBV6Y2A.js +2 -0
- package/dist/cdn/D3RKQSWS.js +2 -0
- package/dist/cdn/DBHLKLKM.js +2 -0
- package/dist/cdn/{CXW5URTF.js → DWYODVWW.js} +1 -1
- package/dist/cdn/{TFT6HK3O.js → E7KEOJZG.js} +1 -1
- package/dist/cdn/FSMHR7GK.js +2 -0
- package/dist/cdn/HO2YDJI2.js +6 -0
- package/dist/cdn/{KQHLOYKL.js → I4L45WQS.js} +1 -1
- package/dist/cdn/IGQFAL3H.js +2 -0
- package/dist/cdn/JYVBCHR6.js +6 -0
- package/dist/cdn/{XETNZW4D.js → NJJYZP3R.js} +1 -1
- package/dist/cdn/NSXX2KYS.js +2 -0
- package/dist/cdn/OFRFP4BX.js +2 -0
- package/dist/cdn/OUFGJV3R.js +2 -0
- package/dist/cdn/PAUIFUMO.js +2 -0
- package/dist/cdn/RWM5T4XB.js +180 -0
- package/dist/cdn/{YHQJ66WJ.js → S3XUYAUX.js} +1 -1
- package/dist/cdn/S6ZAQRC6.js +2 -0
- package/dist/cdn/SRFLL6ET.js +2 -0
- package/dist/cdn/UZL6UVE4.js +2 -0
- package/dist/cdn/{GP6NDTUE.js → WDOM6Z5O.js} +2 -2
- package/dist/cdn/WQKNV6KK.js +2 -0
- package/dist/cdn/{ICYUPLZM.js → WZFC5HUX.js} +1 -1
- package/dist/cdn/XPTCV6YV.js +2 -0
- package/dist/cdn/Y5UFOH54.js +2 -0
- package/dist/cdn/{E5ZKBC24.js → Z4XUJQ2I.js} +2 -2
- package/dist/cdn/{SXHH575T.js → ZJEWP2ND.js} +20 -24
- package/dist/cdn/agent-utils/index.js +1 -1
- package/dist/cdn/agent-utils/middlewares/humanInTheLoop.js +1 -1
- package/dist/cdn/agent-utils/middlewares/middleware.js +1 -1
- package/dist/cdn/agent-utils/middlewares/trace.js +1 -1
- package/dist/cdn/index.js +1 -1
- package/dist/chunks/adapter.js +668 -679
- package/dist/chunks/baseAgentState.js +56 -0
- package/dist/chunks/dataExplorationGraph.js +13 -13
- package/dist/chunks/generateLayerDescriptions.js +189 -235
- package/dist/chunks/navigationGraph.js +28 -28
- package/dist/chunks/orchestrator.js +1 -1
- package/dist/chunks/state.js +20 -26
- package/dist/chunks/utils2.js +3 -3
- package/dist/components/arcgis-assistant-agent/customElement.d.ts +13 -1
- package/dist/components/arcgis-assistant-agent/customElement.js +513 -12
- package/dist/components/arcgis-assistant-data-exploration-agent/customElement.js +1 -1
- package/dist/components/arcgis-assistant-help-agent/customElement.js +1 -1
- package/dist/components/arcgis-assistant-knowledge-agent/customElement.js +1 -1
- package/dist/components/arcgis-assistant-layer-styling-agent/customElement.js +1 -1
- package/dist/components/arcgis-assistant-navigation-agent/customElement.js +1 -1
- 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/types/lumina.d.ts +1 -1
- package/dist/types/preact.d.ts +1 -1
- package/dist/types/react.d.ts +1 -1
- package/dist/types/stencil.d.ts +1 -1
- package/dist/utils/index.js +26 -25
- package/package.json +4 -4
- package/dist/cdn/3DJDRAGV.js +0 -2
- package/dist/cdn/4CEMUECT.js +0 -2
- package/dist/cdn/4PCAK3ET.js +0 -2
- package/dist/cdn/57OMVTIU.js +0 -2
- package/dist/cdn/6U7TEAAJ.js +0 -2
- package/dist/cdn/BE7ZN5FZ.js +0 -2
- package/dist/cdn/BNSJO6X2.js +0 -2
- package/dist/cdn/CMDRED5H.js +0 -2
- package/dist/cdn/DTIVDIDY.js +0 -2
- package/dist/cdn/HBLRVXEB.js +0 -2
- package/dist/cdn/HQXPPYMD.js +0 -2
- package/dist/cdn/IEHPNCTL.js +0 -2
- package/dist/cdn/LHLO6PTD.js +0 -2
- package/dist/cdn/OWXCOUIQ.js +0 -2
- package/dist/cdn/PVE7Q43N.js +0 -2
- package/dist/cdn/ST5FQYT7.js +0 -180
- package/dist/cdn/WUNCZOGU.js +0 -2
- package/dist/cdn/WVPU4QOO.js +0 -2
- package/dist/cdn/WXWO5D3W.js +0 -2
- package/dist/cdn/XCRR2EEG.js +0 -6
- package/dist/cdn/ZS6SXJP2.js +0 -2
|
@@ -1,23 +1,524 @@
|
|
|
1
1
|
/* COPYRIGHT Esri - https://js.arcgis.com/5.2/LICENSE.txt */
|
|
2
|
-
import { c as
|
|
3
|
-
import { LitElement as
|
|
4
|
-
import {
|
|
5
|
-
|
|
2
|
+
import { c as F } from "../../chunks/runtime.js";
|
|
3
|
+
import { LitElement as q } from "@arcgis/lumina";
|
|
4
|
+
import { b as G, i as L } from "../../chunks/utils2.js";
|
|
5
|
+
import C from "@arcgis/core/portal/PortalItem.js";
|
|
6
|
+
import T from "@arcgis/core/portal/Portal.js";
|
|
7
|
+
import { property as i, subclass as h } from "@arcgis/core/core/accessorSupport/decorators.js";
|
|
8
|
+
import { BaseAgent as j } from "../../agent-utils/BaseAgent.js";
|
|
9
|
+
import b from "@arcgis/core/core/Error.js";
|
|
10
|
+
import { z as c } from "zod";
|
|
11
|
+
import { c as z } from "../../chunks/graph.js";
|
|
12
|
+
import v from "@arcgis/core/core/Accessor.js";
|
|
13
|
+
import { LLMAgent as B } from "../../agent-utils/LLMAgent.js";
|
|
14
|
+
import { PromptTemplate as Z } from "@langchain/core/prompts";
|
|
15
|
+
import { Annotation as x } from "@langchain/langgraph";
|
|
16
|
+
import { b as U, d as H } from "../../chunks/state.js";
|
|
17
|
+
import "@arcgis/core/identity/IdentityManager.js";
|
|
18
|
+
import "@arcgis/core/request.js";
|
|
19
|
+
import "@langchain/langgraph/web";
|
|
20
|
+
import "@arcgis/toolkit/string";
|
|
21
|
+
import "../../chunks/generateLayerDescriptions.js";
|
|
22
|
+
import "@langchain/core/messages";
|
|
23
|
+
import "@langchain/core/callbacks/dispatch/web";
|
|
24
|
+
import "@langchain/openai";
|
|
25
|
+
import "@arcgis/core/config.js";
|
|
26
|
+
import "@arcgis/core/core/reactiveUtils.js";
|
|
27
|
+
import "@arcgis/core/layers/FeatureLayer.js";
|
|
28
|
+
import { a as K } from "../../chunks/baseAgentState.js";
|
|
29
|
+
var Q = Object.defineProperty, V = Object.getOwnPropertyDescriptor, f = (e, t, s, o) => {
|
|
30
|
+
for (var r = o > 1 ? void 0 : o ? V(t, s) : t, n = e.length - 1, a; n >= 0; n--)
|
|
31
|
+
(a = e[n]) && (r = (o ? a(t, s, r) : a(r)) || r);
|
|
32
|
+
return o && r && Q(t, s, r), r;
|
|
33
|
+
};
|
|
34
|
+
let p = class extends v {
|
|
35
|
+
//#region Lifecycle
|
|
36
|
+
constructor(e) {
|
|
37
|
+
super(e);
|
|
38
|
+
}
|
|
39
|
+
//#endregion
|
|
40
|
+
//#region Public Methods
|
|
41
|
+
static fromJSON(e) {
|
|
42
|
+
return new p({
|
|
43
|
+
id: e.id,
|
|
44
|
+
sourceAnchorId: e.source_anchor_id,
|
|
45
|
+
sourceNodeId: e.source_node_id,
|
|
46
|
+
targetAnchorId: e.target_anchor_id,
|
|
47
|
+
targetNodeId: e.target_node_id
|
|
48
|
+
});
|
|
49
|
+
}
|
|
50
|
+
//#endregion
|
|
51
|
+
};
|
|
52
|
+
f([
|
|
53
|
+
i()
|
|
54
|
+
], p.prototype, "id", 2);
|
|
55
|
+
f([
|
|
56
|
+
i()
|
|
57
|
+
], p.prototype, "sourceAnchorId", 2);
|
|
58
|
+
f([
|
|
59
|
+
i()
|
|
60
|
+
], p.prototype, "sourceNodeId", 2);
|
|
61
|
+
f([
|
|
62
|
+
i()
|
|
63
|
+
], p.prototype, "targetAnchorId", 2);
|
|
64
|
+
f([
|
|
65
|
+
i()
|
|
66
|
+
], p.prototype, "targetNodeId", 2);
|
|
67
|
+
p = f([
|
|
68
|
+
h("Edge")
|
|
69
|
+
], p);
|
|
70
|
+
var X = Object.defineProperty, Y = Object.getOwnPropertyDescriptor, y = (e, t, s, o) => {
|
|
71
|
+
for (var r = o > 1 ? void 0 : o ? Y(t, s) : t, n = e.length - 1, a; n >= 0; n--)
|
|
72
|
+
(a = e[n]) && (r = (o ? a(t, s, r) : a(r)) || r);
|
|
73
|
+
return o && r && X(t, s, r), r;
|
|
74
|
+
};
|
|
75
|
+
let d = class extends v {
|
|
76
|
+
//#region Lifecycle
|
|
77
|
+
constructor(e) {
|
|
78
|
+
super(e);
|
|
79
|
+
}
|
|
80
|
+
//#endregion
|
|
81
|
+
//#region Public Methods
|
|
82
|
+
async load() {
|
|
83
|
+
return await Promise.resolve(this);
|
|
84
|
+
}
|
|
85
|
+
compile(e) {
|
|
86
|
+
return {
|
|
87
|
+
runtimeNode: this.createRuntimeNode(),
|
|
88
|
+
edges: e.outgoingEdges.map((t) => ({
|
|
89
|
+
from: this.id,
|
|
90
|
+
to: t.targetNodeId
|
|
91
|
+
}))
|
|
92
|
+
};
|
|
93
|
+
}
|
|
94
|
+
static fromJSON(e) {
|
|
95
|
+
throw new Error("BaseNode is abstract and cannot be instantiated directly.");
|
|
96
|
+
}
|
|
97
|
+
//#endregion
|
|
98
|
+
//#region Private Methods
|
|
99
|
+
//#endregion
|
|
100
|
+
};
|
|
101
|
+
y([
|
|
102
|
+
i()
|
|
103
|
+
], d.prototype, "id", 2);
|
|
104
|
+
y([
|
|
105
|
+
i()
|
|
106
|
+
], d.prototype, "label", 2);
|
|
107
|
+
y([
|
|
108
|
+
i()
|
|
109
|
+
], d.prototype, "type", 2);
|
|
110
|
+
d = y([
|
|
111
|
+
h("BaseNode")
|
|
112
|
+
], d);
|
|
113
|
+
var k = Object.defineProperty, ee = Object.getOwnPropertyDescriptor, S = (e, t, s, o) => {
|
|
114
|
+
for (var r = o > 1 ? void 0 : o ? ee(t, s) : t, n = e.length - 1, a; n >= 0; n--)
|
|
115
|
+
(a = e[n]) && (r = (o ? a(t, s, r) : a(r)) || r);
|
|
116
|
+
return o && r && k(t, s, r), r;
|
|
117
|
+
};
|
|
118
|
+
let m = class extends v {
|
|
119
|
+
//#region Lifecycle
|
|
120
|
+
constructor(e) {
|
|
121
|
+
super(e), this.messages = [];
|
|
122
|
+
}
|
|
123
|
+
//#endregion
|
|
124
|
+
//#region Public Methods
|
|
125
|
+
static fromJSON(e) {
|
|
126
|
+
const t = m._normalizeMessages(e.messages);
|
|
127
|
+
return new m({ id: e.id, messages: t });
|
|
128
|
+
}
|
|
129
|
+
//#endregion
|
|
130
|
+
//#region Private Methods
|
|
131
|
+
static _normalizeMessages(e) {
|
|
132
|
+
return Array.isArray(e) ? e.filter(
|
|
133
|
+
(t) => typeof t.content == "string"
|
|
134
|
+
).map((t) => ({
|
|
135
|
+
content: t.content,
|
|
136
|
+
role: t.role ?? "system"
|
|
137
|
+
})) : [];
|
|
138
|
+
}
|
|
139
|
+
//#endregion
|
|
140
|
+
};
|
|
141
|
+
S([
|
|
142
|
+
i()
|
|
143
|
+
], m.prototype, "id", 2);
|
|
144
|
+
S([
|
|
145
|
+
i()
|
|
146
|
+
], m.prototype, "messages", 2);
|
|
147
|
+
m = S([
|
|
148
|
+
h("Prompt")
|
|
149
|
+
], m);
|
|
150
|
+
function I(e) {
|
|
151
|
+
const t = new Set(e.required), s = Object.fromEntries(
|
|
152
|
+
Object.entries(e.properties).map(([o, r]) => {
|
|
153
|
+
const n = J(r);
|
|
154
|
+
return [o, t.has(o) ? n : n.optional()];
|
|
155
|
+
})
|
|
156
|
+
);
|
|
157
|
+
return c.object(s);
|
|
158
|
+
}
|
|
159
|
+
function J(e) {
|
|
160
|
+
let t;
|
|
161
|
+
switch (e.type) {
|
|
162
|
+
case "array":
|
|
163
|
+
t = c.array(e.items ? J(e.items) : c.unknown());
|
|
164
|
+
break;
|
|
165
|
+
case "boolean":
|
|
166
|
+
t = c.boolean();
|
|
167
|
+
break;
|
|
168
|
+
case "number":
|
|
169
|
+
t = c.number();
|
|
170
|
+
break;
|
|
171
|
+
case "object":
|
|
172
|
+
t = I({
|
|
173
|
+
properties: e.properties ?? {},
|
|
174
|
+
required: e.required
|
|
175
|
+
});
|
|
176
|
+
break;
|
|
177
|
+
case "string":
|
|
178
|
+
t = e.enum?.length ? c.enum(e.enum) : c.string();
|
|
179
|
+
break;
|
|
180
|
+
}
|
|
181
|
+
return e.description ? t.describe(e.description) : t;
|
|
182
|
+
}
|
|
183
|
+
var te = Object.defineProperty, re = Object.getOwnPropertyDescriptor, $ = (e) => {
|
|
184
|
+
throw TypeError(e);
|
|
185
|
+
}, N = (e, t, s, o) => {
|
|
186
|
+
for (var r = o > 1 ? void 0 : o ? re(t, s) : t, n = e.length - 1, a; n >= 0; n--)
|
|
187
|
+
(a = e[n]) && (r = (o ? a(t, s, r) : a(r)) || r);
|
|
188
|
+
return o && r && te(t, s, r), r;
|
|
189
|
+
}, se = (e, t, s) => t.has(e) || $("Cannot " + s), oe = (e, t, s) => t.has(e) ? $("Cannot add the same private member more than once") : t instanceof WeakSet ? t.add(e) : t.set(e, s), ne = (e, t, s) => (se(e, t, "access private method"), s), O, D;
|
|
190
|
+
let u = class extends d {
|
|
191
|
+
//#region Lifecycle
|
|
192
|
+
constructor(e) {
|
|
193
|
+
super(e), oe(this, O), this.type = "agent-node";
|
|
194
|
+
}
|
|
195
|
+
//#endregion
|
|
196
|
+
//#region Public Methods
|
|
197
|
+
createRuntimeNode() {
|
|
198
|
+
return async (e, t) => {
|
|
199
|
+
const o = await ne(this, O, D).call(this).run(e, t), r = this.outputSchema?.safeParse(o);
|
|
200
|
+
if (r && !r.success)
|
|
201
|
+
throw r.error;
|
|
202
|
+
const n = r?.data, a = n ?? o.outputMessage;
|
|
203
|
+
return {
|
|
204
|
+
agentExecutionContext: o.agentExecutionContext,
|
|
205
|
+
...n ? {} : { outputMessage: o.outputMessage },
|
|
206
|
+
status: o.status,
|
|
207
|
+
summary: o.summary,
|
|
208
|
+
nodes: {
|
|
209
|
+
[this.id]: { output: a }
|
|
210
|
+
}
|
|
211
|
+
};
|
|
212
|
+
};
|
|
213
|
+
}
|
|
214
|
+
compile(e) {
|
|
215
|
+
const t = e.outgoingEdges[0]?.targetNodeId;
|
|
216
|
+
return {
|
|
217
|
+
runtimeNode: this.createRuntimeNode(),
|
|
218
|
+
edges: [
|
|
219
|
+
{
|
|
220
|
+
from: this.id,
|
|
221
|
+
decide: (s) => s.status === "failed" ? void 0 : t
|
|
222
|
+
}
|
|
223
|
+
],
|
|
224
|
+
schemas: [
|
|
225
|
+
c.object({
|
|
226
|
+
output: this.outputSchema ?? c.string()
|
|
227
|
+
})
|
|
228
|
+
]
|
|
229
|
+
};
|
|
230
|
+
}
|
|
231
|
+
static fromJSON(e) {
|
|
232
|
+
const t = new u({
|
|
233
|
+
id: e.id,
|
|
234
|
+
label: e.label,
|
|
235
|
+
type: "agent-node"
|
|
236
|
+
});
|
|
237
|
+
return e.prompt && (typeof e.prompt == "string" ? t.prompt = m.fromJSON({
|
|
238
|
+
id: `prompt_${e.id}`,
|
|
239
|
+
type: "plain_text",
|
|
240
|
+
messages: [{ content: e.prompt, role: "system" }]
|
|
241
|
+
}) : t.prompt = m.fromJSON(e.prompt)), e.structured_output && (t.outputSchema = I(e.structured_output)), t;
|
|
242
|
+
}
|
|
243
|
+
//#endregion
|
|
244
|
+
};
|
|
245
|
+
O = /* @__PURE__ */ new WeakSet();
|
|
246
|
+
D = function() {
|
|
247
|
+
const e = this.prompt?.messages?.[0].content;
|
|
248
|
+
if (!e?.trim())
|
|
249
|
+
throw new Error(`WebAgent agent node "${this.id}" requires a prompt.`);
|
|
250
|
+
return new B({
|
|
251
|
+
name: this.id,
|
|
252
|
+
// TODO: change to label
|
|
253
|
+
outputSchema: this.outputSchema,
|
|
254
|
+
prompt: e
|
|
255
|
+
});
|
|
256
|
+
};
|
|
257
|
+
N([
|
|
258
|
+
i()
|
|
259
|
+
], u.prototype, "type", 2);
|
|
260
|
+
N([
|
|
261
|
+
i()
|
|
262
|
+
], u.prototype, "prompt", 2);
|
|
263
|
+
N([
|
|
264
|
+
i()
|
|
265
|
+
], u.prototype, "outputSchema", 2);
|
|
266
|
+
u = N([
|
|
267
|
+
h("AgentNode")
|
|
268
|
+
], u);
|
|
269
|
+
var ae = Object.defineProperty, ie = Object.getOwnPropertyDescriptor, P = (e, t, s, o) => {
|
|
270
|
+
for (var r = o > 1 ? void 0 : o ? ie(t, s) : t, n = e.length - 1, a; n >= 0; n--)
|
|
271
|
+
(a = e[n]) && (r = (o ? a(t, s, r) : a(r)) || r);
|
|
272
|
+
return o && r && ae(t, s, r), r;
|
|
273
|
+
};
|
|
274
|
+
let l = class extends d {
|
|
275
|
+
//#region Lifecycle
|
|
276
|
+
constructor(e) {
|
|
277
|
+
super(e), this.type = "end-message-node";
|
|
278
|
+
}
|
|
279
|
+
//#endregion
|
|
280
|
+
//#region Public Methods
|
|
281
|
+
createRuntimeNode() {
|
|
282
|
+
return async (e) => {
|
|
283
|
+
const t = await Z.fromTemplate(this.message, { templateFormat: "mustache" }).format(e);
|
|
284
|
+
return {
|
|
285
|
+
outputMessage: t,
|
|
286
|
+
status: "success",
|
|
287
|
+
summary: t
|
|
288
|
+
};
|
|
289
|
+
};
|
|
290
|
+
}
|
|
291
|
+
compile(e) {
|
|
292
|
+
return {
|
|
293
|
+
runtimeNode: this.createRuntimeNode(),
|
|
294
|
+
edges: []
|
|
295
|
+
};
|
|
296
|
+
}
|
|
297
|
+
static fromJSON(e) {
|
|
298
|
+
const t = new l({
|
|
299
|
+
id: e.id,
|
|
300
|
+
label: e.label,
|
|
301
|
+
type: "end-message-node"
|
|
302
|
+
});
|
|
303
|
+
return t.message = e.message, t;
|
|
304
|
+
}
|
|
305
|
+
//#endregion
|
|
306
|
+
//#region Private Methods
|
|
307
|
+
//#endregion
|
|
308
|
+
};
|
|
309
|
+
P([
|
|
310
|
+
i()
|
|
311
|
+
], l.prototype, "type", 2);
|
|
312
|
+
P([
|
|
313
|
+
i()
|
|
314
|
+
], l.prototype, "message", 2);
|
|
315
|
+
l = P([
|
|
316
|
+
h("EndMessageNode")
|
|
317
|
+
], l);
|
|
318
|
+
var ce = Object.defineProperty, pe = Object.getOwnPropertyDescriptor, R = (e, t, s, o) => {
|
|
319
|
+
for (var r = o > 1 ? void 0 : o ? pe(t, s) : t, n = e.length - 1, a; n >= 0; n--)
|
|
320
|
+
(a = e[n]) && (r = (o ? a(t, s, r) : a(r)) || r);
|
|
321
|
+
return o && r && ce(t, s, r), r;
|
|
322
|
+
};
|
|
323
|
+
let _ = class extends d {
|
|
324
|
+
//#region Lifecycle
|
|
325
|
+
constructor(e) {
|
|
326
|
+
super(e), this.type = "start-node";
|
|
327
|
+
}
|
|
328
|
+
//#endregion
|
|
329
|
+
//#region Public Methods
|
|
330
|
+
createRuntimeNode() {
|
|
331
|
+
return (e) => ({ question: e.agentExecutionContext.userRequest });
|
|
332
|
+
}
|
|
333
|
+
static fromJSON(e) {
|
|
334
|
+
return new _({
|
|
335
|
+
id: e.id,
|
|
336
|
+
label: e.label,
|
|
337
|
+
type: "start-node"
|
|
338
|
+
});
|
|
339
|
+
}
|
|
340
|
+
//#endregion
|
|
341
|
+
//#region Private Methods
|
|
342
|
+
//#endregion
|
|
343
|
+
};
|
|
344
|
+
R([
|
|
345
|
+
i()
|
|
346
|
+
], _.prototype, "type", 2);
|
|
347
|
+
_ = R([
|
|
348
|
+
h("StartNode")
|
|
349
|
+
], _);
|
|
350
|
+
function de(e) {
|
|
351
|
+
switch (e.type) {
|
|
352
|
+
case "agent_node":
|
|
353
|
+
return u.fromJSON(e);
|
|
354
|
+
case "end_message_node":
|
|
355
|
+
return l.fromJSON(e);
|
|
356
|
+
case "start_node":
|
|
357
|
+
return _.fromJSON(e);
|
|
358
|
+
default:
|
|
359
|
+
throw new Error(`WebAgent node "${e.id}" uses unsupported type "${e.type}".`);
|
|
360
|
+
}
|
|
361
|
+
}
|
|
362
|
+
function me(e = {}) {
|
|
363
|
+
const t = Object.keys(e);
|
|
364
|
+
if (U(t), t.includes("nodes"))
|
|
365
|
+
throw new Error("node state cannot define reserved field: nodes.");
|
|
366
|
+
const s = H(e);
|
|
367
|
+
return x.Root({
|
|
368
|
+
...s,
|
|
369
|
+
nodes: x({
|
|
370
|
+
reducer: (o, r) => ({ ...o, ...r }),
|
|
371
|
+
default: () => ({})
|
|
372
|
+
}),
|
|
373
|
+
...K()
|
|
374
|
+
});
|
|
375
|
+
}
|
|
376
|
+
function M(e) {
|
|
377
|
+
const t = /* @__PURE__ */ new Set();
|
|
378
|
+
for (const o of e)
|
|
379
|
+
for (const r of Object.keys(o.shape ?? {}))
|
|
380
|
+
r !== "nodes" && t.add(r);
|
|
381
|
+
const s = Object.fromEntries([...t].map((o) => [o, void 0]));
|
|
382
|
+
return me(s);
|
|
383
|
+
}
|
|
384
|
+
class A {
|
|
385
|
+
//#endregion Private Properties
|
|
386
|
+
//#region Lifecycle
|
|
387
|
+
constructor(t, s, o) {
|
|
388
|
+
this.sourceJSON = t, this.edges = s, this.nodes = o, this._loaded = !1;
|
|
389
|
+
}
|
|
390
|
+
//#endregion Lifecycle
|
|
391
|
+
//#region Public Methods
|
|
392
|
+
static fromJSON(t) {
|
|
393
|
+
return new A(
|
|
394
|
+
t,
|
|
395
|
+
t.graph.edges.map((s) => p.fromJSON(s)),
|
|
396
|
+
t.graph.nodes.map((s) => de(s))
|
|
397
|
+
);
|
|
398
|
+
}
|
|
399
|
+
async load() {
|
|
400
|
+
return this._loadPromise ??= Promise.all(this.nodes.map(async (t) => await t.load())).then(() => {
|
|
401
|
+
this._loaded = !0;
|
|
402
|
+
}), await this._loadPromise, this;
|
|
403
|
+
}
|
|
404
|
+
getSchemas() {
|
|
405
|
+
const t = Object.fromEntries(
|
|
406
|
+
this._getNodeCompilations().flatMap((o, r) => {
|
|
407
|
+
const n = this.nodes[r];
|
|
408
|
+
return o.schemas?.map((a) => [n.id, a]) ?? [];
|
|
409
|
+
})
|
|
410
|
+
);
|
|
411
|
+
return [c.object({
|
|
412
|
+
loopCounts: c.record(c.string(), c.number()).optional(),
|
|
413
|
+
nodes: c.object(t).partial().optional(),
|
|
414
|
+
question: c.string().optional()
|
|
415
|
+
})];
|
|
416
|
+
}
|
|
417
|
+
generate() {
|
|
418
|
+
this._assertLoaded(), this._nodeCompilations = void 0;
|
|
419
|
+
const t = this._getNodeCompilations(), s = M(this.getSchemas()), o = this.nodes.find((a) => a.type === "start-node")?.id, r = {}, n = [];
|
|
420
|
+
for (const [a, W] of this.nodes.entries()) {
|
|
421
|
+
const w = t[a];
|
|
422
|
+
w && (w.runtimeNode && (r[W.id] = w.runtimeNode), n.push(...w.edges));
|
|
423
|
+
}
|
|
424
|
+
return {
|
|
425
|
+
createGraph: () => z(r, n, s, { entryNode: o }),
|
|
426
|
+
workspace: s
|
|
427
|
+
};
|
|
428
|
+
}
|
|
429
|
+
//#endregion Public Methods
|
|
430
|
+
//#region Private Methods
|
|
431
|
+
_assertLoaded() {
|
|
432
|
+
if (!this._loaded)
|
|
433
|
+
throw new Error("AgenticWorkflowRuntime must be loaded before it can generate a graph.");
|
|
434
|
+
}
|
|
435
|
+
_getNodeCompilations() {
|
|
436
|
+
return this._assertLoaded(), this._nodeCompilations ??= this.nodes.map(
|
|
437
|
+
(t) => t.compile({
|
|
438
|
+
outgoingEdges: this.edges.filter((s) => s.sourceNodeId === t.id)
|
|
439
|
+
})
|
|
440
|
+
);
|
|
441
|
+
}
|
|
442
|
+
//#endregion Private Methods
|
|
443
|
+
}
|
|
444
|
+
var ue = Object.defineProperty, he = Object.getOwnPropertyDescriptor, E = (e, t, s, o) => {
|
|
445
|
+
for (var r = o > 1 ? void 0 : o ? he(t, s) : t, n = e.length - 1, a; n >= 0; n--)
|
|
446
|
+
(a = e[n]) && (r = (o ? a(t, s, r) : a(r)) || r);
|
|
447
|
+
return o && r && ue(t, s, r), r;
|
|
448
|
+
};
|
|
449
|
+
const le = () => {
|
|
450
|
+
throw new Error("WebAgent must be loaded before it can run.");
|
|
451
|
+
};
|
|
452
|
+
let g = class extends j {
|
|
453
|
+
//#region Lifecycle
|
|
454
|
+
constructor(e) {
|
|
455
|
+
super(e);
|
|
456
|
+
}
|
|
457
|
+
//#endregion
|
|
458
|
+
//#region Public Methods
|
|
459
|
+
async load() {
|
|
460
|
+
if (this.portalItem) {
|
|
461
|
+
try {
|
|
462
|
+
await this.portalItem.load();
|
|
463
|
+
} catch (s) {
|
|
464
|
+
throw new b("web-agent:load-portal-item", "Failed to load portal item", { error: s });
|
|
465
|
+
}
|
|
466
|
+
const t = await this.portalItem.fetchData();
|
|
467
|
+
if (this.sourceJSON = t, !this.portalItem.title)
|
|
468
|
+
throw new b("web-agent:missing-title", "The portal item is missing a title");
|
|
469
|
+
}
|
|
470
|
+
if (!this.sourceJSON)
|
|
471
|
+
throw new b("web-agent:missing-source-json", "The source JSON is missing");
|
|
472
|
+
if (!this.sourceJSON.description)
|
|
473
|
+
throw new b("web-agent:missing-description", "The source JSON is missing a description");
|
|
474
|
+
const e = A.fromJSON(this.sourceJSON);
|
|
475
|
+
return await e.load(), this._runtime = e, this.description = this.sourceJSON.description, this.name = this.portalItem?.title ?? `web-agent-${Date.now()}`, this.generate(), this;
|
|
476
|
+
}
|
|
477
|
+
getSchemas() {
|
|
478
|
+
return this._runtime?.getSchemas() ?? [];
|
|
479
|
+
}
|
|
480
|
+
generate() {
|
|
481
|
+
if (!this._runtime) {
|
|
482
|
+
this._set("workspace", M([])), this._set("createGraph", le);
|
|
483
|
+
return;
|
|
484
|
+
}
|
|
485
|
+
const { createGraph: e, workspace: t } = this._runtime.generate();
|
|
486
|
+
this._set("workspace", t), this._set("createGraph", e);
|
|
487
|
+
}
|
|
488
|
+
//#endregion
|
|
489
|
+
};
|
|
490
|
+
E([
|
|
491
|
+
i({ type: C })
|
|
492
|
+
], g.prototype, "portalItem", 2);
|
|
493
|
+
E([
|
|
494
|
+
i()
|
|
495
|
+
], g.prototype, "sourceJSON", 2);
|
|
496
|
+
g = E([
|
|
497
|
+
h("WebAgent")
|
|
498
|
+
], g);
|
|
499
|
+
class ge extends q {
|
|
6
500
|
static {
|
|
7
|
-
this.properties = { agent: 0, context: 0 };
|
|
501
|
+
this.properties = { agent: 0, context: 0, itemId: 1, workflow: 0 };
|
|
8
502
|
}
|
|
9
|
-
#
|
|
503
|
+
#e;
|
|
10
504
|
async getContext() {
|
|
11
|
-
return
|
|
505
|
+
return G(this.context) ? await this.context() : this.context;
|
|
12
506
|
}
|
|
13
|
-
load() {
|
|
14
|
-
|
|
507
|
+
async load() {
|
|
508
|
+
let t;
|
|
509
|
+
if (this.itemId) {
|
|
510
|
+
const s = T.getDefault();
|
|
511
|
+
t = new g({ portalItem: new C({ id: this.itemId, portal: s }) });
|
|
512
|
+
} else this.workflow && (t = new g({ sourceJSON: this.workflow }));
|
|
513
|
+
if (t && (await t.load(), this.agent = t.registration), !this.agent)
|
|
514
|
+
throw new Error("Failed to initialize the assistant agent because the agent registration is missing.");
|
|
515
|
+
this.#e = L(this);
|
|
15
516
|
}
|
|
16
517
|
disconnectedCallback() {
|
|
17
|
-
this.#
|
|
518
|
+
this.#e?.unregister(this.agent.id), super.disconnectedCallback();
|
|
18
519
|
}
|
|
19
520
|
}
|
|
20
|
-
|
|
521
|
+
F("arcgis-assistant-agent", ge);
|
|
21
522
|
export {
|
|
22
|
-
|
|
523
|
+
ge as ArcgisAssistantAgent
|
|
23
524
|
};
|
|
@@ -20,7 +20,7 @@ import "zod";
|
|
|
20
20
|
import { D as r } from "../../chunks/dataExplorationGraph.js";
|
|
21
21
|
import "@arcgis/core/views/LinkChartView.js";
|
|
22
22
|
import "@arcgis/core/rest/knowledgeGraphService.js";
|
|
23
|
-
import { r as a,
|
|
23
|
+
import { r as a, i as s } from "../../chunks/utils2.js";
|
|
24
24
|
class e extends i {
|
|
25
25
|
constructor() {
|
|
26
26
|
super(...arguments), this.agent = r;
|
|
@@ -23,7 +23,7 @@ import "@arcgis/core/smartMapping/statistics/uniqueValues.js";
|
|
|
23
23
|
import { H as r } from "../../chunks/helpGraph.js";
|
|
24
24
|
import "@arcgis/core/views/LinkChartView.js";
|
|
25
25
|
import "@arcgis/core/rest/knowledgeGraphService.js";
|
|
26
|
-
import { r as s,
|
|
26
|
+
import { r as s, i as e } from "../../chunks/utils2.js";
|
|
27
27
|
class o extends i {
|
|
28
28
|
constructor() {
|
|
29
29
|
super(...arguments), this.agent = r;
|
|
@@ -21,7 +21,7 @@ import "@arcgis/core/intl.js";
|
|
|
21
21
|
import "@arcgis/core/smartMapping/statistics/summaryStatistics.js";
|
|
22
22
|
import "@arcgis/core/smartMapping/statistics/uniqueValues.js";
|
|
23
23
|
import { A as s } from "../../chunks/arcgisKnowledgeGraph.js";
|
|
24
|
-
import {
|
|
24
|
+
import { a as o, i as n } from "../../chunks/utils2.js";
|
|
25
25
|
import { fetchKnowledgeGraph as a } from "@arcgis/core/rest/knowledgeGraphService.js";
|
|
26
26
|
class c extends r {
|
|
27
27
|
constructor() {
|
|
@@ -23,7 +23,7 @@ import "@arcgis/core/smartMapping/statistics/uniqueValues.js";
|
|
|
23
23
|
import { L as r } from "../../chunks/layerStylingGraph.js";
|
|
24
24
|
import "@arcgis/core/views/LinkChartView.js";
|
|
25
25
|
import "@arcgis/core/rest/knowledgeGraphService.js";
|
|
26
|
-
import { r as s,
|
|
26
|
+
import { r as s, i as e } from "../../chunks/utils2.js";
|
|
27
27
|
class a extends i {
|
|
28
28
|
constructor() {
|
|
29
29
|
super(...arguments), this.agent = r;
|
|
@@ -22,7 +22,7 @@ import "@arcgis/core/smartMapping/statistics/summaryStatistics.js";
|
|
|
22
22
|
import "@arcgis/core/smartMapping/statistics/uniqueValues.js";
|
|
23
23
|
import "@arcgis/core/views/LinkChartView.js";
|
|
24
24
|
import "@arcgis/core/rest/knowledgeGraphService.js";
|
|
25
|
-
import { r as s, a } from "../../chunks/utils2.js";
|
|
25
|
+
import { r as s, i as a } from "../../chunks/utils2.js";
|
|
26
26
|
class e extends i {
|
|
27
27
|
constructor() {
|
|
28
28
|
super(...arguments), this.agent = r;
|