@arcgis/portal-components 5.2.0-next.54 → 5.2.0-next.56
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/{BZRUGC5P.js → 2WEWH5G3.js} +1 -1
- package/dist/cdn/{POIXW2OA.js → 5DE3XVTY.js} +1 -1
- package/dist/cdn/{75N65DHR.js → C2DREZD4.js} +1 -1
- package/dist/cdn/{F3G5N2UU.js → C4UBEDKI.js} +1 -1
- package/dist/cdn/{DZJMNZY6.js → IZOGASBD.js} +1 -1
- package/dist/cdn/TUQSWB7B.js +619 -0
- package/dist/cdn/index.js +1 -1
- package/dist/chunks/utils.js +13 -9
- package/dist/components/arcgis-portal-ai-assistant/customElement.js +483 -452
- 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 +4 -5
- package/dist/cdn/KH6T7CDO.js +0 -645
|
@@ -1,31 +1,29 @@
|
|
|
1
1
|
/* COPYRIGHT Esri - https://js.arcgis.com/5.2/LICENSE.txt */
|
|
2
|
-
import { c as
|
|
3
|
-
import { LitElement as
|
|
4
|
-
import { css as
|
|
5
|
-
import { createRef as
|
|
6
|
-
import { u as
|
|
7
|
-
import { a as
|
|
8
|
-
import { NodeInterrupt as
|
|
9
|
-
import { sendTraceMessage as g, invokeStructuredPrompt as
|
|
10
|
-
import
|
|
11
|
-
import { a as
|
|
12
|
-
import
|
|
13
|
-
import
|
|
14
|
-
import { ChatPromptTemplate as
|
|
15
|
-
import {
|
|
16
|
-
import {
|
|
17
|
-
import {
|
|
18
|
-
|
|
19
|
-
|
|
20
|
-
|
|
21
|
-
const { portal: t, user: e } = s ?? {};
|
|
22
|
-
return !!s && !!t && !!e;
|
|
2
|
+
import { c as pt } from "../../chunks/runtime.js";
|
|
3
|
+
import { LitElement as dt, createEvent as mt } from "@arcgis/lumina";
|
|
4
|
+
import { css as gt, render as ht, html as M } from "lit";
|
|
5
|
+
import { createRef as T, ref as A } from "lit/directives/ref.js";
|
|
6
|
+
import { u as ft } from "../../chunks/useT9n.js";
|
|
7
|
+
import { a as C, t as yt, b as wt } from "../../chunks/functionalities.js";
|
|
8
|
+
import { NodeInterrupt as W, Annotation as y, StateGraph as N, START as P, END as w } from "@langchain/langgraph/web";
|
|
9
|
+
import { sendTraceMessage as g, invokeStructuredPrompt as v, sendUXSuggestion as E, createAgentRuntimeStateWithSharedState as k, createChatModel as D } from "@arcgis/ai-components/utils/index.js";
|
|
10
|
+
import n from "zod";
|
|
11
|
+
import { a as bt, c as vt, q as It } from "../../chunks/groups2.js";
|
|
12
|
+
import xt from "@arcgis/core/identity/IdentityManager.js";
|
|
13
|
+
import F from "@arcgis/core/request.js";
|
|
14
|
+
import { ChatPromptTemplate as U } from "@langchain/core/prompts";
|
|
15
|
+
import { tool as Y } from "@langchain/core/tools";
|
|
16
|
+
import { s as St, a as Mt } from "../../chunks/item.js";
|
|
17
|
+
import { c as Gt, d as Tt, i as At, b as Ct, g as Nt } from "../../chunks/groups.js";
|
|
18
|
+
const H = (a) => {
|
|
19
|
+
const { portal: t, user: e } = a ?? {};
|
|
20
|
+
return !!a && !!t && !!e;
|
|
23
21
|
};
|
|
24
|
-
function
|
|
25
|
-
if (!
|
|
22
|
+
function I(a) {
|
|
23
|
+
if (!H(a))
|
|
26
24
|
throw new Error("Invalid context: PortalAssistantContext with portal and user is required.");
|
|
27
25
|
}
|
|
28
|
-
const
|
|
26
|
+
const Pt = `
|
|
29
27
|
Write a concise, friendly success message for adding members to a group.
|
|
30
28
|
|
|
31
29
|
Rules:
|
|
@@ -40,83 +38,83 @@ Added members:
|
|
|
40
38
|
|
|
41
39
|
Not added members:
|
|
42
40
|
{notAddedMembers}
|
|
43
|
-
`,
|
|
44
|
-
successMessage:
|
|
45
|
-
}), V = "portal-group-creation", j = "approveAddMembers",
|
|
46
|
-
if (
|
|
41
|
+
`, kt = (a) => a.map((t) => `"${t}"`).join(", "), qt = n.object({
|
|
42
|
+
successMessage: n.string().default("")
|
|
43
|
+
}), V = "portal-group-creation", j = "approveAddMembers", zt = async (a, t) => {
|
|
44
|
+
if (a.intentParams.intent !== "addMembers")
|
|
47
45
|
return {
|
|
48
46
|
status: "success",
|
|
49
47
|
outputMessage: "Use @mention usernames for the members you want to add."
|
|
50
48
|
};
|
|
51
|
-
const e =
|
|
49
|
+
const e = a.agentExecutionContext.sharedState.createdGroupId?.value;
|
|
52
50
|
if (!e)
|
|
53
51
|
return {
|
|
54
52
|
status: "success",
|
|
55
53
|
outputMessage: "Create a group first, then add members using @mention usernames."
|
|
56
54
|
};
|
|
57
|
-
const
|
|
58
|
-
if (!
|
|
55
|
+
const s = a.intentParams.memberInfo.memberIdentifiers.map((d) => d.trim()).filter(Boolean);
|
|
56
|
+
if (!s.length)
|
|
59
57
|
return {
|
|
60
58
|
status: "success",
|
|
61
59
|
outputMessage: "Use @mention usernames for the members you want to add."
|
|
62
60
|
};
|
|
63
|
-
const
|
|
61
|
+
const l = `The following member(s) will be added to the newly created group:
|
|
64
62
|
|
|
65
|
-
${
|
|
63
|
+
${s.map((d) => `- **@${d}**`).join(`
|
|
66
64
|
`)}
|
|
67
65
|
|
|
68
|
-
Do you want to continue?`, { hitlResponse:
|
|
69
|
-
if (
|
|
66
|
+
Do you want to continue?`, { hitlResponse: c } = t?.configurable ?? {};
|
|
67
|
+
if (c?.agentId !== V || c.id !== j) {
|
|
70
68
|
const d = {
|
|
71
69
|
agentId: V,
|
|
72
70
|
id: j,
|
|
73
71
|
kind: "booleanChoice",
|
|
74
|
-
message:
|
|
72
|
+
message: l,
|
|
75
73
|
metadata: {
|
|
76
74
|
action: "addMembers",
|
|
77
75
|
groupId: e,
|
|
78
|
-
members: [...
|
|
76
|
+
members: [...s]
|
|
79
77
|
}
|
|
80
78
|
};
|
|
81
|
-
throw new
|
|
79
|
+
throw new W(d);
|
|
82
80
|
}
|
|
83
|
-
if (
|
|
81
|
+
if (c.payload !== !0)
|
|
84
82
|
return {
|
|
85
83
|
status: "success",
|
|
86
84
|
outputMessage: "Okay, I cancelled adding members to the group."
|
|
87
85
|
};
|
|
88
86
|
await g(
|
|
89
|
-
{ text: `Adding members ${
|
|
87
|
+
{ text: `Adding members ${kt(s)}...`, agentName: "group-creation" },
|
|
90
88
|
t
|
|
91
89
|
);
|
|
92
|
-
const
|
|
93
|
-
|
|
94
|
-
const { result:
|
|
95
|
-
if (
|
|
90
|
+
const i = t?.configurable?.context;
|
|
91
|
+
I(i);
|
|
92
|
+
const { result: u, error: r } = await bt(i.portal, e, s);
|
|
93
|
+
if (r || !u)
|
|
96
94
|
return {
|
|
97
95
|
status: "success",
|
|
98
96
|
outputMessage: "I could not add members to that group. Please confirm group access and user accounts, then try again."
|
|
99
97
|
};
|
|
100
|
-
const { addedUsernames: p, notAddedUsers: m } =
|
|
98
|
+
const { addedUsernames: p, notAddedUsers: m } = u;
|
|
101
99
|
try {
|
|
102
|
-
const
|
|
103
|
-
promptText:
|
|
104
|
-
schema:
|
|
100
|
+
const h = (await v({
|
|
101
|
+
promptText: Pt,
|
|
102
|
+
schema: qt,
|
|
105
103
|
modelTier: "fast",
|
|
106
104
|
inputVariables: {
|
|
107
105
|
addedMembers: p.join(", "),
|
|
108
106
|
notAddedMembers: JSON.stringify(
|
|
109
|
-
m.map((
|
|
107
|
+
m.map((f) => ({ username: f.username, reason: f.error.message }))
|
|
110
108
|
)
|
|
111
109
|
}
|
|
112
110
|
})).successMessage;
|
|
113
|
-
if (
|
|
114
|
-
return { status: "success", outputMessage:
|
|
111
|
+
if (h)
|
|
112
|
+
return { status: "success", outputMessage: h };
|
|
115
113
|
} catch (d) {
|
|
116
114
|
console.error("Error generating add-members success message:", d);
|
|
117
115
|
}
|
|
118
116
|
return {};
|
|
119
|
-
},
|
|
117
|
+
}, $t = `
|
|
120
118
|
Write a concise, friendly success message after creating a portal group.
|
|
121
119
|
|
|
122
120
|
Rules:
|
|
@@ -127,7 +125,7 @@ Rules:
|
|
|
127
125
|
|
|
128
126
|
Group title:
|
|
129
127
|
{groupTitle}
|
|
130
|
-
`,
|
|
128
|
+
`, Et = `
|
|
131
129
|
Write a concise, friendly failure message after an attempt to create a portal group.
|
|
132
130
|
|
|
133
131
|
Rules:
|
|
@@ -142,36 +140,36 @@ Group title:
|
|
|
142
140
|
|
|
143
141
|
Failure reason:
|
|
144
142
|
{failureReason}
|
|
145
|
-
`,
|
|
146
|
-
successMessage:
|
|
147
|
-
}),
|
|
148
|
-
failureMessage:
|
|
149
|
-
}),
|
|
150
|
-
if (
|
|
143
|
+
`, _ = "portal-group-creation", L = "approveCreateGroup", Dt = n.object({
|
|
144
|
+
successMessage: n.string().default("")
|
|
145
|
+
}), Ut = n.object({
|
|
146
|
+
failureMessage: n.string().default("")
|
|
147
|
+
}), Rt = async (a, t) => {
|
|
148
|
+
if (a.intentParams.intent !== "create")
|
|
151
149
|
return {
|
|
152
150
|
status: "success",
|
|
153
151
|
outputMessage: "Tell me the group title you want to use."
|
|
154
152
|
};
|
|
155
|
-
const e =
|
|
153
|
+
const e = a.intentParams.title.trim();
|
|
156
154
|
if (!e)
|
|
157
155
|
return {
|
|
158
156
|
status: "success",
|
|
159
157
|
outputMessage: "What title would you like for the new group?"
|
|
160
158
|
};
|
|
161
|
-
const
|
|
162
|
-
if (o?.agentId !==
|
|
163
|
-
const
|
|
164
|
-
agentId:
|
|
165
|
-
id:
|
|
159
|
+
const s = `A group with the title **${e}** will be created. Do you want to continue?`, { hitlResponse: o } = t?.configurable;
|
|
160
|
+
if (o?.agentId !== _ || o.id !== L) {
|
|
161
|
+
const r = {
|
|
162
|
+
agentId: _,
|
|
163
|
+
id: L,
|
|
166
164
|
kind: "booleanChoice",
|
|
167
|
-
message:
|
|
165
|
+
message: s,
|
|
168
166
|
metadata: {
|
|
169
167
|
action: "createGroup",
|
|
170
168
|
title: e,
|
|
171
169
|
access: "private"
|
|
172
170
|
}
|
|
173
171
|
};
|
|
174
|
-
throw new
|
|
172
|
+
throw new W(r);
|
|
175
173
|
}
|
|
176
174
|
if (o.payload !== !0)
|
|
177
175
|
return {
|
|
@@ -179,22 +177,22 @@ Failure reason:
|
|
|
179
177
|
outputMessage: `Okay, I cancelled creating **${e}**.`
|
|
180
178
|
};
|
|
181
179
|
await g({ text: `Creating group "${e}"...`, agentName: "group-creation" }, t);
|
|
182
|
-
const
|
|
183
|
-
|
|
184
|
-
const { result:
|
|
180
|
+
const l = t?.configurable?.context;
|
|
181
|
+
I(l);
|
|
182
|
+
const { result: c, error: i } = await vt(l.portal, {
|
|
185
183
|
title: e,
|
|
186
184
|
access: "private"
|
|
187
185
|
});
|
|
188
|
-
if (
|
|
189
|
-
const
|
|
186
|
+
if (i || !c) {
|
|
187
|
+
const r = i?.message?.trim() || "No additional details were provided.";
|
|
190
188
|
try {
|
|
191
|
-
const m = (await
|
|
192
|
-
promptText:
|
|
193
|
-
schema:
|
|
189
|
+
const m = (await v({
|
|
190
|
+
promptText: Et,
|
|
191
|
+
schema: Ut,
|
|
194
192
|
modelTier: "fast",
|
|
195
193
|
inputVariables: {
|
|
196
194
|
groupTitle: e,
|
|
197
|
-
failureReason:
|
|
195
|
+
failureReason: r
|
|
198
196
|
}
|
|
199
197
|
})).failureMessage.trim();
|
|
200
198
|
if (m)
|
|
@@ -210,11 +208,11 @@ Failure reason:
|
|
|
210
208
|
outputMessage: "I could not create that group. Please confirm your permissions and try again with the group title."
|
|
211
209
|
};
|
|
212
210
|
}
|
|
213
|
-
const
|
|
211
|
+
const u = c.id;
|
|
214
212
|
try {
|
|
215
|
-
const p = (await
|
|
216
|
-
promptText:
|
|
217
|
-
schema:
|
|
213
|
+
const p = (await v({
|
|
214
|
+
promptText: $t,
|
|
215
|
+
schema: Dt,
|
|
218
216
|
modelTier: "fast",
|
|
219
217
|
inputVariables: {
|
|
220
218
|
groupTitle: e
|
|
@@ -224,28 +222,28 @@ Failure reason:
|
|
|
224
222
|
return {
|
|
225
223
|
status: "success",
|
|
226
224
|
outputMessage: p,
|
|
227
|
-
sharedStatePatch: { createdGroupId: { value:
|
|
228
|
-
createdGroupId:
|
|
225
|
+
sharedStatePatch: { createdGroupId: { value: u } },
|
|
226
|
+
createdGroupId: u
|
|
229
227
|
};
|
|
230
|
-
} catch (
|
|
231
|
-
console.error("Error generating create-group success message:",
|
|
228
|
+
} catch (r) {
|
|
229
|
+
console.error("Error generating create-group success message:", r);
|
|
232
230
|
}
|
|
233
231
|
return {};
|
|
234
|
-
},
|
|
235
|
-
for (let t =
|
|
236
|
-
const e =
|
|
232
|
+
}, x = (a) => {
|
|
233
|
+
for (let t = a.length - 1; t >= 0; t -= 1) {
|
|
234
|
+
const e = a[t];
|
|
237
235
|
if (e.type !== "human")
|
|
238
236
|
continue;
|
|
239
|
-
const
|
|
240
|
-
if (typeof
|
|
241
|
-
return
|
|
242
|
-
if (Array.isArray(
|
|
243
|
-
return
|
|
237
|
+
const s = e.content;
|
|
238
|
+
if (typeof s == "string")
|
|
239
|
+
return s;
|
|
240
|
+
if (Array.isArray(s))
|
|
241
|
+
return s.map(
|
|
244
242
|
(o) => typeof o == "string" ? o : "text" in o && typeof o.text == "string" ? o.text : ""
|
|
245
243
|
).join(" ").trim();
|
|
246
244
|
}
|
|
247
245
|
return "";
|
|
248
|
-
},
|
|
246
|
+
}, Ot = `
|
|
249
247
|
You classify whether a user is asking to create a new ArcGIS Portal group or add members to an existing group.
|
|
250
248
|
|
|
251
249
|
Rules:
|
|
@@ -271,25 +269,25 @@ Examples:
|
|
|
271
269
|
|
|
272
270
|
User message:
|
|
273
271
|
{userMessage}
|
|
274
|
-
`, Ft =
|
|
275
|
-
intent:
|
|
276
|
-
title:
|
|
277
|
-
memberIdentifiers:
|
|
278
|
-
clarifyMessage:
|
|
279
|
-
}),
|
|
272
|
+
`, Ft = n.object({
|
|
273
|
+
intent: n.enum(["clarify", "create", "addMembers"]).default("clarify"),
|
|
274
|
+
title: n.string().default(""),
|
|
275
|
+
memberIdentifiers: n.array(n.string()).default([]),
|
|
276
|
+
clarifyMessage: n.string().default("")
|
|
277
|
+
}), Vt = async (a, t) => {
|
|
280
278
|
await g({ text: "Thinking about groups...", agentName: "group-creation" }, t);
|
|
281
|
-
const e =
|
|
282
|
-
promptText:
|
|
279
|
+
const e = x(a.agentExecutionContext.messages).trim(), s = await v({
|
|
280
|
+
promptText: Ot,
|
|
283
281
|
schema: Ft,
|
|
284
282
|
modelTier: "default",
|
|
285
283
|
inputVariables: { userMessage: e }
|
|
286
|
-
}), o =
|
|
284
|
+
}), o = s.title.trim(), l = s.memberIdentifiers.filter(Boolean), c = s.clarifyMessage.trim(), i = s.intent === "create" && !!o, u = s.intent === "addMembers" && l.length > 0;
|
|
287
285
|
return {
|
|
288
|
-
intentParams:
|
|
286
|
+
intentParams: i ? { intent: "create", title: o } : u ? { intent: "addMembers", memberInfo: { memberIdentifiers: l } } : { intent: "clarify" },
|
|
289
287
|
status: "success",
|
|
290
|
-
outputMessage: !
|
|
288
|
+
outputMessage: !i && !u ? c : ""
|
|
291
289
|
};
|
|
292
|
-
},
|
|
290
|
+
}, jt = n.enum([
|
|
293
291
|
"portal-content",
|
|
294
292
|
"portal-content-favorites",
|
|
295
293
|
"portal-content-group",
|
|
@@ -304,44 +302,44 @@ User message:
|
|
|
304
302
|
"portal-notebooks",
|
|
305
303
|
"portal-scene-viewer",
|
|
306
304
|
"portal-settings-security"
|
|
307
|
-
]),
|
|
308
|
-
destinationType:
|
|
309
|
-
}), Lt =
|
|
310
|
-
|
|
311
|
-
|
|
312
|
-
destinationType:
|
|
313
|
-
itemId:
|
|
305
|
+
]), _t = n.object({
|
|
306
|
+
destinationType: jt
|
|
307
|
+
}), Lt = n.union([
|
|
308
|
+
_t,
|
|
309
|
+
n.object({
|
|
310
|
+
destinationType: n.literal("portal-item"),
|
|
311
|
+
itemId: n.string().trim().min(1)
|
|
314
312
|
}),
|
|
315
|
-
|
|
316
|
-
destinationType:
|
|
317
|
-
groupId:
|
|
313
|
+
n.object({
|
|
314
|
+
destinationType: n.literal("portal-group"),
|
|
315
|
+
groupId: n.string().trim().min(1)
|
|
318
316
|
})
|
|
319
|
-
]),
|
|
317
|
+
]), X = "portal-navigation", R = async (a, t) => {
|
|
320
318
|
const e = t?.configurable?.context;
|
|
321
|
-
!
|
|
322
|
-
}, Bt = async (
|
|
323
|
-
const e =
|
|
319
|
+
!H(e) || !e.navigationTargetMap?.[a.destinationType] || await E({ type: X, data: { ...a } }, t);
|
|
320
|
+
}, Bt = async (a, t) => {
|
|
321
|
+
const e = a.createdGroupId ?? a.agentExecutionContext.sharedState.createdGroupId?.value;
|
|
324
322
|
return e ? (await g({ text: "Preparing navigation...", agentName: "group-creation" }, t), await R({ destinationType: "portal-group", groupId: e }, t), {}) : {};
|
|
325
|
-
},
|
|
326
|
-
...
|
|
323
|
+
}, B = (a, t) => t ?? a, Z = y.Root({
|
|
324
|
+
...k(),
|
|
327
325
|
// * Shared state between nodes (but not persisted to the agent execution context)
|
|
328
326
|
/** Parameters related to the user's intent for group creation actions */
|
|
329
|
-
intentParams:
|
|
327
|
+
intentParams: y({ reducer: B, default: () => ({ intent: "clarify" }) }),
|
|
330
328
|
/** The ID of the group that was created
|
|
331
329
|
* even though we already have this in the shared state
|
|
332
330
|
* we still need it here to also share between nodes
|
|
333
331
|
*/
|
|
334
|
-
createdGroupId:
|
|
335
|
-
}), Qt = () => new
|
|
332
|
+
createdGroupId: y({ reducer: B, default: () => "" })
|
|
333
|
+
}), Qt = () => new N(Z).addNode("detectGroupCreationIntent", Vt).addNode("createPortalGroup", Rt).addNode("addMembersToPortalGroup", zt).addNode("suggestCreatedGroupNavigation", Bt).addEdge(P, "detectGroupCreationIntent").addConditionalEdges("detectGroupCreationIntent", (t) => {
|
|
336
334
|
switch (t.intentParams.intent) {
|
|
337
335
|
case "create":
|
|
338
336
|
return "createPortalGroup";
|
|
339
337
|
case "addMembers":
|
|
340
338
|
return "addMembersToPortalGroup";
|
|
341
339
|
default:
|
|
342
|
-
return
|
|
340
|
+
return w;
|
|
343
341
|
}
|
|
344
|
-
}).addEdge("createPortalGroup", "suggestCreatedGroupNavigation").addEdge("addMembersToPortalGroup", "suggestCreatedGroupNavigation").addEdge("suggestCreatedGroupNavigation",
|
|
342
|
+
}).addEdge("createPortalGroup", "suggestCreatedGroupNavigation").addEdge("addMembersToPortalGroup", "suggestCreatedGroupNavigation").addEdge("suggestCreatedGroupNavigation", w), Kt = String.raw`- **portal-group-creation** - Portal group creation assistant:
|
|
345
343
|
- creates a new ArcGIS Portal group for the signed-in user
|
|
346
344
|
- adds users to the newly created group using @mention usernames
|
|
347
345
|
`, Jt = {
|
|
@@ -349,134 +347,157 @@ User message:
|
|
|
349
347
|
name: "Portal Group Creation",
|
|
350
348
|
description: Kt,
|
|
351
349
|
createGraph: Qt,
|
|
352
|
-
workspace:
|
|
353
|
-
},
|
|
354
|
-
const t =
|
|
350
|
+
workspace: Z
|
|
351
|
+
}, tt = "portalDocAssistantMemory", Wt = () => ({ conversationId: "" }), Yt = (a) => {
|
|
352
|
+
const t = a?.[tt]?.value;
|
|
355
353
|
if (!t || typeof t != "object")
|
|
356
354
|
return Wt();
|
|
357
355
|
const e = t;
|
|
358
356
|
return {
|
|
359
357
|
conversationId: typeof e.conversationId == "string" ? e.conversationId : ""
|
|
360
358
|
};
|
|
361
|
-
},
|
|
362
|
-
[
|
|
363
|
-
})
|
|
364
|
-
|
|
365
|
-
|
|
359
|
+
}, Ht = (a) => ({
|
|
360
|
+
[tt]: { value: a }
|
|
361
|
+
}), Xt = {
|
|
362
|
+
rag: {
|
|
363
|
+
top_k: 20,
|
|
364
|
+
certainty_threshold: 0.7,
|
|
365
|
+
radius_of_surrounding_chunks: 2,
|
|
366
|
+
top_k_surrounding_chunks: 120,
|
|
367
|
+
extract_key_terms: !0
|
|
368
|
+
},
|
|
369
|
+
pipeline: {
|
|
370
|
+
conversation_history: {
|
|
371
|
+
allow: !0,
|
|
372
|
+
number_of_interactions_to_include: 4
|
|
373
|
+
},
|
|
374
|
+
conversation_title: { allow: !1 },
|
|
375
|
+
follow_up: { allow: !1 },
|
|
376
|
+
retrieved_chunks_in_response: { allow: !1 }
|
|
377
|
+
}
|
|
378
|
+
};
|
|
379
|
+
function Zt(a) {
|
|
380
|
+
return {
|
|
381
|
+
kind: "DocAIAssistantRequest",
|
|
382
|
+
filters: {
|
|
383
|
+
...Xt,
|
|
384
|
+
persona: { persona: a }
|
|
385
|
+
}
|
|
386
|
+
};
|
|
387
|
+
}
|
|
388
|
+
async function te({
|
|
389
|
+
portal: a,
|
|
366
390
|
question: t,
|
|
367
391
|
persona: e,
|
|
368
|
-
previousConversationId:
|
|
392
|
+
previousConversationId: s,
|
|
369
393
|
signal: o,
|
|
370
|
-
skillId:
|
|
394
|
+
skillId: l
|
|
371
395
|
}) {
|
|
372
|
-
|
|
373
|
-
const
|
|
374
|
-
portal:
|
|
375
|
-
skillId:
|
|
396
|
+
l ??= "doc_ai_assistant";
|
|
397
|
+
const c = Zt(e), i = await ee({
|
|
398
|
+
portal: a,
|
|
399
|
+
skillId: l,
|
|
376
400
|
message: t,
|
|
377
|
-
options: { context:
|
|
378
|
-
kind: "DocAIAssistantRequest",
|
|
379
|
-
filters: { persona: { persona: e } }
|
|
380
|
-
}, previousConversationId: a, signal: o }
|
|
401
|
+
options: { context: c, previousConversationId: s, signal: o }
|
|
381
402
|
});
|
|
382
403
|
return {
|
|
383
|
-
reply:
|
|
384
|
-
conversationId:
|
|
404
|
+
reply: ae(i, l),
|
|
405
|
+
conversationId: i[0]?.conversationId ?? ""
|
|
385
406
|
};
|
|
386
407
|
}
|
|
387
|
-
async function
|
|
388
|
-
portal:
|
|
408
|
+
async function ee({
|
|
409
|
+
portal: a,
|
|
389
410
|
skillId: t,
|
|
390
411
|
message: e,
|
|
391
|
-
options:
|
|
412
|
+
options: s
|
|
392
413
|
}) {
|
|
393
|
-
const
|
|
414
|
+
const l = `${a.helperServices.aiAssistantServices.url}/skills/${t}/chat`, c = {
|
|
394
415
|
"Content-Type": "application/json",
|
|
395
|
-
token:
|
|
396
|
-
},
|
|
416
|
+
token: xt.findCredential(a.url)?.token ?? ""
|
|
417
|
+
}, i = await F(l, {
|
|
397
418
|
method: "post",
|
|
398
419
|
body: JSON.stringify({
|
|
399
420
|
message: e,
|
|
400
|
-
context:
|
|
401
|
-
conversationId:
|
|
421
|
+
context: s.context,
|
|
422
|
+
conversationId: s.previousConversationId
|
|
402
423
|
}),
|
|
403
|
-
headers:
|
|
404
|
-
signal:
|
|
424
|
+
headers: c,
|
|
425
|
+
signal: s.signal
|
|
405
426
|
});
|
|
406
|
-
if (
|
|
407
|
-
throw new Error(`Doc assistant chat failed (${
|
|
408
|
-
cause:
|
|
427
|
+
if (i.httpStatus !== 200)
|
|
428
|
+
throw new Error(`Doc assistant chat failed (${i.httpStatus})`, {
|
|
429
|
+
cause: i.data
|
|
409
430
|
});
|
|
410
|
-
const
|
|
411
|
-
if (!
|
|
431
|
+
const u = i.data, r = [u], { conversationId: p, inquiryId: m } = u, d = async (h, f) => {
|
|
432
|
+
if (!f)
|
|
412
433
|
return;
|
|
413
|
-
await
|
|
414
|
-
const
|
|
434
|
+
await yt(500);
|
|
435
|
+
const b = await F(l, {
|
|
415
436
|
method: "post",
|
|
416
|
-
body: JSON.stringify({ conversationId: p, inquiryId: m, ackSequenceNumber:
|
|
417
|
-
headers:
|
|
418
|
-
signal:
|
|
437
|
+
body: JSON.stringify({ conversationId: p, inquiryId: m, ackSequenceNumber: h }),
|
|
438
|
+
headers: c,
|
|
439
|
+
signal: s.signal
|
|
419
440
|
});
|
|
420
|
-
if (
|
|
421
|
-
throw new Error(`Doc assistant poll failed (${
|
|
422
|
-
cause:
|
|
441
|
+
if (b.httpStatus !== 200)
|
|
442
|
+
throw new Error(`Doc assistant poll failed (${b.httpStatus})`, {
|
|
443
|
+
cause: b.data
|
|
423
444
|
});
|
|
424
|
-
const S =
|
|
425
|
-
|
|
445
|
+
const S = b.data;
|
|
446
|
+
r.push(S), await d(S.sequenceNumber, S.hasMore);
|
|
426
447
|
};
|
|
427
|
-
return
|
|
448
|
+
return u.hasMore && await d(u.sequenceNumber, u.hasMore), r;
|
|
428
449
|
}
|
|
429
|
-
function
|
|
450
|
+
function ae(a, t) {
|
|
430
451
|
switch (t) {
|
|
431
452
|
case "doc_chat":
|
|
432
|
-
return
|
|
453
|
+
return a.find((e) => e.message != null)?.message ?? "";
|
|
433
454
|
case "doc_ai_assistant":
|
|
434
|
-
for (let e =
|
|
435
|
-
const
|
|
436
|
-
if (
|
|
437
|
-
const o =
|
|
455
|
+
for (let e = a.length - 1; e >= 0; e -= 1) {
|
|
456
|
+
const s = a[e];
|
|
457
|
+
if (s.context?.kind === "DocAIAssistantContext") {
|
|
458
|
+
const o = s.context.results?.[0]?.reply;
|
|
438
459
|
if (o)
|
|
439
460
|
return o;
|
|
440
461
|
}
|
|
441
462
|
}
|
|
442
463
|
return "";
|
|
443
464
|
default:
|
|
444
|
-
return
|
|
465
|
+
return C(t);
|
|
445
466
|
}
|
|
446
467
|
}
|
|
447
|
-
const
|
|
468
|
+
const se = async (a, t) => {
|
|
448
469
|
await g({ text: "Asking documentation assistant...", agentName: "doc-assistant" }, t);
|
|
449
|
-
const e =
|
|
470
|
+
const e = x(a.agentExecutionContext.messages).trim();
|
|
450
471
|
if (!e)
|
|
451
472
|
return {
|
|
452
473
|
status: "success",
|
|
453
474
|
outputMessage: "Please share your question and I can help with ArcGIS and Portal documentation."
|
|
454
475
|
};
|
|
455
|
-
const
|
|
456
|
-
|
|
457
|
-
const o = Yt(
|
|
458
|
-
portal:
|
|
476
|
+
const s = t?.configurable?.context;
|
|
477
|
+
I(s);
|
|
478
|
+
const o = Yt(a.agentExecutionContext.sharedState), { reply: l, conversationId: c } = await te({
|
|
479
|
+
portal: s.portal,
|
|
459
480
|
question: e,
|
|
460
481
|
previousConversationId: o.conversationId || void 0,
|
|
461
482
|
skillId: "doc_ai_assistant",
|
|
462
|
-
persona: "
|
|
483
|
+
persona: "doc-online"
|
|
463
484
|
});
|
|
464
485
|
return {
|
|
465
486
|
status: "success",
|
|
466
|
-
outputMessage:
|
|
467
|
-
sharedStatePatch:
|
|
468
|
-
conversationId:
|
|
487
|
+
outputMessage: l.trim() || "I could not retrieve a response from the documentation assistant.",
|
|
488
|
+
sharedStatePatch: Ht({
|
|
489
|
+
conversationId: c || o.conversationId
|
|
469
490
|
})
|
|
470
491
|
};
|
|
471
|
-
},
|
|
472
|
-
async ({ groupTitle:
|
|
473
|
-
const e =
|
|
492
|
+
}, et = Y(
|
|
493
|
+
async ({ groupTitle: a }, t) => {
|
|
494
|
+
const e = a.trim();
|
|
474
495
|
if (!e)
|
|
475
496
|
return null;
|
|
476
|
-
const
|
|
477
|
-
|
|
497
|
+
const s = t?.configurable?.context;
|
|
498
|
+
I(s);
|
|
478
499
|
try {
|
|
479
|
-
return (await
|
|
500
|
+
return (await It(s.portal, { query: `title:${e}`, num: 1 }))?.results[0]?.id || null;
|
|
480
501
|
} catch (o) {
|
|
481
502
|
return console.error("Error searching for portal group by title:", o), null;
|
|
482
503
|
}
|
|
@@ -484,28 +505,36 @@ const te = async (s, t) => {
|
|
|
484
505
|
{
|
|
485
506
|
name: "resolvePortalGroupIdByTitle",
|
|
486
507
|
description: "Resolves an ArcGIS Portal group title to the best-match group id. Use this when a user references a group by title instead of an explicit group id.",
|
|
487
|
-
schema:
|
|
488
|
-
groupTitle:
|
|
508
|
+
schema: n.object({
|
|
509
|
+
groupTitle: n.string().describe("The portal group title to resolve to a group id.")
|
|
489
510
|
})
|
|
490
511
|
}
|
|
491
|
-
),
|
|
492
|
-
async ({ itemTitle:
|
|
493
|
-
const e =
|
|
512
|
+
), at = Y(
|
|
513
|
+
async ({ itemTitle: a }, t) => {
|
|
514
|
+
const e = a.trim();
|
|
494
515
|
if (!e)
|
|
495
516
|
return null;
|
|
496
|
-
const
|
|
497
|
-
|
|
498
|
-
const { result: o, error:
|
|
499
|
-
return
|
|
517
|
+
const s = t?.configurable?.context;
|
|
518
|
+
I(s);
|
|
519
|
+
const { result: o, error: l } = await St(s.portal, e, { num: 1 });
|
|
520
|
+
return l && console.error("Error searching for portal item by title:", l), o?.results[0]?.id || null;
|
|
500
521
|
},
|
|
501
522
|
{
|
|
502
523
|
name: "resolvePortalItemIdByTitle",
|
|
503
524
|
description: 'Resolves an ArcGIS Portal item title to the best-match item id. Use this when a user references an item by title (including hash mentions like #title or #"title with spaces") instead of an explicit item id.',
|
|
504
|
-
schema:
|
|
505
|
-
itemTitle:
|
|
525
|
+
schema: n.object({
|
|
526
|
+
itemTitle: n.string().describe("The portal item title to resolve to an item id.")
|
|
506
527
|
})
|
|
507
528
|
}
|
|
508
|
-
)
|
|
529
|
+
);
|
|
530
|
+
function G(a, t = "#") {
|
|
531
|
+
const e = a.match(new RegExp(`\\${t}"([^"]+)"`, "u"));
|
|
532
|
+
if (e?.[1])
|
|
533
|
+
return e[1].trim();
|
|
534
|
+
const s = a.match(new RegExp(`\\${t}([^\\s"']+)`, "u"));
|
|
535
|
+
return s?.[1] ? s[1].trim() : null;
|
|
536
|
+
}
|
|
537
|
+
const st = {
|
|
509
538
|
"portal-content": {
|
|
510
539
|
description: "The main content page of the portal.",
|
|
511
540
|
hints: ["My content", "Content"],
|
|
@@ -586,16 +615,16 @@ const te = async (s, t) => {
|
|
|
586
615
|
hints: ["Organization settings", "Security", "Organization > Settings > Security"],
|
|
587
616
|
scope: "entity"
|
|
588
617
|
}
|
|
589
|
-
},
|
|
590
|
-
([
|
|
618
|
+
}, oe = wt(st), re = Object.entries(st).map(
|
|
619
|
+
([a, { description: t, hints: e, scope: s }]) => ` - ${a}: ${t} (scope: ${s}; hints: ${e.join(", ")})`
|
|
591
620
|
).join(`
|
|
592
|
-
`),
|
|
621
|
+
`), ne = `
|
|
593
622
|
You decide whether the assistant response should include a navigation action to ArcGIS Portal.
|
|
594
623
|
|
|
595
624
|
Given the user question and assistant response:
|
|
596
625
|
- Decide if a navigation action would help the user complete the task.
|
|
597
626
|
- If yes, choose one destination type:
|
|
598
|
-
${
|
|
627
|
+
${re}
|
|
599
628
|
|
|
600
629
|
Rules:
|
|
601
630
|
- Only suggest navigation when you are highly confident the destination will help complete the user's task.
|
|
@@ -618,38 +647,40 @@ User question:
|
|
|
618
647
|
|
|
619
648
|
Assistant response:
|
|
620
649
|
{response}
|
|
621
|
-
`,
|
|
622
|
-
shouldSuggestNavigation:
|
|
623
|
-
destinationType:
|
|
624
|
-
itemId:
|
|
625
|
-
groupId:
|
|
626
|
-
confidence:
|
|
627
|
-
}),
|
|
650
|
+
`, Q = n.object({
|
|
651
|
+
shouldSuggestNavigation: n.boolean().default(!1),
|
|
652
|
+
destinationType: n.enum(["none", ...oe]).default("none"),
|
|
653
|
+
itemId: n.string().default(""),
|
|
654
|
+
groupId: n.string().default(""),
|
|
655
|
+
confidence: n.number().min(0).max(1).default(0)
|
|
656
|
+
}), ie = async (a, t) => {
|
|
628
657
|
await g({ text: "Extracting navigation intent...", agentName: "doc-assistant" }, t);
|
|
629
|
-
const e =
|
|
658
|
+
const e = a.outputMessage.trim();
|
|
630
659
|
if (!e)
|
|
631
660
|
return {};
|
|
632
|
-
const
|
|
633
|
-
question:
|
|
661
|
+
const s = x(a.agentExecutionContext.messages).trim(), o = await U.fromTemplate(ne).format({
|
|
662
|
+
question: s,
|
|
634
663
|
response: e
|
|
635
|
-
}),
|
|
636
|
-
|
|
637
|
-
tools: [tt, Z],
|
|
638
|
-
systemPrompt: o,
|
|
639
|
-
responseFormat: K,
|
|
640
|
-
checkpointer: !0
|
|
641
|
-
}).invoke({ messages: s.agentExecutionContext.messages }, t), l = K.parse(u.structuredResponse ?? {});
|
|
642
|
-
if (!l.shouldSuggestNavigation || l.destinationType === "none")
|
|
664
|
+
}), c = (await D({ modelTier: "fast" })).withStructuredOutput(Q), i = Q.parse(await c.invoke(o));
|
|
665
|
+
if (!i.shouldSuggestNavigation || i.destinationType === "none")
|
|
643
666
|
return {};
|
|
644
|
-
|
|
645
|
-
|
|
667
|
+
if (i.destinationType === "portal-item" && !i.itemId) {
|
|
668
|
+
const r = G(s, "#");
|
|
669
|
+
r && (i.itemId = await at.invoke({ itemTitle: r }, t) ?? "");
|
|
670
|
+
}
|
|
671
|
+
if (i.destinationType === "portal-group" && !i.groupId) {
|
|
672
|
+
const r = G(s, "$") ?? G(s, "#");
|
|
673
|
+
r && (i.groupId = await et.invoke({ groupTitle: r }, t) ?? "");
|
|
674
|
+
}
|
|
675
|
+
const u = le(i);
|
|
676
|
+
return u ? (await R(u, t), {}) : {};
|
|
646
677
|
};
|
|
647
|
-
function
|
|
648
|
-
destinationType:
|
|
678
|
+
function le({
|
|
679
|
+
destinationType: a,
|
|
649
680
|
itemId: t,
|
|
650
681
|
groupId: e
|
|
651
682
|
}) {
|
|
652
|
-
switch (
|
|
683
|
+
switch (a) {
|
|
653
684
|
case "portal-content":
|
|
654
685
|
case "portal-content-favorites":
|
|
655
686
|
case "portal-content-group":
|
|
@@ -664,7 +695,7 @@ function re({
|
|
|
664
695
|
case "portal-notebooks":
|
|
665
696
|
case "portal-scene-viewer":
|
|
666
697
|
case "portal-settings-security":
|
|
667
|
-
return { destinationType:
|
|
698
|
+
return { destinationType: a };
|
|
668
699
|
case "portal-item":
|
|
669
700
|
return t ? { destinationType: "portal-item", itemId: t } : null;
|
|
670
701
|
case "portal-group":
|
|
@@ -672,34 +703,34 @@ function re({
|
|
|
672
703
|
case "none":
|
|
673
704
|
return null;
|
|
674
705
|
default:
|
|
675
|
-
return
|
|
706
|
+
return C(a);
|
|
676
707
|
}
|
|
677
708
|
}
|
|
678
|
-
const
|
|
679
|
-
...
|
|
680
|
-
}),
|
|
709
|
+
const ot = y.Root({
|
|
710
|
+
...k()
|
|
711
|
+
}), ue = () => new N(ot).addNode("answerDocQuestion", se).addNode("extractNavigationIntent", ie).addEdge(P, "answerDocQuestion").addEdge("answerDocQuestion", "extractNavigationIntent").addEdge("extractNavigationIntent", w), ce = String.raw`- **portal-doc-assistant** - General ArcGIS documentation and Portal help assistant:
|
|
681
712
|
- answers general ArcGIS, Portal, Enterprise, and JavaScript SDK questions
|
|
682
713
|
- acts as a fallback when specialized agents are not applicable
|
|
683
|
-
`,
|
|
714
|
+
`, pe = {
|
|
684
715
|
id: "portal-doc-assistant",
|
|
685
716
|
name: "Portal Doc Assistant",
|
|
686
|
-
description:
|
|
687
|
-
createGraph:
|
|
688
|
-
workspace:
|
|
689
|
-
},
|
|
690
|
-
const t =
|
|
691
|
-
return t ? { latestGroupId: t.latestGroupId, memory: t.memory } :
|
|
692
|
-
},
|
|
717
|
+
description: ce,
|
|
718
|
+
createGraph: ue,
|
|
719
|
+
workspace: ot
|
|
720
|
+
}, de = () => ({ latestGroupId: null, memory: {} }), q = (a) => {
|
|
721
|
+
const t = a?.agentExecutionContext.sharedState.portalGroupSummaryMemory?.value;
|
|
722
|
+
return t ? { latestGroupId: t.latestGroupId, memory: t.memory } : de();
|
|
723
|
+
}, rt = `
|
|
693
724
|
Shared markdown formatting rules:
|
|
694
725
|
- Use clear markdown headings (##) to separate sections.
|
|
695
726
|
- Use concise bullet points for lists of facts, counts, or signals.
|
|
696
727
|
- Emphasize key metrics with bold labels (for example: **Recent items:** 4).
|
|
697
728
|
- Keep wording direct and analytical; avoid filler language but make sure the language is friendly.
|
|
698
729
|
- Do not include raw internal IDs unless explicitly requested.
|
|
699
|
-
`,
|
|
730
|
+
`, me = `
|
|
700
731
|
You answer follow-up questions about ArcGIS group analytics.
|
|
701
732
|
|
|
702
|
-
${
|
|
733
|
+
${rt}
|
|
703
734
|
|
|
704
735
|
Ground your answer in the provided group analytics summary and context.
|
|
705
736
|
If the answer is not available from the provided context, state that clearly and suggest what to check next.
|
|
@@ -721,18 +752,18 @@ Group full context:
|
|
|
721
752
|
|
|
722
753
|
Question:
|
|
723
754
|
{question}
|
|
724
|
-
`,
|
|
755
|
+
`, ge = async (a, t) => {
|
|
725
756
|
await g({ text: "Answering group follow-up...", agentName: "group-analytics" }, t);
|
|
726
|
-
const e =
|
|
757
|
+
const e = q(a), s = a.groupSummaryGroupId ?? e.latestGroupId, o = s ? e.memory[s] : void 0, l = a.groupSummaryQuestion || x(a.agentExecutionContext.messages);
|
|
727
758
|
return o ? {
|
|
728
759
|
status: "success",
|
|
729
|
-
outputMessage: (await
|
|
730
|
-
promptText:
|
|
731
|
-
schema:
|
|
760
|
+
outputMessage: (await v({
|
|
761
|
+
promptText: me,
|
|
762
|
+
schema: he,
|
|
732
763
|
modelTier: "default",
|
|
733
764
|
inputVariables: {
|
|
734
765
|
summary: o.summary,
|
|
735
|
-
question:
|
|
766
|
+
question: l,
|
|
736
767
|
fullContext: JSON.stringify(o.fullContext)
|
|
737
768
|
}
|
|
738
769
|
})).answer
|
|
@@ -740,10 +771,10 @@ Question:
|
|
|
740
771
|
status: "success",
|
|
741
772
|
outputMessage: "I do not have group analytics context yet. Ask me to analyze a group first with analyze group <group id>."
|
|
742
773
|
};
|
|
743
|
-
},
|
|
744
|
-
answer:
|
|
745
|
-
isRelevant:
|
|
746
|
-
}),
|
|
774
|
+
}, he = n.object({
|
|
775
|
+
answer: n.string(),
|
|
776
|
+
isRelevant: n.boolean()
|
|
777
|
+
}), fe = `
|
|
747
778
|
Classify the user's request for ArcGIS Portal group analytics.
|
|
748
779
|
|
|
749
780
|
Rules:
|
|
@@ -772,58 +803,58 @@ hasAnalyticsContext:
|
|
|
772
803
|
|
|
773
804
|
User message:
|
|
774
805
|
{userMessage}
|
|
775
|
-
`,
|
|
806
|
+
`, ye = async (a, t) => {
|
|
776
807
|
await g({ text: "Analyzing group-analytics intent...", agentName: "group-analytics" }, t);
|
|
777
|
-
const e =
|
|
808
|
+
const e = x(a.agentExecutionContext.messages), s = !!q(a).latestGroupId, o = await U.fromTemplate(fe).format({
|
|
778
809
|
userMessage: e,
|
|
779
|
-
hasAnalyticsContext: String(
|
|
780
|
-
}),
|
|
781
|
-
|
|
782
|
-
|
|
783
|
-
|
|
784
|
-
|
|
785
|
-
|
|
786
|
-
|
|
810
|
+
hasAnalyticsContext: String(s)
|
|
811
|
+
}), c = (await D({ modelTier: "fast" })).withStructuredOutput(K), i = K.parse(await c.invoke(o));
|
|
812
|
+
let u = i.groupId;
|
|
813
|
+
if ((i.intent === "summarize" || i.intent === "navigation") && !u) {
|
|
814
|
+
const f = G(e, "$");
|
|
815
|
+
f && (u = await et.invoke({ groupTitle: f }, t) ?? "");
|
|
816
|
+
}
|
|
817
|
+
const { intent: r, question: p } = i, m = r === "summarize" && !u, d = r === "followUp" && !(p ?? "").trim(), h = r === "clarify" || m || d;
|
|
787
818
|
return {
|
|
788
|
-
groupSummaryIntent:
|
|
789
|
-
groupSummaryGroupId:
|
|
790
|
-
groupSummaryQuestion:
|
|
819
|
+
groupSummaryIntent: h ? "clarify" : r,
|
|
820
|
+
groupSummaryGroupId: u || null,
|
|
821
|
+
groupSummaryQuestion: p || "",
|
|
791
822
|
status: "success",
|
|
792
|
-
outputMessage:
|
|
823
|
+
outputMessage: h ? "Please clarify with a group id or title" : ""
|
|
793
824
|
};
|
|
794
|
-
},
|
|
795
|
-
intent:
|
|
796
|
-
groupId:
|
|
797
|
-
question:
|
|
798
|
-
}),
|
|
799
|
-
const e =
|
|
825
|
+
}, K = n.object({
|
|
826
|
+
intent: n.enum(["summarize", "followUp", "navigation", "clarify"]),
|
|
827
|
+
groupId: n.string().default(""),
|
|
828
|
+
question: n.string().default("")
|
|
829
|
+
}), we = async (a, t) => {
|
|
830
|
+
const e = q(a), s = a.groupSummaryGroupId ?? e.latestGroupId;
|
|
800
831
|
return await g({ text: "Preparing navigation...", agentName: "group-analytics" }, t), await R(
|
|
801
|
-
|
|
832
|
+
s ? { destinationType: "portal-group", groupId: s } : { destinationType: "portal-groups" },
|
|
802
833
|
t
|
|
803
834
|
), { status: "success" };
|
|
804
835
|
};
|
|
805
|
-
function
|
|
806
|
-
return
|
|
836
|
+
function nt({ timestamp: a, now: t, windowMs: e }) {
|
|
837
|
+
return a ? t - a <= e : !1;
|
|
807
838
|
}
|
|
808
|
-
const
|
|
809
|
-
function
|
|
810
|
-
const t =
|
|
839
|
+
const be = 720 * 60 * 60 * 1e3;
|
|
840
|
+
function ve(a) {
|
|
841
|
+
const t = Gt(a);
|
|
811
842
|
return {
|
|
812
|
-
id:
|
|
813
|
-
title:
|
|
814
|
-
description:
|
|
815
|
-
snippet:
|
|
816
|
-
access:
|
|
817
|
-
owner:
|
|
818
|
-
tags:
|
|
819
|
-
created:
|
|
820
|
-
modified:
|
|
821
|
-
isInvitationOnly:
|
|
843
|
+
id: a.id ?? "",
|
|
844
|
+
title: a.title ?? "",
|
|
845
|
+
description: a.description ?? "",
|
|
846
|
+
snippet: a.snippet ?? "",
|
|
847
|
+
access: a.access ?? null,
|
|
848
|
+
owner: a.owner ?? "",
|
|
849
|
+
tags: a.tags ?? [],
|
|
850
|
+
created: a.created?.getTime(),
|
|
851
|
+
modified: a.modified?.getTime(),
|
|
852
|
+
isInvitationOnly: a.isInvitationOnly,
|
|
822
853
|
sourceSignals: {
|
|
823
|
-
capabilities:
|
|
824
|
-
membershipAccess:
|
|
825
|
-
isOpenData: At(
|
|
826
|
-
isDistributedCollaborationGroup:
|
|
854
|
+
capabilities: Nt(a),
|
|
855
|
+
membershipAccess: Ct(a),
|
|
856
|
+
isOpenData: At(a),
|
|
857
|
+
isDistributedCollaborationGroup: Tt(a),
|
|
827
858
|
orgId: t.orgId,
|
|
828
859
|
hiddenMembers: t.hiddenMembers,
|
|
829
860
|
isViewOnly: t.isViewOnly,
|
|
@@ -832,16 +863,16 @@ function we(s) {
|
|
|
832
863
|
}
|
|
833
864
|
};
|
|
834
865
|
}
|
|
835
|
-
async function
|
|
836
|
-
const t = { owner:
|
|
866
|
+
async function Ie(a) {
|
|
867
|
+
const t = { owner: a.owner ?? "", admins: [], users: [] };
|
|
837
868
|
try {
|
|
838
|
-
return await
|
|
869
|
+
return await a.fetchMembers();
|
|
839
870
|
} catch (e) {
|
|
840
871
|
return console.warn("Unable to fetch group members for analytics context", e), t;
|
|
841
872
|
}
|
|
842
873
|
}
|
|
843
|
-
function
|
|
844
|
-
return
|
|
874
|
+
function xe(a) {
|
|
875
|
+
return a.map((t) => ({
|
|
845
876
|
id: t.id ?? "",
|
|
846
877
|
title: t.title ?? "Untitled",
|
|
847
878
|
type: t.type ?? "Unknown",
|
|
@@ -850,43 +881,43 @@ function ve(s) {
|
|
|
850
881
|
modified: t.modified?.getTime()
|
|
851
882
|
}));
|
|
852
883
|
}
|
|
853
|
-
function
|
|
854
|
-
return
|
|
855
|
-
(e) => e.modified ?
|
|
884
|
+
function Se(a, t) {
|
|
885
|
+
return a.filter(
|
|
886
|
+
(e) => e.modified ? nt({ timestamp: e.modified, now: t, windowMs: be }) : !1
|
|
856
887
|
);
|
|
857
888
|
}
|
|
858
|
-
function
|
|
889
|
+
function Me(a) {
|
|
859
890
|
const t = /* @__PURE__ */ new Map();
|
|
860
|
-
for (const e of
|
|
891
|
+
for (const e of a)
|
|
861
892
|
t.set(e.type, (t.get(e.type) ?? 0) + 1);
|
|
862
|
-
return [...t.entries()].sort((e,
|
|
893
|
+
return [...t.entries()].sort((e, s) => s[1] - e[1] || e[0].localeCompare(s[0])).slice(0, 6).map(([e, s]) => ({ type: e, count: s }));
|
|
863
894
|
}
|
|
864
|
-
async function
|
|
865
|
-
const t = await
|
|
895
|
+
async function Ge(a) {
|
|
896
|
+
const t = await a.queryItems({ num: 20, sortField: "modified", sortOrder: "desc" }), e = xe(t.results), s = Date.now();
|
|
866
897
|
return {
|
|
867
898
|
total: t.total,
|
|
868
899
|
topItems: e,
|
|
869
|
-
recentlyModifiedItems:
|
|
870
|
-
topItemTypes:
|
|
900
|
+
recentlyModifiedItems: Se(e, s),
|
|
901
|
+
topItemTypes: Me(e)
|
|
871
902
|
};
|
|
872
903
|
}
|
|
873
|
-
async function
|
|
904
|
+
async function Te(a, t) {
|
|
874
905
|
if (!t)
|
|
875
906
|
return { error: { code: "missingGroupId", message: "Group id is required." } };
|
|
876
907
|
try {
|
|
877
|
-
const
|
|
878
|
-
if (!
|
|
908
|
+
const s = (await a.queryGroups({ query: `id:${t}`, num: 1 })).results[0];
|
|
909
|
+
if (!s)
|
|
879
910
|
return { error: { code: "groupNotFound", message: `No group found for id: ${t}` } };
|
|
880
|
-
const o =
|
|
881
|
-
return { result: { group: o, members:
|
|
911
|
+
const o = ve(s), l = await Ie(s), c = await Ge(s);
|
|
912
|
+
return { result: { group: o, members: l, items: c } };
|
|
882
913
|
} catch (e) {
|
|
883
914
|
return console.error("Error fetching portal group analytics context:", e), { error: { code: "unhandledError" } };
|
|
884
915
|
}
|
|
885
916
|
}
|
|
886
|
-
const
|
|
917
|
+
const Ae = `
|
|
887
918
|
You summarize ArcGIS Portal groups based on structured context and deterministic activity signals.
|
|
888
919
|
|
|
889
|
-
${
|
|
920
|
+
${rt}
|
|
890
921
|
|
|
891
922
|
Output format requirements:
|
|
892
923
|
- Return concise markdown with clear sections in this order:
|
|
@@ -922,82 +953,82 @@ Group context:
|
|
|
922
953
|
|
|
923
954
|
Deterministic signals:
|
|
924
955
|
{deterministicSignals}
|
|
925
|
-
`,
|
|
926
|
-
const e =
|
|
956
|
+
`, Ce = 2160 * 60 * 60 * 1e3, Ne = async (a, t) => {
|
|
957
|
+
const e = a.groupSummaryGroupId;
|
|
927
958
|
if (!e)
|
|
928
959
|
return {
|
|
929
960
|
status: "success",
|
|
930
961
|
outputMessage: 'Please clarify with analyze group <group id>, analyze group $<title>, or analyze group $"<title with spaces>".'
|
|
931
962
|
};
|
|
932
963
|
await g({ text: `Analyzing group ${e}...`, agentName: "group-analytics" }, t);
|
|
933
|
-
const
|
|
934
|
-
|
|
935
|
-
const { result: o, error:
|
|
936
|
-
if (
|
|
964
|
+
const s = t?.configurable?.context;
|
|
965
|
+
I(s);
|
|
966
|
+
const { result: o, error: l } = await Te(s.portal, e);
|
|
967
|
+
if (l || !o)
|
|
937
968
|
return await g({ text: "Failed to fetch group context", agentName: "group-analytics" }, t), {
|
|
938
969
|
status: "success",
|
|
939
970
|
outputMessage: "Unable to retrieve group context for analytics."
|
|
940
971
|
};
|
|
941
|
-
const { group:
|
|
942
|
-
promptText:
|
|
943
|
-
schema:
|
|
972
|
+
const { group: c, items: i } = o, u = Date.now(), r = c.modified, p = r ? nt({ timestamp: r, now: u, windowMs: Ce }) : !1, m = i.recentlyModifiedItems.length, d = m > 0, h = p || d, f = await v({
|
|
973
|
+
promptText: Ae,
|
|
974
|
+
schema: Pe,
|
|
944
975
|
modelTier: "default",
|
|
945
976
|
inputVariables: {
|
|
946
977
|
context: JSON.stringify(o),
|
|
947
978
|
deterministicSignals: JSON.stringify({
|
|
948
|
-
isGroupActive:
|
|
979
|
+
isGroupActive: h,
|
|
949
980
|
isGroupRecentlyModified: p,
|
|
950
981
|
hasRecentlyAddedOrUpdatedContent: d,
|
|
951
982
|
recentItemCount: m
|
|
952
983
|
})
|
|
953
984
|
}
|
|
954
|
-
}), { followUpQuestions:
|
|
985
|
+
}), { followUpQuestions: b, summary: S } = f, ut = q(a), ct = {
|
|
955
986
|
latestGroupId: e,
|
|
956
987
|
memory: {
|
|
957
|
-
...
|
|
958
|
-
[e]: { summary: S, followUpQuestions:
|
|
988
|
+
...ut.memory,
|
|
989
|
+
[e]: { summary: S, followUpQuestions: b, fullContext: o }
|
|
959
990
|
}
|
|
960
991
|
};
|
|
961
|
-
return
|
|
992
|
+
return b.length && await E({ type: "suggested-prompts", data: { prompts: b } }, t), {
|
|
962
993
|
status: "success",
|
|
963
994
|
outputMessage: S,
|
|
964
|
-
sharedStatePatch: { portalGroupSummaryMemory: { value:
|
|
995
|
+
sharedStatePatch: { portalGroupSummaryMemory: { value: ct } }
|
|
965
996
|
};
|
|
966
|
-
},
|
|
967
|
-
summary:
|
|
968
|
-
followUpQuestions:
|
|
969
|
-
}),
|
|
970
|
-
...
|
|
971
|
-
groupSummaryIntent:
|
|
972
|
-
reducer:
|
|
997
|
+
}, Pe = n.object({
|
|
998
|
+
summary: n.string(),
|
|
999
|
+
followUpQuestions: n.array(n.string()).default([])
|
|
1000
|
+
}), z = (a, t) => t ?? a, it = y.Root({
|
|
1001
|
+
...k(),
|
|
1002
|
+
groupSummaryIntent: y({
|
|
1003
|
+
reducer: z,
|
|
973
1004
|
default: () => "clarify"
|
|
974
1005
|
}),
|
|
975
|
-
groupSummaryGroupId:
|
|
976
|
-
reducer:
|
|
1006
|
+
groupSummaryGroupId: y({
|
|
1007
|
+
reducer: z,
|
|
977
1008
|
default: () => null
|
|
978
1009
|
}),
|
|
979
|
-
groupSummaryQuestion:
|
|
980
|
-
reducer:
|
|
1010
|
+
groupSummaryQuestion: y({
|
|
1011
|
+
reducer: z,
|
|
981
1012
|
default: () => ""
|
|
982
1013
|
})
|
|
983
|
-
}),
|
|
1014
|
+
}), ke = () => new N(it).addNode("detectGroupSummaryIntent", ye).addNode("summarizePortalGroup", Ne).addNode("answerGroupSummaryFollowUp", ge).addNode("suggestGroupSummaryNavigation", we).addEdge(P, "detectGroupSummaryIntent").addConditionalEdges("detectGroupSummaryIntent", (t) => t.groupSummaryIntent === "summarize" ? "summarizePortalGroup" : t.groupSummaryIntent === "followUp" ? "answerGroupSummaryFollowUp" : t.groupSummaryIntent === "navigation" ? "suggestGroupSummaryNavigation" : w).addEdge("summarizePortalGroup", w).addEdge("answerGroupSummaryFollowUp", w).addEdge("suggestGroupSummaryNavigation", w), qe = String.raw`- **portal-group-analytics** - Portal group analytics assistant:
|
|
984
1015
|
- summarizes ArcGIS portal groups from group context and sourceJSON details
|
|
985
1016
|
- answers follow-up questions grounded in the summarized group
|
|
986
1017
|
- suggests navigation to groups when relevant
|
|
987
|
-
`,
|
|
1018
|
+
`, ze = {
|
|
988
1019
|
id: "portal-group-analytics",
|
|
989
1020
|
name: "Portal Group Analytics",
|
|
990
|
-
description:
|
|
991
|
-
createGraph:
|
|
992
|
-
workspace:
|
|
993
|
-
},
|
|
994
|
-
const t =
|
|
995
|
-
return t ? { latestItemId: t.latestItemId, memory: t.memory } :
|
|
996
|
-
},
|
|
997
|
-
intent:
|
|
998
|
-
itemId:
|
|
999
|
-
question:
|
|
1000
|
-
}),
|
|
1021
|
+
description: qe,
|
|
1022
|
+
createGraph: ke,
|
|
1023
|
+
workspace: it
|
|
1024
|
+
}, $e = () => ({ latestItemId: null, memory: {} }), O = (a) => {
|
|
1025
|
+
const t = a?.agentExecutionContext.sharedState.portalItemAnalyticsSummaryMemory?.value;
|
|
1026
|
+
return t ? { latestItemId: t.latestItemId, memory: t.memory } : $e();
|
|
1027
|
+
}, J = n.object({
|
|
1028
|
+
intent: n.enum(["summarize", "followUp", "clarify"]),
|
|
1029
|
+
itemId: n.string().default(""),
|
|
1030
|
+
question: n.string().default("")
|
|
1031
|
+
}), Ee = n.object({ summary: n.string(), followUpQuestions: n.array(n.string()).default([]) }), De = n.object({ answer: n.string(), isRelevant: n.boolean() }), Ue = `
|
|
1001
1032
|
You answer follow-up questions about an ArcGIS item.
|
|
1002
1033
|
|
|
1003
1034
|
Ground your answer in the provided item context.
|
|
@@ -1017,18 +1048,18 @@ Item full context
|
|
|
1017
1048
|
|
|
1018
1049
|
Question:
|
|
1019
1050
|
{question}
|
|
1020
|
-
`,
|
|
1051
|
+
`, Re = async (a, t) => {
|
|
1021
1052
|
await g({ text: "Answering follow-up...", agentName: "analytics" }, t);
|
|
1022
|
-
const e =
|
|
1053
|
+
const e = O(a), s = a.analyticsItemId ?? e.latestItemId, o = s ? e.memory[s] : void 0, l = a.analyticsQuestion || x(a.agentExecutionContext.messages);
|
|
1023
1054
|
return o ? {
|
|
1024
1055
|
status: "success",
|
|
1025
|
-
outputMessage: (await
|
|
1026
|
-
promptText:
|
|
1027
|
-
schema:
|
|
1056
|
+
outputMessage: (await v({
|
|
1057
|
+
promptText: Ue,
|
|
1058
|
+
schema: De,
|
|
1028
1059
|
modelTier: "default",
|
|
1029
1060
|
inputVariables: {
|
|
1030
1061
|
summary: o.summary,
|
|
1031
|
-
question:
|
|
1062
|
+
question: l,
|
|
1032
1063
|
fullContext: JSON.stringify(o.fullContext)
|
|
1033
1064
|
}
|
|
1034
1065
|
})).answer
|
|
@@ -1036,7 +1067,7 @@ Question:
|
|
|
1036
1067
|
status: "success",
|
|
1037
1068
|
outputMessage: "I don't have enough information yet. Please ask me to summarize the item first using summarize item <item id>."
|
|
1038
1069
|
};
|
|
1039
|
-
},
|
|
1070
|
+
}, Oe = `
|
|
1040
1071
|
Classify the user analytics request.
|
|
1041
1072
|
|
|
1042
1073
|
Rules:
|
|
@@ -1066,27 +1097,27 @@ hasSummaryContext:
|
|
|
1066
1097
|
|
|
1067
1098
|
User message:
|
|
1068
1099
|
{userMessage}
|
|
1069
|
-
`, Fe = async (
|
|
1100
|
+
`, Fe = async (a, t) => {
|
|
1070
1101
|
await g({ text: "Analyzing intent...", agentName: "analytics" }, t);
|
|
1071
|
-
const e =
|
|
1102
|
+
const e = x(a.agentExecutionContext.messages), s = !!O(a).latestItemId, o = await U.fromTemplate(Oe).format({
|
|
1072
1103
|
userMessage: e,
|
|
1073
|
-
hasSummaryContext: String(
|
|
1074
|
-
}),
|
|
1075
|
-
|
|
1076
|
-
|
|
1077
|
-
|
|
1078
|
-
|
|
1079
|
-
|
|
1080
|
-
|
|
1104
|
+
hasSummaryContext: String(s)
|
|
1105
|
+
}), c = (await D({ modelTier: "fast" })).withStructuredOutput(J), i = J.parse(await c.invoke(o));
|
|
1106
|
+
let u = i.itemId;
|
|
1107
|
+
if (i.intent === "summarize" && !u) {
|
|
1108
|
+
const f = G(e, "#");
|
|
1109
|
+
f && (u = await at.invoke({ itemTitle: f }, t) ?? "");
|
|
1110
|
+
}
|
|
1111
|
+
const { intent: r, question: p } = i, h = r === "clarify" || r === "summarize" && !u || r === "followUp" && !p;
|
|
1081
1112
|
return {
|
|
1082
|
-
agentExecutionContext: { ...
|
|
1083
|
-
analyticsIntent:
|
|
1084
|
-
analyticsItemId:
|
|
1085
|
-
analyticsQuestion:
|
|
1113
|
+
agentExecutionContext: { ...a.agentExecutionContext },
|
|
1114
|
+
analyticsIntent: h ? "clarify" : r,
|
|
1115
|
+
analyticsItemId: u || null,
|
|
1116
|
+
analyticsQuestion: p || "",
|
|
1086
1117
|
status: "success",
|
|
1087
|
-
outputMessage:
|
|
1118
|
+
outputMessage: h ? 'Please clarify with summarize item <item id>, summarize item #<title>, or summarize item #"<title with spaces>".' : ""
|
|
1088
1119
|
};
|
|
1089
|
-
},
|
|
1120
|
+
}, Ve = `
|
|
1090
1121
|
You are a item summary tool for ArcGIS. Your job is to summarize an item's info based on the provided context.
|
|
1091
1122
|
Summary rules:
|
|
1092
1123
|
- The summary should be concise markdown, make sure to format the output nicely so it's easy to read.
|
|
@@ -1101,55 +1132,55 @@ Do not include internal identifiers.
|
|
|
1101
1132
|
If the user asks for a detailed summary, you may expand the response up to 300 words.
|
|
1102
1133
|
Item context:
|
|
1103
1134
|
{context}
|
|
1104
|
-
`,
|
|
1105
|
-
const e =
|
|
1135
|
+
`, je = async (a, t) => {
|
|
1136
|
+
const e = a.analyticsItemId;
|
|
1106
1137
|
if (!e)
|
|
1107
1138
|
return {
|
|
1108
1139
|
status: "success",
|
|
1109
1140
|
outputMessage: 'Please clarify with summarize item <item id>, summarize item #<title>, or summarize item #"<title with spaces>".'
|
|
1110
1141
|
};
|
|
1111
1142
|
await g({ text: `Summarizing item ${e}...`, agentName: "analytics" }, t);
|
|
1112
|
-
const
|
|
1113
|
-
|
|
1114
|
-
const { portal: o, user:
|
|
1115
|
-
if (
|
|
1143
|
+
const s = t?.configurable?.context;
|
|
1144
|
+
I(s);
|
|
1145
|
+
const { portal: o, user: l } = s, { result: c, error: i } = await Mt(l, o, e);
|
|
1146
|
+
if (i || !c)
|
|
1116
1147
|
return await g({ text: "Failed to get item context for summarization", agentName: "analytics" }, t), {
|
|
1117
1148
|
status: "success",
|
|
1118
1149
|
outputMessage: "Unable to retrieve item context for summarization."
|
|
1119
1150
|
};
|
|
1120
|
-
const { context:
|
|
1121
|
-
promptText:
|
|
1122
|
-
schema:
|
|
1151
|
+
const { context: u } = c, r = await v({
|
|
1152
|
+
promptText: Ve,
|
|
1153
|
+
schema: Ee,
|
|
1123
1154
|
modelTier: "default",
|
|
1124
|
-
inputVariables: { context: JSON.stringify(
|
|
1125
|
-
}), { followUpQuestions: p, summary: m } =
|
|
1155
|
+
inputVariables: { context: JSON.stringify(u) }
|
|
1156
|
+
}), { followUpQuestions: p, summary: m } = r, d = O(a), h = {
|
|
1126
1157
|
latestItemId: e,
|
|
1127
1158
|
memory: {
|
|
1128
1159
|
...d.memory,
|
|
1129
|
-
[e]: { summary: m, followUpQuestions: p, fullContext:
|
|
1160
|
+
[e]: { summary: m, followUpQuestions: p, fullContext: u }
|
|
1130
1161
|
}
|
|
1131
1162
|
};
|
|
1132
|
-
return p.length && await
|
|
1163
|
+
return p.length && await E({ type: "suggested-prompts", data: { prompts: p } }, t), {
|
|
1133
1164
|
status: "success",
|
|
1134
1165
|
outputMessage: m,
|
|
1135
|
-
sharedStatePatch: { portalItemAnalyticsSummaryMemory: { value:
|
|
1166
|
+
sharedStatePatch: { portalItemAnalyticsSummaryMemory: { value: h } }
|
|
1136
1167
|
};
|
|
1137
|
-
},
|
|
1138
|
-
...
|
|
1168
|
+
}, $ = (a, t) => t ?? a, lt = y.Root({
|
|
1169
|
+
...k(),
|
|
1139
1170
|
// States shared only across nodes in the graph, not between invocations
|
|
1140
|
-
analyticsIntent:
|
|
1141
|
-
reducer:
|
|
1171
|
+
analyticsIntent: y({
|
|
1172
|
+
reducer: $,
|
|
1142
1173
|
default: () => "clarify"
|
|
1143
1174
|
}),
|
|
1144
|
-
analyticsItemId:
|
|
1145
|
-
reducer:
|
|
1175
|
+
analyticsItemId: y({
|
|
1176
|
+
reducer: $,
|
|
1146
1177
|
default: () => null
|
|
1147
1178
|
}),
|
|
1148
|
-
analyticsQuestion:
|
|
1149
|
-
reducer:
|
|
1179
|
+
analyticsQuestion: y({
|
|
1180
|
+
reducer: $,
|
|
1150
1181
|
default: () => ""
|
|
1151
1182
|
})
|
|
1152
|
-
}),
|
|
1183
|
+
}), _e = () => new N(lt).addNode("detectAnalyticsIntent", Fe).addNode("summarizePortalItem", je).addNode("answerAnalyticsFollowUp", Re).addEdge(P, "detectAnalyticsIntent").addConditionalEdges("detectAnalyticsIntent", (t) => t.analyticsIntent === "summarize" ? "summarizePortalItem" : t.analyticsIntent === "followUp" ? "answerAnalyticsFollowUp" : w).addEdge("summarizePortalItem", w).addEdge("answerAnalyticsFollowUp", w), Le = String.raw`- **portal-item-analytics** - Portal item analytics assistant:
|
|
1153
1184
|
- answers questions about one specific ArcGIS portal item when item context is present
|
|
1154
1185
|
- summarizes item details, metadata, and context grounded in that item
|
|
1155
1186
|
- suggests follow-up prompts grounded in the same item
|
|
@@ -1158,13 +1189,13 @@ Item context:
|
|
|
1158
1189
|
id: "portal-item-analytics",
|
|
1159
1190
|
name: "Portal Item Analytics",
|
|
1160
1191
|
description: Le,
|
|
1161
|
-
createGraph:
|
|
1162
|
-
workspace:
|
|
1163
|
-
}, Qe =
|
|
1164
|
-
function Ke(
|
|
1192
|
+
createGraph: _e,
|
|
1193
|
+
workspace: lt
|
|
1194
|
+
}, Qe = gt`:host{height:100%;border-width:1px;border-style:solid;border-color:var(--calcite-color-border-3);display:block;width:100%;--tw-shadow: 0 1px 6px -1px rgba(0, 0, 0, .16), 0 1px 2px -1px rgba(0, 0, 0, .08);--tw-shadow-colored: 0 1px 6px -1px var(--tw-shadow-color), 0 1px 2px -1px var(--tw-shadow-color);box-shadow:var(--tw-ring-offset-shadow, 0 0 #0000),var(--tw-ring-shadow, 0 0 #0000),var(--tw-shadow)}.chat-entry{display:flex;flex-direction:column;gap:.75rem;width:100%}.chat-actions{display:flex;justify-content:flex-end;gap:.5rem}.header-actions{display:flex;gap:.5rem;padding-inline-start:.75rem}.navigation-block{display:flex;flex-direction:column;align-items:stretch;gap:.35rem;margin-top:.5rem}.navigation-button{width:100%;margin-block:.25rem}.navigation-block-description{font-size:.75rem;color:var(--calcite-color-text-3)}`;
|
|
1195
|
+
function Ke(a, t) {
|
|
1165
1196
|
if (!t)
|
|
1166
1197
|
return;
|
|
1167
|
-
const { destinationType: e } =
|
|
1198
|
+
const { destinationType: e } = a;
|
|
1168
1199
|
switch (e) {
|
|
1169
1200
|
case "portal-content":
|
|
1170
1201
|
case "portal-content-favorites":
|
|
@@ -1182,26 +1213,26 @@ function Ke(s, t) {
|
|
|
1182
1213
|
case "portal-settings-security":
|
|
1183
1214
|
return t[e];
|
|
1184
1215
|
case "portal-item":
|
|
1185
|
-
return t[e]?.(
|
|
1216
|
+
return t[e]?.(a.itemId);
|
|
1186
1217
|
case "portal-group":
|
|
1187
|
-
return t[e]?.(
|
|
1218
|
+
return t[e]?.(a.groupId);
|
|
1188
1219
|
default:
|
|
1189
|
-
return
|
|
1220
|
+
return C(e);
|
|
1190
1221
|
}
|
|
1191
1222
|
}
|
|
1192
|
-
function Je(
|
|
1193
|
-
const t = Lt.safeParse(
|
|
1223
|
+
function Je(a) {
|
|
1224
|
+
const t = Lt.safeParse(a);
|
|
1194
1225
|
return t.success ? t.data : void 0;
|
|
1195
1226
|
}
|
|
1196
|
-
class We extends
|
|
1227
|
+
class We extends dt {
|
|
1197
1228
|
constructor() {
|
|
1198
|
-
super(...arguments), this.t9n =
|
|
1199
|
-
const e = t.detail,
|
|
1200
|
-
if (!
|
|
1229
|
+
super(...arguments), this.t9n = ft({ blocking: !0 }), this.assistantEl = T(), this.formEl = T(), this.voiceInputEl = T(), this.inputEl = T(), this.navigationSlotElements = /* @__PURE__ */ new Map(), this.handleSlottableRequest = (t) => {
|
|
1230
|
+
const e = t.detail, s = e.data?.block;
|
|
1231
|
+
if (!s)
|
|
1201
1232
|
return;
|
|
1202
|
-
const o = this.getNavigationAction(
|
|
1233
|
+
const o = this.getNavigationAction(s);
|
|
1203
1234
|
o && this.upsertNavigationSlotElement(e.slotName, o);
|
|
1204
|
-
}, this.inputText = "", this.showVoiceInput = !0, this.isListening = !1, this.isVoiceInputDisabled = !1, this.interrupt = null, this.autoDestroyDisabled = !1, this.defaultClosed = !1, this.arcgisPortalNavigationRequest =
|
|
1235
|
+
}, this.inputText = "", this.showVoiceInput = !0, this.isListening = !1, this.isVoiceInputDisabled = !1, this.interrupt = null, this.autoDestroyDisabled = !1, this.defaultClosed = !1, this.arcgisPortalNavigationRequest = mt();
|
|
1205
1236
|
}
|
|
1206
1237
|
static {
|
|
1207
1238
|
this.properties = { inputText: 16, showVoiceInput: 16, isListening: 16, isVoiceInputDisabled: 16, interrupt: 16, autoDestroyDisabled: 5, portal: 0, user: 0, config: 0, navigationTargetMap: 0, defaultClosed: 5 };
|
|
@@ -1210,22 +1241,22 @@ class We extends ct {
|
|
|
1210
1241
|
this.styles = Qe;
|
|
1211
1242
|
}
|
|
1212
1243
|
getNavigationAction(t) {
|
|
1213
|
-
if (t?.type !==
|
|
1244
|
+
if (t?.type !== X)
|
|
1214
1245
|
return;
|
|
1215
1246
|
const e = Je(t.data);
|
|
1216
1247
|
if (!e)
|
|
1217
1248
|
return;
|
|
1218
|
-
const
|
|
1219
|
-
if (
|
|
1220
|
-
return { href:
|
|
1249
|
+
const s = Ke(e, this.navigationTargetMap);
|
|
1250
|
+
if (s)
|
|
1251
|
+
return { href: s, targetDetail: e, label: this.getNavigationText(e.destinationType) };
|
|
1221
1252
|
}
|
|
1222
1253
|
upsertNavigationSlotElement(t, e) {
|
|
1223
|
-
const
|
|
1224
|
-
if (!
|
|
1254
|
+
const s = this.assistantEl.value;
|
|
1255
|
+
if (!s)
|
|
1225
1256
|
return;
|
|
1226
1257
|
let o = this.navigationSlotElements.get(t);
|
|
1227
|
-
o || (o = document.createElement("div"), o.slot = t, this.navigationSlotElements.set(t, o),
|
|
1228
|
-
|
|
1258
|
+
o || (o = document.createElement("div"), o.slot = t, this.navigationSlotElements.set(t, o), s.append(o)), ht(M`<div><calcite-button class="navigation-button" appearance=outline width=full .href=${e.href} icon-end=launch @click=${(l) => {
|
|
1259
|
+
l.preventDefault(), this.arcgisPortalNavigationRequest.emit({
|
|
1229
1260
|
href: e.href,
|
|
1230
1261
|
targetDetail: e.targetDetail
|
|
1231
1262
|
});
|
|
@@ -1267,49 +1298,49 @@ class We extends ct {
|
|
|
1267
1298
|
case "portal-group":
|
|
1268
1299
|
return e.openGroup;
|
|
1269
1300
|
default:
|
|
1270
|
-
return
|
|
1301
|
+
return C(t);
|
|
1271
1302
|
}
|
|
1272
1303
|
}
|
|
1273
1304
|
render() {
|
|
1274
|
-
const { t9n: t, inputText: e, portal:
|
|
1275
|
-
return M`<arcgis-assistant log-enabled keep-suggested-prompts .heading=${t.heading} .entryMessage=${t.entryMessage} @arcgisSlottableRequest=${this.handleSlottableRequest} @arcgisInterrupt=${({ detail:
|
|
1276
|
-
this.interrupt =
|
|
1305
|
+
const { t9n: t, inputText: e, portal: s, user: o, navigationTargetMap: l, showVoiceInput: c, isListening: i, isVoiceInputDisabled: u } = this;
|
|
1306
|
+
return M`<arcgis-assistant log-enabled keep-suggested-prompts .heading=${t.heading} .entryMessage=${t.entryMessage} @arcgisSlottableRequest=${this.handleSlottableRequest} @arcgisInterrupt=${({ detail: r }) => {
|
|
1307
|
+
this.interrupt = r;
|
|
1277
1308
|
}} @arcgisInterruptCancel=${() => {
|
|
1278
1309
|
this.interrupt = null;
|
|
1279
1310
|
}} @arcgisInterruptSubmit=${() => {
|
|
1280
1311
|
this.interrupt = null;
|
|
1281
|
-
}} @arcgisPromptSelect=${({ detail:
|
|
1282
|
-
this.inputText =
|
|
1312
|
+
}} @arcgisPromptSelect=${({ detail: r }) => {
|
|
1313
|
+
this.inputText = r.prompt, requestAnimationFrame(() => {
|
|
1283
1314
|
this.inputEl.value?.focusTextArea();
|
|
1284
1315
|
});
|
|
1285
|
-
}} ${A(this.assistantEl)}><div slot=header-actions-start class="header-actions"><calcite-icon icon=effects></calcite-icon></div><form slot=chat-entry class="chat-entry" @submit=${(
|
|
1286
|
-
|
|
1316
|
+
}} ${A(this.assistantEl)}><div slot=header-actions-start class="header-actions"><calcite-icon icon=effects></calcite-icon></div><form slot=chat-entry class="chat-entry" @submit=${(r) => {
|
|
1317
|
+
r.preventDefault();
|
|
1287
1318
|
const p = e.trim();
|
|
1288
1319
|
p && (this.assistantEl.value?.submitMessage(p), this.inputText = "");
|
|
1289
|
-
}} ${A(this.formEl)}><arcgis-portal-mentionable-text-area .portal=${
|
|
1290
|
-
|
|
1291
|
-
}} @arcgisUserMentionableTextAreaChange=${({ detail:
|
|
1292
|
-
this.inputText =
|
|
1320
|
+
}} ${A(this.formEl)}><arcgis-portal-mentionable-text-area .portal=${s} .user=${o} rows=3 .popoverListLabel=${t.mentionEntities} .placeholder=${t.placeholder} .value=${e} @arcgisUserMentionableTextAreaKeyDown=${({ detail: r }) => {
|
|
1321
|
+
r.key === "Enter" && !r.shiftKey && (r.preventDefault(), this.formEl.value?.requestSubmit());
|
|
1322
|
+
}} @arcgisUserMentionableTextAreaChange=${({ detail: r }) => {
|
|
1323
|
+
this.inputText = r ?? "";
|
|
1293
1324
|
}} ${A(this.inputEl)}></arcgis-portal-mentionable-text-area><div class="chat-actions"><arcgis-portal-voice-input @arcgisVoiceInputStart=${() => {
|
|
1294
1325
|
this.isListening = !0, this.isVoiceInputDisabled = !1;
|
|
1295
1326
|
}} @arcgisVoiceInputStop=${() => {
|
|
1296
1327
|
this.isListening = !1, this.isVoiceInputDisabled = !1;
|
|
1297
|
-
}} @arcgisVoiceInputError=${(
|
|
1298
|
-
|
|
1299
|
-
}} @arcgisVoiceInputInterimTranscription=${(
|
|
1300
|
-
this.inputText =
|
|
1301
|
-
}} ${A(this.voiceInputEl)}></arcgis-portal-voice-input>${
|
|
1328
|
+
}} @arcgisVoiceInputError=${(r) => {
|
|
1329
|
+
r.detail.errorCode === "not-supported" && (this.showVoiceInput = !1);
|
|
1330
|
+
}} @arcgisVoiceInputInterimTranscription=${(r) => {
|
|
1331
|
+
this.inputText = r.detail.text;
|
|
1332
|
+
}} ${A(this.voiceInputEl)}></arcgis-portal-voice-input>${c && M`<calcite-button icon-start=microphone .label=${t.voiceInput} round .disabled=${u} .appearance=${i ? "solid" : "outline-fill"} @click=${async () => {
|
|
1302
1333
|
this.isVoiceInputDisabled = !0;
|
|
1303
|
-
const
|
|
1304
|
-
|
|
1305
|
-
}}></calcite-button>` || ""}<calcite-button type=submit icon-start=send round .disabled=${!e.trim()} .label=${t.send}>${t.send}</calcite-button></div></form><arcgis-assistant-agent .agent=${Be} .context=${{ portal:
|
|
1306
|
-
this.assistantEl.value?.submitInterrupt(
|
|
1334
|
+
const r = this.voiceInputEl.value;
|
|
1335
|
+
i ? await r?.stopListening() : await r?.startListening();
|
|
1336
|
+
}}></calcite-button>` || ""}<calcite-button type=submit icon-start=send round .disabled=${!e.trim()} .label=${t.send}>${t.send}</calcite-button></div></form><arcgis-assistant-agent .agent=${Be} .context=${{ portal: s, user: o, navigationTargetMap: l }}></arcgis-assistant-agent><arcgis-assistant-agent .agent=${Jt} .context=${{ portal: s, user: o, navigationTargetMap: l }}></arcgis-assistant-agent><arcgis-assistant-agent .agent=${pe} .context=${{ portal: s, user: o, navigationTargetMap: l }}></arcgis-assistant-agent><arcgis-assistant-agent .agent=${ze} .context=${{ portal: s, user: o, navigationTargetMap: l }}></arcgis-assistant-agent>${this.interrupt && M`<arcgis-portal-ai-assistant-interrupt slot=interrupt .type=${this.interrupt.type} .message=${this.interrupt.message} .options=${this.interrupt.options} @arcgisSubmit=${({ detail: r }) => {
|
|
1337
|
+
this.assistantEl.value?.submitInterrupt(r);
|
|
1307
1338
|
}} @arcgisCancel=${() => {
|
|
1308
1339
|
this.assistantEl.value?.cancelInterrupt();
|
|
1309
1340
|
}}></arcgis-portal-ai-assistant-interrupt>` || ""}</arcgis-assistant>`;
|
|
1310
1341
|
}
|
|
1311
1342
|
}
|
|
1312
|
-
|
|
1343
|
+
pt("arcgis-portal-ai-assistant", We);
|
|
1313
1344
|
export {
|
|
1314
1345
|
We as ArcgisPortalAiAssistant
|
|
1315
1346
|
};
|