@arcgis/portal-components 5.2.0-next.86 → 5.2.0-next.87
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/{GADH24KO.js → 25KISBCS.js} +1 -1
- package/dist/cdn/2TQ4B2LU.js +2 -0
- package/dist/cdn/4GRTJ7XT.js +2 -0
- package/dist/cdn/{ZAB6B2B6.js → 5EMPEJ65.js} +1 -1
- package/dist/cdn/C7XKSVMU.js +2 -0
- package/dist/cdn/{DHWAQSKG.js → F3LFFR3K.js} +1 -1
- package/dist/cdn/F3M3R7X2.js +2 -0
- package/dist/cdn/{CD2GV5YW.js → F76RXJ66.js} +1 -1
- package/dist/cdn/FQTFZLHT.js +2 -0
- package/dist/cdn/KYNL256E.js +2 -0
- package/dist/cdn/{NASFEWDT.js → LDYOCDG6.js} +1 -1
- package/dist/cdn/{LRADZ46B.js → NQQLTGIK.js} +1 -1
- package/dist/cdn/{R5MGNFM2.js → PMQCCLS5.js} +1 -1
- package/dist/cdn/QTKBB22S.js +2 -0
- package/dist/cdn/SYDYG3CL.js +2 -0
- package/dist/cdn/{TUBYAQ6R.js → X5B4PAML.js} +1 -1
- package/dist/cdn/{ECA5GSSU.js → X6XTK2TE.js} +1 -1
- package/dist/cdn/{6BALICUQ.js → Y56BS6IQ.js} +52 -52
- package/dist/cdn/YBWCEZJP.js +2 -0
- package/dist/cdn/assets/portal-account-switcher/t9n/messages.en.json +1 -1
- package/dist/cdn/index.js +1 -1
- package/dist/chunks/fieldAddDelete.js +1 -1
- package/dist/chunks/groups2.js +1 -1
- package/dist/chunks/item2.js +1 -1
- package/dist/chunks/portal-account-switcher.js +3 -3
- package/dist/chunks/portal.js +2 -2
- package/dist/chunks/portal2.js +1 -1
- package/dist/chunks/request.js +1 -1
- package/dist/chunks/services.js +17 -0
- package/dist/chunks/user.js +1 -1
- package/dist/chunks/utils.js +4 -4
- package/dist/components/arcgis-portal-account-switcher/customElement.d.ts +22 -2
- package/dist/components/arcgis-portal-account-switcher/customElement.js +211 -207
- package/dist/components/arcgis-portal-account-switcher/index.js +1 -3
- package/dist/components/arcgis-portal-account-switcher/types.d.ts +6 -0
- package/dist/components/arcgis-portal-account-switcher-accounts/customElement.d.ts +20 -2
- package/dist/components/arcgis-portal-account-switcher-accounts/customElement.js +5 -5
- package/dist/components/arcgis-portal-account-switcher-list/customElement.d.ts +22 -4
- package/dist/components/arcgis-portal-account-switcher-list/customElement.js +58 -37
- package/dist/components/arcgis-portal-account-switcher-list/index.js +2 -3
- package/dist/components/arcgis-portal-ai-assistant/agents/portalRouteKeys.d.ts +25 -16
- package/dist/components/arcgis-portal-ai-assistant/agents/types.d.ts +4 -4
- package/dist/components/arcgis-portal-ai-assistant/customElement.js +611 -603
- package/dist/components/arcgis-portal-field-delete/customElement.js +1 -1
- package/dist/components/arcgis-portal-group-browser/customElement.js +1 -1
- package/dist/components/arcgis-portal-group-thumbnail/customElement.js +1 -1
- package/dist/components/arcgis-portal-navigation/customElement.js +1 -2
- package/dist/components/arcgis-portal-user-avatar/customElement.js +25 -36
- package/dist/components/arcgis-portal-user-popup/customElement.js +27 -27
- 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 +4 -4
- package/dist/types/lumina.d.ts +2 -2
- package/dist/types/preact.d.ts +2 -2
- package/dist/types/react.d.ts +2 -2
- package/dist/types/stencil.d.ts +2 -2
- package/dist/types/user.d.ts +1 -1
- package/package.json +7 -7
- package/dist/cdn/5MVBQWW3.js +0 -2
- package/dist/cdn/76A6NXMY.js +0 -2
- package/dist/cdn/E4D3U6ZA.js +0 -2
- package/dist/cdn/J57ZXL3U.js +0 -2
- package/dist/cdn/OAKVCMNN.js +0 -2
- package/dist/cdn/QREMLELA.js +0 -2
- package/dist/cdn/SOJ5KMMZ.js +0 -2
- package/dist/cdn/V6N5BWDA.js +0 -2
|
@@ -1,30 +1,30 @@
|
|
|
1
1
|
/* COPYRIGHT Esri - https://js.arcgis.com/5.2/LICENSE.txt */
|
|
2
|
-
import { c as
|
|
3
|
-
import { LitElement as
|
|
4
|
-
import { css as
|
|
2
|
+
import { c as De } from "../../chunks/runtime.js";
|
|
3
|
+
import { LitElement as Ue, createEvent as Fe } from "@arcgis/lumina";
|
|
4
|
+
import { css as Oe, render as Le, html as b } from "lit";
|
|
5
5
|
import { createRef as P, ref as q } from "lit/directives/ref.js";
|
|
6
|
-
import { u as
|
|
7
|
-
import { NodeInterrupt as
|
|
8
|
-
import { sendTraceMessage as m, invokeStructuredPrompt as
|
|
6
|
+
import { u as je } from "../../chunks/useT9n.js";
|
|
7
|
+
import { NodeInterrupt as fe, Annotation as h, StateGraph as A, START as N, END as w } from "@langchain/langgraph/web";
|
|
8
|
+
import { sendTraceMessage as m, invokeStructuredPrompt as v, sendUXSuggestion as Q, createAgentRuntimeStateWithSharedState as G, createChatModel as W, getEmbeddings as Ve } from "@arcgis/ai-components/utils/index.js";
|
|
9
9
|
import s from "zod";
|
|
10
|
-
import { a as
|
|
11
|
-
import
|
|
10
|
+
import { a as Be, c as Ke, q as Qe } from "../../chunks/groups2.js";
|
|
11
|
+
import We from "@arcgis/core/identity/IdentityManager.js";
|
|
12
12
|
import H from "@arcgis/core/request.js";
|
|
13
|
-
import { a as
|
|
13
|
+
import { a as R, t as Je, b as B } from "../../chunks/functionalities.js";
|
|
14
14
|
import { ChatPromptTemplate as J } from "@langchain/core/prompts";
|
|
15
|
-
import { tool as
|
|
16
|
-
import { s as
|
|
17
|
-
import { g as
|
|
18
|
-
import
|
|
19
|
-
const
|
|
20
|
-
const { portal:
|
|
21
|
-
return !!
|
|
15
|
+
import { tool as ye } from "@langchain/core/tools";
|
|
16
|
+
import { s as _e, a as Ye } from "../../chunks/item.js";
|
|
17
|
+
import { g as He, e as Xe, i as Ze, c as et, a as tt } from "../../chunks/groups.js";
|
|
18
|
+
import at from "@arcgis/core/portal/Portal.js";
|
|
19
|
+
const we = (e) => {
|
|
20
|
+
const { portal: t, user: a } = e ?? {};
|
|
21
|
+
return !!e && !!t && !!a;
|
|
22
22
|
};
|
|
23
|
-
function T(
|
|
24
|
-
if (!
|
|
23
|
+
function T(e) {
|
|
24
|
+
if (!we(e))
|
|
25
25
|
throw new Error("Invalid context: PortalAssistantContext with portal and user is required.");
|
|
26
26
|
}
|
|
27
|
-
const
|
|
27
|
+
const nt = `
|
|
28
28
|
Write a concise, friendly success message for adding members to a group.
|
|
29
29
|
|
|
30
30
|
Rules:
|
|
@@ -39,21 +39,21 @@ Added members:
|
|
|
39
39
|
|
|
40
40
|
Not added members:
|
|
41
41
|
{notAddedMembers}
|
|
42
|
-
`,
|
|
42
|
+
`, ot = (e) => e.map((t) => `"${t}"`).join(", "), rt = s.object({
|
|
43
43
|
successMessage: s.string().default("")
|
|
44
|
-
}), X = "portal-group-creation", Z = "approveAddMembers",
|
|
45
|
-
if (
|
|
44
|
+
}), X = "portal-group-creation", Z = "approveAddMembers", st = async (e, t) => {
|
|
45
|
+
if (e.intentParams.intent !== "addMembers")
|
|
46
46
|
return {
|
|
47
47
|
status: "success",
|
|
48
48
|
outputMessage: "Use @mention usernames for the members you want to add."
|
|
49
49
|
};
|
|
50
|
-
const a =
|
|
50
|
+
const a = e.agentExecutionContext.sharedState.createdGroupId?.value;
|
|
51
51
|
if (!a)
|
|
52
52
|
return {
|
|
53
53
|
status: "success",
|
|
54
54
|
outputMessage: "Create a group first, then add members using @mention usernames."
|
|
55
55
|
};
|
|
56
|
-
const n =
|
|
56
|
+
const n = e.intentParams.memberInfo.memberIdentifiers.map((p) => p.trim()).filter(Boolean);
|
|
57
57
|
if (!n.length)
|
|
58
58
|
return {
|
|
59
59
|
status: "success",
|
|
@@ -64,7 +64,7 @@ Not added members:
|
|
|
64
64
|
${n.map((p) => `- **@${p}**`).join(`
|
|
65
65
|
`)}
|
|
66
66
|
|
|
67
|
-
Do you want to continue?`, { hitlResponse: c } =
|
|
67
|
+
Do you want to continue?`, { hitlResponse: c } = t?.configurable ?? {};
|
|
68
68
|
if (c?.agentId !== X || c.id !== Z) {
|
|
69
69
|
const p = {
|
|
70
70
|
agentId: X,
|
|
@@ -77,7 +77,7 @@ Do you want to continue?`, { hitlResponse: c } = e?.configurable ?? {};
|
|
|
77
77
|
members: [...n]
|
|
78
78
|
}
|
|
79
79
|
};
|
|
80
|
-
throw new
|
|
80
|
+
throw new fe(p);
|
|
81
81
|
}
|
|
82
82
|
if (c.payload !== !0)
|
|
83
83
|
return {
|
|
@@ -85,12 +85,12 @@ Do you want to continue?`, { hitlResponse: c } = e?.configurable ?? {};
|
|
|
85
85
|
outputMessage: "Okay, I cancelled adding members to the group."
|
|
86
86
|
};
|
|
87
87
|
await m(
|
|
88
|
-
{ text: `Adding members ${
|
|
89
|
-
|
|
88
|
+
{ text: `Adding members ${ot(n)}...`, agentName: "group-creation" },
|
|
89
|
+
t
|
|
90
90
|
);
|
|
91
|
-
const i =
|
|
91
|
+
const i = t?.configurable?.context;
|
|
92
92
|
T(i);
|
|
93
|
-
const { result: l, error: u } = await
|
|
93
|
+
const { result: l, error: u } = await Be(i.portal, a, n);
|
|
94
94
|
if (u || !l)
|
|
95
95
|
return {
|
|
96
96
|
status: "success",
|
|
@@ -98,9 +98,9 @@ Do you want to continue?`, { hitlResponse: c } = e?.configurable ?? {};
|
|
|
98
98
|
};
|
|
99
99
|
const { addedUsernames: d, notAddedUsers: g } = l;
|
|
100
100
|
try {
|
|
101
|
-
const f = (await
|
|
102
|
-
promptText:
|
|
103
|
-
schema:
|
|
101
|
+
const f = (await v({
|
|
102
|
+
promptText: nt,
|
|
103
|
+
schema: rt,
|
|
104
104
|
modelTier: "fast",
|
|
105
105
|
inputVariables: {
|
|
106
106
|
addedMembers: d.join(", "),
|
|
@@ -115,7 +115,7 @@ Do you want to continue?`, { hitlResponse: c } = e?.configurable ?? {};
|
|
|
115
115
|
console.error("Error generating add-members success message:", p);
|
|
116
116
|
}
|
|
117
117
|
return {};
|
|
118
|
-
},
|
|
118
|
+
}, it = `
|
|
119
119
|
Write a concise, friendly success message after creating a portal group.
|
|
120
120
|
|
|
121
121
|
Rules:
|
|
@@ -126,7 +126,7 @@ Rules:
|
|
|
126
126
|
|
|
127
127
|
Group title:
|
|
128
128
|
{groupTitle}
|
|
129
|
-
`,
|
|
129
|
+
`, ct = `
|
|
130
130
|
Write a concise, friendly failure message after an attempt to create a portal group.
|
|
131
131
|
|
|
132
132
|
Rules:
|
|
@@ -141,27 +141,27 @@ Group title:
|
|
|
141
141
|
|
|
142
142
|
Failure reason:
|
|
143
143
|
{failureReason}
|
|
144
|
-
`,
|
|
144
|
+
`, ee = "portal-group-creation", te = "approveCreateGroup", ut = s.object({
|
|
145
145
|
successMessage: s.string().default("")
|
|
146
|
-
}),
|
|
146
|
+
}), lt = s.object({
|
|
147
147
|
failureMessage: s.string().default("")
|
|
148
|
-
}),
|
|
149
|
-
if (
|
|
148
|
+
}), dt = async (e, t) => {
|
|
149
|
+
if (e.intentParams.intent !== "create")
|
|
150
150
|
return {
|
|
151
151
|
status: "success",
|
|
152
152
|
outputMessage: "Tell me the group title you want to use."
|
|
153
153
|
};
|
|
154
|
-
const a =
|
|
154
|
+
const a = e.intentParams.title.trim();
|
|
155
155
|
if (!a)
|
|
156
156
|
return {
|
|
157
157
|
status: "success",
|
|
158
158
|
outputMessage: "What title would you like for the new group?"
|
|
159
159
|
};
|
|
160
|
-
const n = `A group with the title **${a}** will be created. Do you want to continue?`, { hitlResponse: o } =
|
|
161
|
-
if (o?.agentId !==
|
|
160
|
+
const n = `A group with the title **${a}** will be created. Do you want to continue?`, { hitlResponse: o } = t?.configurable;
|
|
161
|
+
if (o?.agentId !== ee || o.id !== te) {
|
|
162
162
|
const u = {
|
|
163
|
-
agentId:
|
|
164
|
-
id:
|
|
163
|
+
agentId: ee,
|
|
164
|
+
id: te,
|
|
165
165
|
kind: "booleanChoice",
|
|
166
166
|
message: n,
|
|
167
167
|
metadata: {
|
|
@@ -170,26 +170,26 @@ Failure reason:
|
|
|
170
170
|
access: "private"
|
|
171
171
|
}
|
|
172
172
|
};
|
|
173
|
-
throw new
|
|
173
|
+
throw new fe(u);
|
|
174
174
|
}
|
|
175
175
|
if (o.payload !== !0)
|
|
176
176
|
return {
|
|
177
177
|
status: "success",
|
|
178
178
|
outputMessage: `Okay, I cancelled creating **${a}**.`
|
|
179
179
|
};
|
|
180
|
-
await m({ text: `Creating group "${a}"...`, agentName: "group-creation" },
|
|
181
|
-
const r =
|
|
180
|
+
await m({ text: `Creating group "${a}"...`, agentName: "group-creation" }, t);
|
|
181
|
+
const r = t?.configurable?.context;
|
|
182
182
|
T(r);
|
|
183
|
-
const { result: c, error: i } = await
|
|
183
|
+
const { result: c, error: i } = await Ke(r.portal, {
|
|
184
184
|
title: a,
|
|
185
185
|
access: "private"
|
|
186
186
|
});
|
|
187
187
|
if (i || !c) {
|
|
188
188
|
const u = i?.message?.trim() || "No additional details were provided.";
|
|
189
189
|
try {
|
|
190
|
-
const g = (await
|
|
191
|
-
promptText:
|
|
192
|
-
schema:
|
|
190
|
+
const g = (await v({
|
|
191
|
+
promptText: ct,
|
|
192
|
+
schema: lt,
|
|
193
193
|
modelTier: "fast",
|
|
194
194
|
inputVariables: {
|
|
195
195
|
groupTitle: a,
|
|
@@ -211,9 +211,9 @@ Failure reason:
|
|
|
211
211
|
}
|
|
212
212
|
const l = c.id;
|
|
213
213
|
try {
|
|
214
|
-
const d = (await
|
|
215
|
-
promptText:
|
|
216
|
-
schema:
|
|
214
|
+
const d = (await v({
|
|
215
|
+
promptText: it,
|
|
216
|
+
schema: ut,
|
|
217
217
|
modelTier: "fast",
|
|
218
218
|
inputVariables: {
|
|
219
219
|
groupTitle: a
|
|
@@ -230,9 +230,9 @@ Failure reason:
|
|
|
230
230
|
console.error("Error generating create-group success message:", u);
|
|
231
231
|
}
|
|
232
232
|
return {};
|
|
233
|
-
}, I = (
|
|
234
|
-
for (let
|
|
235
|
-
const a = t
|
|
233
|
+
}, I = (e) => {
|
|
234
|
+
for (let t = e.length - 1; t >= 0; t -= 1) {
|
|
235
|
+
const a = e[t];
|
|
236
236
|
if (a.type !== "human")
|
|
237
237
|
continue;
|
|
238
238
|
const n = a.content;
|
|
@@ -244,7 +244,7 @@ Failure reason:
|
|
|
244
244
|
).join(" ").trim();
|
|
245
245
|
}
|
|
246
246
|
return "";
|
|
247
|
-
},
|
|
247
|
+
}, pt = `
|
|
248
248
|
You classify whether a user is asking to create a new ArcGIS Portal group or add members to an existing group.
|
|
249
249
|
|
|
250
250
|
Rules:
|
|
@@ -270,16 +270,16 @@ Examples:
|
|
|
270
270
|
|
|
271
271
|
User message:
|
|
272
272
|
{userMessage}
|
|
273
|
-
`,
|
|
273
|
+
`, mt = s.object({
|
|
274
274
|
intent: s.enum(["clarify", "create", "addMembers"]).default("clarify"),
|
|
275
275
|
title: s.string().default(""),
|
|
276
276
|
memberIdentifiers: s.array(s.string()).default([]),
|
|
277
277
|
clarifyMessage: s.string().default("")
|
|
278
|
-
}),
|
|
279
|
-
await m({ text: "Thinking about groups...", agentName: "group-creation" },
|
|
280
|
-
const a = I(
|
|
281
|
-
promptText:
|
|
282
|
-
schema:
|
|
278
|
+
}), gt = async (e, t) => {
|
|
279
|
+
await m({ text: "Thinking about groups...", agentName: "group-creation" }, t);
|
|
280
|
+
const a = I(e.agentExecutionContext.messages).trim(), n = await v({
|
|
281
|
+
promptText: pt,
|
|
282
|
+
schema: mt,
|
|
283
283
|
modelTier: "default",
|
|
284
284
|
inputVariables: { userMessage: a }
|
|
285
285
|
}), o = n.title.trim(), r = n.memberIdentifiers.filter(Boolean), c = n.clarifyMessage.trim(), i = n.intent === "create" && !!o, l = n.intent === "addMembers" && r.length > 0;
|
|
@@ -288,78 +288,88 @@ User message:
|
|
|
288
288
|
status: "success",
|
|
289
289
|
outputMessage: !i && !l ? c : ""
|
|
290
290
|
};
|
|
291
|
-
},
|
|
292
|
-
"
|
|
293
|
-
"
|
|
294
|
-
"
|
|
295
|
-
"
|
|
296
|
-
"
|
|
297
|
-
"
|
|
298
|
-
|
|
299
|
-
|
|
300
|
-
|
|
301
|
-
|
|
302
|
-
|
|
303
|
-
|
|
304
|
-
|
|
305
|
-
|
|
291
|
+
}, ht = [
|
|
292
|
+
"general",
|
|
293
|
+
"about",
|
|
294
|
+
"homePage",
|
|
295
|
+
"gallery",
|
|
296
|
+
"aiAssistants",
|
|
297
|
+
"map",
|
|
298
|
+
"items",
|
|
299
|
+
"groups",
|
|
300
|
+
"webhooks",
|
|
301
|
+
"utilityServices",
|
|
302
|
+
"agol",
|
|
303
|
+
"esriContent",
|
|
304
|
+
"livingAtlas",
|
|
305
|
+
"servers",
|
|
306
|
+
"memberRoles",
|
|
307
|
+
"newMemberDefaults",
|
|
308
|
+
"marketplace",
|
|
309
|
+
"collaborations",
|
|
310
|
+
"credits",
|
|
311
|
+
"security",
|
|
312
|
+
"openData",
|
|
313
|
+
"hub",
|
|
314
|
+
"orgExtensions"
|
|
315
|
+
], ft = ["newItem", "createLayer", "developerCredentials"], yt = ["favorites", "group", "living-atlas", "org"], wt = ["featured", "my", "organization"], bt = ["licenses", "members", "overview", "reports", "settings", "status"], vt = s.object({
|
|
306
316
|
destinationType: s.literal("portal-content"),
|
|
307
|
-
hash: s.enum(
|
|
317
|
+
hash: s.enum(yt).optional(),
|
|
308
318
|
queryParams: s.object({
|
|
309
|
-
newItem: s.enum(
|
|
319
|
+
newItem: s.enum(ft).optional()
|
|
310
320
|
}).optional()
|
|
311
|
-
}),
|
|
321
|
+
}), It = s.object({
|
|
312
322
|
destinationType: s.literal("portal-groups"),
|
|
313
|
-
hash: s.enum(
|
|
314
|
-
}),
|
|
323
|
+
hash: s.enum(wt).optional()
|
|
324
|
+
}), St = s.object({
|
|
315
325
|
destinationType: s.literal("portal-org"),
|
|
316
|
-
hash: s.enum(
|
|
326
|
+
hash: s.enum(bt).optional(),
|
|
317
327
|
queryParams: s.object({
|
|
318
|
-
tab: s.
|
|
319
|
-
section: s.
|
|
320
|
-
subsection: s.
|
|
328
|
+
tab: s.enum(ht).optional(),
|
|
329
|
+
section: s.string().optional(),
|
|
330
|
+
subsection: s.string().optional(),
|
|
321
331
|
period: s.string().optional(),
|
|
322
332
|
startTime: s.string().optional(),
|
|
323
333
|
endTime: s.string().optional()
|
|
324
334
|
}).optional()
|
|
325
|
-
}),
|
|
335
|
+
}), xt = s.object({
|
|
326
336
|
destinationType: s.literal("portal-item"),
|
|
327
337
|
itemId: s.string().trim().min(1)
|
|
328
|
-
}),
|
|
338
|
+
}), Tt = s.object({
|
|
329
339
|
destinationType: s.literal("portal-group"),
|
|
330
340
|
groupId: s.string().trim().min(1)
|
|
331
|
-
}),
|
|
341
|
+
}), Mt = s.object({
|
|
332
342
|
destinationType: s.union([
|
|
333
343
|
s.literal("portal-gallery"),
|
|
334
344
|
s.literal("portal-map-viewer"),
|
|
335
345
|
s.literal("portal-notebooks"),
|
|
336
346
|
s.literal("portal-scene-viewer")
|
|
337
347
|
])
|
|
338
|
-
}),
|
|
339
|
-
|
|
340
|
-
|
|
341
|
-
|
|
342
|
-
|
|
343
|
-
|
|
344
|
-
|
|
345
|
-
]),
|
|
346
|
-
const a =
|
|
347
|
-
!
|
|
348
|
-
},
|
|
349
|
-
const a =
|
|
350
|
-
return a ? (await m({ text: "Preparing navigation...", agentName: "group-creation" },
|
|
351
|
-
},
|
|
348
|
+
}), Ct = s.union([
|
|
349
|
+
vt,
|
|
350
|
+
It,
|
|
351
|
+
St,
|
|
352
|
+
xt,
|
|
353
|
+
Tt,
|
|
354
|
+
Mt
|
|
355
|
+
]), be = "portal-navigation", D = async (e, t) => {
|
|
356
|
+
const a = t?.configurable?.context;
|
|
357
|
+
!we(a) || !a.navigationTargetMap?.[e.destinationType] || await Q({ type: be, data: { ...e } }, t);
|
|
358
|
+
}, At = async (e, t) => {
|
|
359
|
+
const a = e.createdGroupId ?? e.agentExecutionContext.sharedState.createdGroupId?.value;
|
|
360
|
+
return a ? (await m({ text: "Preparing navigation...", agentName: "group-creation" }, t), await D({ destinationType: "portal-group", groupId: a }, t), {}) : {};
|
|
361
|
+
}, ae = (e, t) => t ?? e, ve = h.Root({
|
|
352
362
|
...G(),
|
|
353
363
|
// * Shared state between nodes (but not persisted to the agent execution context)
|
|
354
364
|
/** Parameters related to the user's intent for group creation actions */
|
|
355
|
-
intentParams: h({ reducer:
|
|
365
|
+
intentParams: h({ reducer: ae, default: () => ({ intent: "clarify" }) }),
|
|
356
366
|
/** The ID of the group that was created
|
|
357
367
|
* even though we already have this in the shared state
|
|
358
368
|
* we still need it here to also share between nodes
|
|
359
369
|
*/
|
|
360
|
-
createdGroupId: h({ reducer:
|
|
361
|
-
}),
|
|
362
|
-
switch (
|
|
370
|
+
createdGroupId: h({ reducer: ae, default: () => "" })
|
|
371
|
+
}), Nt = () => new A(ve).addNode("detectGroupCreationIntent", gt).addNode("createPortalGroup", dt).addNode("addMembersToPortalGroup", st).addNode("suggestCreatedGroupNavigation", At).addEdge(N, "detectGroupCreationIntent").addConditionalEdges("detectGroupCreationIntent", (t) => {
|
|
372
|
+
switch (t.intentParams.intent) {
|
|
363
373
|
case "create":
|
|
364
374
|
return "createPortalGroup";
|
|
365
375
|
case "addMembers":
|
|
@@ -367,68 +377,68 @@ User message:
|
|
|
367
377
|
default:
|
|
368
378
|
return w;
|
|
369
379
|
}
|
|
370
|
-
}).addEdge("createPortalGroup", "suggestCreatedGroupNavigation").addEdge("addMembersToPortalGroup", "suggestCreatedGroupNavigation").addEdge("suggestCreatedGroupNavigation", w),
|
|
380
|
+
}).addEdge("createPortalGroup", "suggestCreatedGroupNavigation").addEdge("addMembersToPortalGroup", "suggestCreatedGroupNavigation").addEdge("suggestCreatedGroupNavigation", w), Gt = String.raw`- **portal-group-creation** - Portal group creation assistant:
|
|
371
381
|
- creates a new ArcGIS Portal group for the signed-in user
|
|
372
382
|
- adds users to the newly created group using @mention usernames
|
|
373
|
-
`,
|
|
383
|
+
`, Pt = {
|
|
374
384
|
id: "portal-group-creation",
|
|
375
385
|
name: "Portal Group Creation",
|
|
376
|
-
description:
|
|
377
|
-
createGraph:
|
|
378
|
-
workspace:
|
|
379
|
-
},
|
|
380
|
-
const
|
|
381
|
-
if (!
|
|
382
|
-
return
|
|
383
|
-
const a =
|
|
386
|
+
description: Gt,
|
|
387
|
+
createGraph: Nt,
|
|
388
|
+
workspace: ve
|
|
389
|
+
}, Ie = "portalDocAssistantMemory", qt = () => ({ conversationId: "" }), Et = (e) => {
|
|
390
|
+
const t = e?.[Ie]?.value;
|
|
391
|
+
if (!t || typeof t != "object")
|
|
392
|
+
return qt();
|
|
393
|
+
const a = t;
|
|
384
394
|
return {
|
|
385
395
|
conversationId: typeof a.conversationId == "string" ? a.conversationId : ""
|
|
386
396
|
};
|
|
387
|
-
},
|
|
388
|
-
[
|
|
389
|
-
}),
|
|
397
|
+
}, kt = (e) => ({
|
|
398
|
+
[Ie]: { value: e }
|
|
399
|
+
}), zt = {
|
|
390
400
|
pipeline: {
|
|
391
401
|
follow_up: { allow: !1 }
|
|
392
402
|
}
|
|
393
403
|
};
|
|
394
|
-
function
|
|
404
|
+
function $t(e) {
|
|
395
405
|
return {
|
|
396
406
|
kind: "DocAIAssistantRequest",
|
|
397
407
|
filters: {
|
|
398
|
-
...
|
|
399
|
-
persona: { persona:
|
|
408
|
+
...zt,
|
|
409
|
+
persona: { persona: e }
|
|
400
410
|
}
|
|
401
411
|
};
|
|
402
412
|
}
|
|
403
|
-
async function
|
|
404
|
-
portal:
|
|
405
|
-
question:
|
|
413
|
+
async function Rt({
|
|
414
|
+
portal: e,
|
|
415
|
+
question: t,
|
|
406
416
|
persona: a,
|
|
407
417
|
previousConversationId: n,
|
|
408
418
|
signal: o,
|
|
409
419
|
skillId: r
|
|
410
420
|
}) {
|
|
411
421
|
r ??= "doc_ai_assistant";
|
|
412
|
-
const c =
|
|
413
|
-
portal:
|
|
422
|
+
const c = $t(a), i = await Dt({
|
|
423
|
+
portal: e,
|
|
414
424
|
skillId: r,
|
|
415
|
-
message:
|
|
425
|
+
message: t,
|
|
416
426
|
options: { context: c, previousConversationId: n, signal: o }
|
|
417
427
|
});
|
|
418
428
|
return {
|
|
419
|
-
reply:
|
|
429
|
+
reply: Ut(i, r),
|
|
420
430
|
conversationId: i[0]?.conversationId ?? ""
|
|
421
431
|
};
|
|
422
432
|
}
|
|
423
|
-
async function
|
|
424
|
-
portal:
|
|
425
|
-
skillId:
|
|
433
|
+
async function Dt({
|
|
434
|
+
portal: e,
|
|
435
|
+
skillId: t,
|
|
426
436
|
message: a,
|
|
427
437
|
options: n
|
|
428
438
|
}) {
|
|
429
|
-
const r = `${
|
|
439
|
+
const r = `${e.helperServices.aiAssistantServices.url}/skills/${t}/chat`, c = {
|
|
430
440
|
"Content-Type": "application/json",
|
|
431
|
-
token:
|
|
441
|
+
token: We.findCredential(e.url)?.token ?? ""
|
|
432
442
|
}, i = await H(r, {
|
|
433
443
|
method: "post",
|
|
434
444
|
body: JSON.stringify({
|
|
@@ -446,7 +456,7 @@ async function Fe({
|
|
|
446
456
|
const l = i.data, u = [l], { conversationId: d, inquiryId: g } = l, p = async (f, y) => {
|
|
447
457
|
if (!y)
|
|
448
458
|
return;
|
|
449
|
-
await
|
|
459
|
+
await Je(500);
|
|
450
460
|
const S = await H(r, {
|
|
451
461
|
method: "post",
|
|
452
462
|
body: JSON.stringify({ conversationId: d, inquiryId: g, ackSequenceNumber: f }),
|
|
@@ -457,18 +467,18 @@ async function Fe({
|
|
|
457
467
|
throw new Error(`Doc assistant poll failed (${S.httpStatus})`, {
|
|
458
468
|
cause: S.data
|
|
459
469
|
});
|
|
460
|
-
const
|
|
461
|
-
u.push(
|
|
470
|
+
const M = S.data;
|
|
471
|
+
u.push(M), await p(M.sequenceNumber, M.hasMore);
|
|
462
472
|
};
|
|
463
473
|
return l.hasMore && await p(l.sequenceNumber, l.hasMore), u;
|
|
464
474
|
}
|
|
465
|
-
function
|
|
466
|
-
switch (
|
|
475
|
+
function Ut(e, t) {
|
|
476
|
+
switch (t) {
|
|
467
477
|
case "doc_chat":
|
|
468
|
-
return
|
|
478
|
+
return e.find((a) => a.message != null)?.message ?? "";
|
|
469
479
|
case "doc_ai_assistant":
|
|
470
|
-
for (let a =
|
|
471
|
-
const n =
|
|
480
|
+
for (let a = e.length - 1; a >= 0; a -= 1) {
|
|
481
|
+
const n = e[a];
|
|
472
482
|
if (n.context?.kind === "DocAIAssistantContext") {
|
|
473
483
|
const o = n.context.results?.[0]?.reply;
|
|
474
484
|
if (o)
|
|
@@ -477,20 +487,20 @@ function Oe(t, e) {
|
|
|
477
487
|
}
|
|
478
488
|
return "";
|
|
479
489
|
default:
|
|
480
|
-
return
|
|
490
|
+
return R(t);
|
|
481
491
|
}
|
|
482
492
|
}
|
|
483
|
-
const
|
|
484
|
-
await m({ text: "Asking documentation assistant...", agentName: "doc-assistant" },
|
|
485
|
-
const a = I(
|
|
493
|
+
const Ft = async (e, t) => {
|
|
494
|
+
await m({ text: "Asking documentation assistant...", agentName: "doc-assistant" }, t);
|
|
495
|
+
const a = I(e.agentExecutionContext.messages).trim();
|
|
486
496
|
if (!a)
|
|
487
497
|
return {
|
|
488
498
|
status: "success",
|
|
489
499
|
outputMessage: "Please share your question and I can help with ArcGIS and Portal documentation."
|
|
490
500
|
};
|
|
491
|
-
const n =
|
|
501
|
+
const n = t?.configurable?.context;
|
|
492
502
|
T(n);
|
|
493
|
-
const o =
|
|
503
|
+
const o = Et(e.agentExecutionContext.sharedState), { reply: r, conversationId: c } = await Rt({
|
|
494
504
|
portal: n.portal,
|
|
495
505
|
question: a,
|
|
496
506
|
previousConversationId: o.conversationId || void 0,
|
|
@@ -500,19 +510,19 @@ const Le = async (t, e) => {
|
|
|
500
510
|
return {
|
|
501
511
|
status: "success",
|
|
502
512
|
outputMessage: r.trim() || "I could not retrieve a response from the documentation assistant.",
|
|
503
|
-
sharedStatePatch:
|
|
513
|
+
sharedStatePatch: kt({
|
|
504
514
|
conversationId: c || o.conversationId
|
|
505
515
|
})
|
|
506
516
|
};
|
|
507
|
-
},
|
|
508
|
-
async ({ groupTitle:
|
|
509
|
-
const a =
|
|
517
|
+
}, Se = ye(
|
|
518
|
+
async ({ groupTitle: e }, t) => {
|
|
519
|
+
const a = e.trim();
|
|
510
520
|
if (!a)
|
|
511
521
|
return null;
|
|
512
|
-
const n =
|
|
522
|
+
const n = t?.configurable?.context;
|
|
513
523
|
T(n);
|
|
514
524
|
try {
|
|
515
|
-
return (await
|
|
525
|
+
return (await Qe(n.portal, { query: `title:${a}`, num: 1 }))?.results[0]?.id || null;
|
|
516
526
|
} catch (o) {
|
|
517
527
|
return console.error("Error searching for portal group by title:", o), null;
|
|
518
528
|
}
|
|
@@ -524,14 +534,14 @@ const Le = async (t, e) => {
|
|
|
524
534
|
groupTitle: s.string().describe("The portal group title to resolve to a group id.")
|
|
525
535
|
})
|
|
526
536
|
}
|
|
527
|
-
),
|
|
528
|
-
async ({ itemTitle:
|
|
529
|
-
const a =
|
|
537
|
+
), xe = ye(
|
|
538
|
+
async ({ itemTitle: e }, t) => {
|
|
539
|
+
const a = e.trim();
|
|
530
540
|
if (!a)
|
|
531
541
|
return null;
|
|
532
|
-
const n =
|
|
542
|
+
const n = t?.configurable?.context;
|
|
533
543
|
T(n);
|
|
534
|
-
const { result: o, error: r } = await
|
|
544
|
+
const { result: o, error: r } = await _e(n.portal, a, { num: 1 });
|
|
535
545
|
return r && console.error("Error searching for portal item by title:", r), o?.results[0]?.id || null;
|
|
536
546
|
},
|
|
537
547
|
{
|
|
@@ -542,16 +552,16 @@ const Le = async (t, e) => {
|
|
|
542
552
|
})
|
|
543
553
|
}
|
|
544
554
|
);
|
|
545
|
-
function
|
|
546
|
-
const a =
|
|
555
|
+
function C(e, t = "#") {
|
|
556
|
+
const a = e.match(new RegExp(`\\${t}"([^"]+)"`, "u"));
|
|
547
557
|
if (a?.[1])
|
|
548
558
|
return a[1].trim();
|
|
549
|
-
const n =
|
|
559
|
+
const n = e.match(new RegExp(`\\${t}([^\\s"']+)`, "u"));
|
|
550
560
|
return n?.[1] ? n[1].trim() : null;
|
|
551
561
|
}
|
|
552
|
-
function
|
|
553
|
-
const
|
|
554
|
-
const n = a, o =
|
|
562
|
+
function Ot(e) {
|
|
563
|
+
const t = B(e).flatMap((a) => {
|
|
564
|
+
const n = a, o = e[a], r = [
|
|
555
565
|
n,
|
|
556
566
|
{
|
|
557
567
|
description: o.description,
|
|
@@ -563,13 +573,13 @@ function je(t) {
|
|
|
563
573
|
}) : [];
|
|
564
574
|
return [r, ...c];
|
|
565
575
|
});
|
|
566
|
-
return Object.fromEntries(
|
|
576
|
+
return Object.fromEntries(t);
|
|
567
577
|
}
|
|
568
|
-
function
|
|
569
|
-
return Object.entries(
|
|
578
|
+
function Lt(e) {
|
|
579
|
+
return Object.entries(e).map(([t, { description: a, hints: n }]) => ` - ${t}: ${a} (hints: ${n.join(", ")})`).join(`
|
|
570
580
|
`);
|
|
571
581
|
}
|
|
572
|
-
const
|
|
582
|
+
const jt = {
|
|
573
583
|
// Example prompt: "Take me to my content"
|
|
574
584
|
"portal-content": {
|
|
575
585
|
description: "The main content page of the portal.",
|
|
@@ -703,13 +713,13 @@ const Be = {
|
|
|
703
713
|
}
|
|
704
714
|
}
|
|
705
715
|
}
|
|
706
|
-
},
|
|
716
|
+
}, Te = Ot(jt), Vt = B(Te), Bt = Lt(Te), Kt = `
|
|
707
717
|
You decide whether the assistant response should include a navigation action to ArcGIS Portal.
|
|
708
718
|
|
|
709
719
|
Given the user question and assistant response:
|
|
710
720
|
- Decide if a navigation action would help the user complete the task.
|
|
711
721
|
- If yes, choose one destinationType:
|
|
712
|
-
${
|
|
722
|
+
${Bt}
|
|
713
723
|
|
|
714
724
|
Rules:
|
|
715
725
|
- Only suggest navigation when you are highly confident the destination will help complete the user's task.
|
|
@@ -732,47 +742,47 @@ User question:
|
|
|
732
742
|
|
|
733
743
|
Assistant response:
|
|
734
744
|
{response}
|
|
735
|
-
`,
|
|
745
|
+
`, ne = s.object({
|
|
736
746
|
shouldSuggestNavigation: s.boolean().default(!1),
|
|
737
|
-
destinationType: s.enum(["none", ...
|
|
747
|
+
destinationType: s.enum(["none", ...Vt]).default("none"),
|
|
738
748
|
itemId: s.string().default(""),
|
|
739
749
|
groupId: s.string().default(""),
|
|
740
750
|
confidence: s.number().min(0).max(1).default(0)
|
|
741
|
-
}),
|
|
742
|
-
await m({ text: "Extracting navigation intent...", agentName: "doc-assistant" },
|
|
743
|
-
const a =
|
|
751
|
+
}), Qt = async (e, t) => {
|
|
752
|
+
await m({ text: "Extracting navigation intent...", agentName: "doc-assistant" }, t);
|
|
753
|
+
const a = e.outputMessage.trim();
|
|
744
754
|
if (!a)
|
|
745
755
|
return {};
|
|
746
|
-
const n = I(
|
|
756
|
+
const n = I(e.agentExecutionContext.messages).trim(), o = await J.fromTemplate(Kt).format({
|
|
747
757
|
question: n,
|
|
748
758
|
response: a
|
|
749
|
-
}), c = (await W({ modelTier: "fast" })).withStructuredOutput(
|
|
759
|
+
}), c = (await W({ modelTier: "fast" })).withStructuredOutput(ne), i = ne.parse(await c.invoke(o));
|
|
750
760
|
if (!i.shouldSuggestNavigation || i.destinationType === "none")
|
|
751
761
|
return {};
|
|
752
762
|
if (i.destinationType === "portal-item" && !i.itemId) {
|
|
753
|
-
const u =
|
|
754
|
-
u && (i.itemId = await
|
|
763
|
+
const u = C(n, "#");
|
|
764
|
+
u && (i.itemId = await xe.invoke({ itemTitle: u }, t) ?? "");
|
|
755
765
|
}
|
|
756
766
|
if (i.destinationType === "portal-group" && !i.groupId) {
|
|
757
|
-
const u =
|
|
758
|
-
u && (i.groupId = await
|
|
767
|
+
const u = C(n, "$") ?? C(n, "#");
|
|
768
|
+
u && (i.groupId = await Se.invoke({ groupTitle: u }, t) ?? "");
|
|
759
769
|
}
|
|
760
|
-
const l =
|
|
761
|
-
return l ? (await
|
|
770
|
+
const l = Wt(i);
|
|
771
|
+
return l ? (await D(l, t), {}) : {};
|
|
762
772
|
};
|
|
763
|
-
function
|
|
764
|
-
destinationType:
|
|
765
|
-
itemId:
|
|
773
|
+
function Wt({
|
|
774
|
+
destinationType: e,
|
|
775
|
+
itemId: t,
|
|
766
776
|
groupId: a
|
|
767
777
|
}) {
|
|
768
|
-
switch (
|
|
778
|
+
switch (e) {
|
|
769
779
|
case "portal-content":
|
|
770
780
|
case "portal-gallery":
|
|
771
781
|
case "portal-groups":
|
|
772
782
|
case "portal-map-viewer":
|
|
773
783
|
case "portal-notebooks":
|
|
774
784
|
case "portal-scene-viewer":
|
|
775
|
-
return { destinationType:
|
|
785
|
+
return { destinationType: e };
|
|
776
786
|
case "portal-org-security":
|
|
777
787
|
return {
|
|
778
788
|
destinationType: "portal-org",
|
|
@@ -786,7 +796,7 @@ function _e({
|
|
|
786
796
|
case "portal-content-new-item-developer-credentials":
|
|
787
797
|
return {
|
|
788
798
|
queryParams: {
|
|
789
|
-
newItem:
|
|
799
|
+
newItem: Jt[e]
|
|
790
800
|
},
|
|
791
801
|
destinationType: "portal-content"
|
|
792
802
|
};
|
|
@@ -794,82 +804,80 @@ function _e({
|
|
|
794
804
|
case "portal-content-group":
|
|
795
805
|
case "portal-content-living-atlas":
|
|
796
806
|
case "portal-content-organization":
|
|
797
|
-
return { destinationType: "portal-content", hash:
|
|
807
|
+
return { destinationType: "portal-content", hash: _t[e] };
|
|
798
808
|
case "portal-groups-featured":
|
|
799
809
|
case "portal-groups-my":
|
|
800
810
|
case "portal-groups-organization":
|
|
801
|
-
return { destinationType: "portal-groups", hash:
|
|
811
|
+
return { destinationType: "portal-groups", hash: Yt[e] };
|
|
802
812
|
case "portal-org-security-custom-sign-in":
|
|
803
813
|
case "portal-org-security-logins":
|
|
804
814
|
case "portal-org-security-change-login-provider":
|
|
805
815
|
case "portal-org-security-multifactor-auth":
|
|
806
816
|
case "portal-org-security-multifactor-enforcement":
|
|
807
817
|
case "portal-org-security-multifactor-designated-admins":
|
|
808
|
-
const n = Ze[t];
|
|
809
818
|
return {
|
|
810
819
|
destinationType: "portal-org",
|
|
811
820
|
hash: "settings",
|
|
812
821
|
queryParams: {
|
|
813
822
|
tab: "security",
|
|
814
|
-
|
|
815
|
-
subsection: n
|
|
823
|
+
subsection: Ht[e]
|
|
816
824
|
}
|
|
817
825
|
};
|
|
818
826
|
case "portal-item":
|
|
819
|
-
return
|
|
827
|
+
return t ? { destinationType: e, itemId: t } : null;
|
|
820
828
|
case "portal-group":
|
|
821
|
-
return a ? { destinationType:
|
|
829
|
+
return a ? { destinationType: e, groupId: a } : null;
|
|
822
830
|
case "none":
|
|
823
831
|
return null;
|
|
824
832
|
default:
|
|
825
|
-
return
|
|
833
|
+
return R(e);
|
|
826
834
|
}
|
|
827
835
|
}
|
|
828
|
-
const
|
|
836
|
+
const Jt = {
|
|
829
837
|
"portal-content-new-item": "newItem",
|
|
830
838
|
"portal-content-new-item-feature-layer": "createLayer",
|
|
831
839
|
"portal-content-new-item-developer-credentials": "developerCredentials"
|
|
832
|
-
},
|
|
840
|
+
}, _t = {
|
|
833
841
|
"portal-content-favorites": "favorites",
|
|
834
842
|
"portal-content-group": "group",
|
|
835
843
|
"portal-content-living-atlas": "living-atlas",
|
|
836
844
|
"portal-content-organization": "org"
|
|
837
|
-
},
|
|
845
|
+
}, Yt = {
|
|
838
846
|
"portal-groups-featured": "featured",
|
|
839
847
|
"portal-groups-my": "my",
|
|
840
848
|
"portal-groups-organization": "organization"
|
|
841
|
-
},
|
|
849
|
+
}, Ht = {
|
|
842
850
|
"portal-org-security-custom-sign-in": "customSignInSection",
|
|
843
851
|
"portal-org-security-logins": "loginsSection",
|
|
844
852
|
"portal-org-security-change-login-provider": "changeLoginProviderSection",
|
|
845
853
|
"portal-org-security-multifactor-auth": "multiFactorAuthSection",
|
|
846
854
|
"portal-org-security-multifactor-enforcement": "multifactorEnforcementSection",
|
|
847
855
|
"portal-org-security-multifactor-designated-admins": "multifactorDesignatedAdminsSection"
|
|
848
|
-
},
|
|
856
|
+
}, Me = h.Root({
|
|
849
857
|
...G()
|
|
850
|
-
}),
|
|
858
|
+
}), Xt = () => new A(Me).addNode("answerDocQuestion", Ft).addNode("extractNavigationIntent", Qt).addEdge(N, "answerDocQuestion").addEdge("answerDocQuestion", "extractNavigationIntent").addEdge("extractNavigationIntent", w), Zt = String.raw`- **portal-doc-assistant** - General ArcGIS documentation and Portal help assistant:
|
|
851
859
|
- answers general ArcGIS, Portal, Enterprise, and JavaScript SDK questions
|
|
852
860
|
- acts as a fallback when specialized agents are not applicable
|
|
853
|
-
`,
|
|
861
|
+
`, ea = {
|
|
854
862
|
id: "portal-doc-assistant",
|
|
855
863
|
name: "Portal Doc Assistant",
|
|
856
|
-
description:
|
|
857
|
-
createGraph:
|
|
858
|
-
workspace:
|
|
859
|
-
},
|
|
860
|
-
const
|
|
861
|
-
return
|
|
862
|
-
},
|
|
864
|
+
description: Zt,
|
|
865
|
+
createGraph: Xt,
|
|
866
|
+
workspace: Me
|
|
867
|
+
}, ta = () => ({ latestGroupId: null, memory: {} }), U = (e) => {
|
|
868
|
+
const t = e?.agentExecutionContext.sharedState.portalGroupSummaryMemory?.value;
|
|
869
|
+
return t ? { latestGroupId: t.latestGroupId, memory: t.memory } : ta();
|
|
870
|
+
}, Ce = `
|
|
863
871
|
Shared markdown formatting rules:
|
|
864
872
|
- Use clear markdown headings (##) to separate sections.
|
|
865
873
|
- Use concise bullet points for lists of facts, counts, or signals.
|
|
866
874
|
- Emphasize key metrics with bold labels (for example: **Recent items:** 4).
|
|
867
875
|
- Keep wording direct and analytical; avoid filler language but make sure the language is friendly.
|
|
868
876
|
- Do not include raw internal IDs unless explicitly requested.
|
|
869
|
-
`,
|
|
877
|
+
`, aa = `
|
|
870
878
|
You answer follow-up questions about ArcGIS group analytics.
|
|
871
879
|
|
|
872
|
-
${
|
|
880
|
+
${Ce}
|
|
873
881
|
|
|
874
882
|
Ground your answer in the provided group analytics summary and context.
|
|
875
883
|
If the answer is not available from the provided context, state that clearly and suggest what to check next.
|
|
@@ -891,14 +899,14 @@ Group full context:
|
|
|
891
899
|
|
|
892
900
|
Question:
|
|
893
901
|
{question}
|
|
894
|
-
`,
|
|
895
|
-
await m({ text: "Answering group follow-up...", agentName: "group-analytics" },
|
|
896
|
-
const a = U(
|
|
902
|
+
`, na = async (e, t) => {
|
|
903
|
+
await m({ text: "Answering group follow-up...", agentName: "group-analytics" }, t);
|
|
904
|
+
const a = U(e), n = e.groupSummaryGroupId ?? a.latestGroupId, o = n ? a.memory[n] : void 0, r = e.groupSummaryQuestion || I(e.agentExecutionContext.messages);
|
|
897
905
|
return o ? {
|
|
898
906
|
status: "success",
|
|
899
|
-
outputMessage: (await
|
|
900
|
-
promptText:
|
|
901
|
-
schema:
|
|
907
|
+
outputMessage: (await v({
|
|
908
|
+
promptText: aa,
|
|
909
|
+
schema: oa,
|
|
902
910
|
modelTier: "default",
|
|
903
911
|
inputVariables: {
|
|
904
912
|
summary: o.summary,
|
|
@@ -910,10 +918,10 @@ Question:
|
|
|
910
918
|
status: "success",
|
|
911
919
|
outputMessage: "I do not have group analytics context yet. Ask me to analyze a group first with analyze group <group id>."
|
|
912
920
|
};
|
|
913
|
-
},
|
|
921
|
+
}, oa = s.object({
|
|
914
922
|
answer: s.string(),
|
|
915
923
|
isRelevant: s.boolean()
|
|
916
|
-
}),
|
|
924
|
+
}), ra = `
|
|
917
925
|
Classify the user's request for ArcGIS Portal group analytics.
|
|
918
926
|
|
|
919
927
|
Rules:
|
|
@@ -942,16 +950,16 @@ hasAnalyticsContext:
|
|
|
942
950
|
|
|
943
951
|
User message:
|
|
944
952
|
{userMessage}
|
|
945
|
-
`,
|
|
946
|
-
await m({ text: "Analyzing group-analytics intent...", agentName: "group-analytics" },
|
|
947
|
-
const a = I(
|
|
953
|
+
`, sa = async (e, t) => {
|
|
954
|
+
await m({ text: "Analyzing group-analytics intent...", agentName: "group-analytics" }, t);
|
|
955
|
+
const a = I(e.agentExecutionContext.messages), n = !!U(e).latestGroupId, o = await J.fromTemplate(ra).format({
|
|
948
956
|
userMessage: a,
|
|
949
957
|
hasAnalyticsContext: String(n)
|
|
950
|
-
}), c = (await W({ modelTier: "fast" })).withStructuredOutput(
|
|
958
|
+
}), c = (await W({ modelTier: "fast" })).withStructuredOutput(oe), i = oe.parse(await c.invoke(o));
|
|
951
959
|
let l = i.groupId;
|
|
952
960
|
if ((i.intent === "summarize" || i.intent === "navigation") && !l) {
|
|
953
|
-
const y =
|
|
954
|
-
y && (l = await
|
|
961
|
+
const y = C(a, "$");
|
|
962
|
+
y && (l = await Se.invoke({ groupTitle: y }, t) ?? "");
|
|
955
963
|
}
|
|
956
964
|
const { intent: u, question: d } = i, g = u === "summarize" && !l, p = u === "followUp" && !(d ?? "").trim(), f = u === "clarify" || g || p;
|
|
957
965
|
return {
|
|
@@ -961,102 +969,102 @@ User message:
|
|
|
961
969
|
status: "success",
|
|
962
970
|
outputMessage: f ? "Please clarify with a group id or title" : ""
|
|
963
971
|
};
|
|
964
|
-
},
|
|
972
|
+
}, oe = s.object({
|
|
965
973
|
intent: s.enum(["summarize", "followUp", "navigation", "clarify"]),
|
|
966
974
|
groupId: s.string().default(""),
|
|
967
975
|
question: s.string().default("")
|
|
968
|
-
}),
|
|
969
|
-
const a = U(
|
|
970
|
-
return await m({ text: "Preparing navigation...", agentName: "group-analytics" },
|
|
976
|
+
}), ia = async (e, t) => {
|
|
977
|
+
const a = U(e), n = e.groupSummaryGroupId ?? a.latestGroupId;
|
|
978
|
+
return await m({ text: "Preparing navigation...", agentName: "group-analytics" }, t), await D(
|
|
971
979
|
n ? { destinationType: "portal-group", groupId: n } : { destinationType: "portal-groups" },
|
|
972
|
-
|
|
980
|
+
t
|
|
973
981
|
), { status: "success" };
|
|
974
982
|
};
|
|
975
|
-
function
|
|
976
|
-
return
|
|
983
|
+
function Ae({ timestamp: e, now: t, windowMs: a }) {
|
|
984
|
+
return e ? t - e <= a : !1;
|
|
977
985
|
}
|
|
978
|
-
const
|
|
979
|
-
function
|
|
980
|
-
const
|
|
986
|
+
const ca = 720 * 60 * 60 * 1e3;
|
|
987
|
+
function ua(e) {
|
|
988
|
+
const t = He(e);
|
|
981
989
|
return {
|
|
982
|
-
id:
|
|
983
|
-
title:
|
|
984
|
-
description:
|
|
985
|
-
snippet:
|
|
986
|
-
access:
|
|
987
|
-
owner:
|
|
988
|
-
tags:
|
|
989
|
-
created:
|
|
990
|
-
modified:
|
|
991
|
-
isInvitationOnly:
|
|
990
|
+
id: e.id ?? "",
|
|
991
|
+
title: e.title ?? "",
|
|
992
|
+
description: e.description ?? "",
|
|
993
|
+
snippet: e.snippet ?? "",
|
|
994
|
+
access: e.access ?? null,
|
|
995
|
+
owner: e.owner ?? "",
|
|
996
|
+
tags: e.tags ?? [],
|
|
997
|
+
created: e.created?.getTime(),
|
|
998
|
+
modified: e.modified?.getTime(),
|
|
999
|
+
isInvitationOnly: e.isInvitationOnly,
|
|
992
1000
|
sourceSignals: {
|
|
993
|
-
capabilities:
|
|
994
|
-
membershipAccess:
|
|
995
|
-
isOpenData:
|
|
996
|
-
isDistributedCollaborationGroup:
|
|
997
|
-
orgId:
|
|
998
|
-
hiddenMembers:
|
|
999
|
-
isViewOnly:
|
|
1000
|
-
isReadOnly:
|
|
1001
|
-
leavingDisallowed:
|
|
1001
|
+
capabilities: tt(e),
|
|
1002
|
+
membershipAccess: et(e),
|
|
1003
|
+
isOpenData: Ze(e),
|
|
1004
|
+
isDistributedCollaborationGroup: Xe(e),
|
|
1005
|
+
orgId: t.orgId,
|
|
1006
|
+
hiddenMembers: t.hiddenMembers,
|
|
1007
|
+
isViewOnly: t.isViewOnly,
|
|
1008
|
+
isReadOnly: t.isReadOnly,
|
|
1009
|
+
leavingDisallowed: t.leavingDisallowed
|
|
1002
1010
|
}
|
|
1003
1011
|
};
|
|
1004
1012
|
}
|
|
1005
|
-
async function
|
|
1006
|
-
const
|
|
1013
|
+
async function la(e) {
|
|
1014
|
+
const t = { owner: e.owner ?? "", admins: [], users: [] };
|
|
1007
1015
|
try {
|
|
1008
|
-
return await
|
|
1016
|
+
return await e.fetchMembers();
|
|
1009
1017
|
} catch (a) {
|
|
1010
|
-
return console.warn("Unable to fetch group members for analytics context", a),
|
|
1018
|
+
return console.warn("Unable to fetch group members for analytics context", a), t;
|
|
1011
1019
|
}
|
|
1012
1020
|
}
|
|
1013
|
-
function
|
|
1014
|
-
return
|
|
1015
|
-
id:
|
|
1016
|
-
title:
|
|
1017
|
-
type:
|
|
1018
|
-
owner:
|
|
1019
|
-
created:
|
|
1020
|
-
modified:
|
|
1021
|
+
function da(e) {
|
|
1022
|
+
return e.map((t) => ({
|
|
1023
|
+
id: t.id ?? "",
|
|
1024
|
+
title: t.title ?? "Untitled",
|
|
1025
|
+
type: t.type ?? "Unknown",
|
|
1026
|
+
owner: t.owner ?? "",
|
|
1027
|
+
created: t.created?.getTime(),
|
|
1028
|
+
modified: t.modified?.getTime()
|
|
1021
1029
|
}));
|
|
1022
1030
|
}
|
|
1023
|
-
function
|
|
1024
|
-
return
|
|
1025
|
-
(a) => a.modified ?
|
|
1031
|
+
function pa(e, t) {
|
|
1032
|
+
return e.filter(
|
|
1033
|
+
(a) => a.modified ? Ae({ timestamp: a.modified, now: t, windowMs: ca }) : !1
|
|
1026
1034
|
);
|
|
1027
1035
|
}
|
|
1028
|
-
function
|
|
1029
|
-
const
|
|
1030
|
-
for (const a of
|
|
1031
|
-
|
|
1032
|
-
return [...
|
|
1036
|
+
function ma(e) {
|
|
1037
|
+
const t = /* @__PURE__ */ new Map();
|
|
1038
|
+
for (const a of e)
|
|
1039
|
+
t.set(a.type, (t.get(a.type) ?? 0) + 1);
|
|
1040
|
+
return [...t.entries()].sort((a, n) => n[1] - a[1] || a[0].localeCompare(n[0])).slice(0, 6).map(([a, n]) => ({ type: a, count: n }));
|
|
1033
1041
|
}
|
|
1034
|
-
async function
|
|
1035
|
-
const
|
|
1042
|
+
async function ga(e) {
|
|
1043
|
+
const t = await e.queryItems({ num: 20, sortField: "modified", sortOrder: "desc" }), a = da(t.results), n = Date.now();
|
|
1036
1044
|
return {
|
|
1037
|
-
total:
|
|
1045
|
+
total: t.total,
|
|
1038
1046
|
topItems: a,
|
|
1039
|
-
recentlyModifiedItems:
|
|
1040
|
-
topItemTypes:
|
|
1047
|
+
recentlyModifiedItems: pa(a, n),
|
|
1048
|
+
topItemTypes: ma(a)
|
|
1041
1049
|
};
|
|
1042
1050
|
}
|
|
1043
|
-
async function
|
|
1044
|
-
if (!
|
|
1051
|
+
async function ha(e, t) {
|
|
1052
|
+
if (!t)
|
|
1045
1053
|
return { error: { code: "missingGroupId", message: "Group id is required." } };
|
|
1046
1054
|
try {
|
|
1047
|
-
const n = (await
|
|
1055
|
+
const n = (await e.queryGroups({ query: `id:${t}`, num: 1 })).results[0];
|
|
1048
1056
|
if (!n)
|
|
1049
|
-
return { error: { code: "groupNotFound", message: `No group found for id: ${
|
|
1050
|
-
const o =
|
|
1057
|
+
return { error: { code: "groupNotFound", message: `No group found for id: ${t}` } };
|
|
1058
|
+
const o = ua(n), r = await la(n), c = await ga(n);
|
|
1051
1059
|
return { result: { group: o, members: r, items: c } };
|
|
1052
1060
|
} catch (a) {
|
|
1053
1061
|
return console.error("Error fetching portal group analytics context:", a), { error: { code: "unhandledError" } };
|
|
1054
1062
|
}
|
|
1055
1063
|
}
|
|
1056
|
-
const
|
|
1064
|
+
const fa = `
|
|
1057
1065
|
You summarize ArcGIS Portal groups based on structured context and deterministic activity signals.
|
|
1058
1066
|
|
|
1059
|
-
${
|
|
1067
|
+
${Ce}
|
|
1060
1068
|
|
|
1061
1069
|
Output format requirements:
|
|
1062
1070
|
- Return concise markdown with clear sections in this order:
|
|
@@ -1092,25 +1100,25 @@ Group context:
|
|
|
1092
1100
|
|
|
1093
1101
|
Deterministic signals:
|
|
1094
1102
|
{deterministicSignals}
|
|
1095
|
-
`,
|
|
1096
|
-
const a =
|
|
1103
|
+
`, ya = 2160 * 60 * 60 * 1e3, wa = async (e, t) => {
|
|
1104
|
+
const a = e.groupSummaryGroupId;
|
|
1097
1105
|
if (!a)
|
|
1098
1106
|
return {
|
|
1099
1107
|
status: "success",
|
|
1100
1108
|
outputMessage: 'Please clarify with analyze group <group id>, analyze group $<title>, or analyze group $"<title with spaces>".'
|
|
1101
1109
|
};
|
|
1102
|
-
await m({ text: `Analyzing group ${a}...`, agentName: "group-analytics" },
|
|
1103
|
-
const n =
|
|
1110
|
+
await m({ text: `Analyzing group ${a}...`, agentName: "group-analytics" }, t);
|
|
1111
|
+
const n = t?.configurable?.context;
|
|
1104
1112
|
T(n);
|
|
1105
|
-
const { result: o, error: r } = await
|
|
1113
|
+
const { result: o, error: r } = await ha(n.portal, a);
|
|
1106
1114
|
if (r || !o)
|
|
1107
|
-
return await m({ text: "Failed to fetch group context", agentName: "group-analytics" },
|
|
1115
|
+
return await m({ text: "Failed to fetch group context", agentName: "group-analytics" }, t), {
|
|
1108
1116
|
status: "success",
|
|
1109
1117
|
outputMessage: "Unable to retrieve group context for analytics."
|
|
1110
1118
|
};
|
|
1111
|
-
const { group: c, items: i } = o, l = Date.now(), u = c.modified, d = u ?
|
|
1112
|
-
promptText:
|
|
1113
|
-
schema:
|
|
1119
|
+
const { group: c, items: i } = o, l = Date.now(), u = c.modified, d = u ? Ae({ timestamp: u, now: l, windowMs: ya }) : !1, g = i.recentlyModifiedItems.length, p = g > 0, f = d || p, y = await v({
|
|
1120
|
+
promptText: fa,
|
|
1121
|
+
schema: ba,
|
|
1114
1122
|
modelTier: "default",
|
|
1115
1123
|
inputVariables: {
|
|
1116
1124
|
context: JSON.stringify(o),
|
|
@@ -1121,22 +1129,22 @@ Deterministic signals:
|
|
|
1121
1129
|
recentItemCount: g
|
|
1122
1130
|
})
|
|
1123
1131
|
}
|
|
1124
|
-
}), { followUpQuestions: S, summary:
|
|
1132
|
+
}), { followUpQuestions: S, summary: M } = y, $e = U(e), Re = {
|
|
1125
1133
|
latestGroupId: a,
|
|
1126
1134
|
memory: {
|
|
1127
|
-
...$
|
|
1128
|
-
[a]: { summary:
|
|
1135
|
+
...$e.memory,
|
|
1136
|
+
[a]: { summary: M, followUpQuestions: S, fullContext: o }
|
|
1129
1137
|
}
|
|
1130
1138
|
};
|
|
1131
|
-
return S.length && await Q({ type: "suggested-prompts", data: { prompts: S } },
|
|
1139
|
+
return S.length && await Q({ type: "suggested-prompts", data: { prompts: S } }, t), {
|
|
1132
1140
|
status: "success",
|
|
1133
|
-
outputMessage:
|
|
1134
|
-
sharedStatePatch: { portalGroupSummaryMemory: { value:
|
|
1141
|
+
outputMessage: M,
|
|
1142
|
+
sharedStatePatch: { portalGroupSummaryMemory: { value: Re } }
|
|
1135
1143
|
};
|
|
1136
|
-
},
|
|
1144
|
+
}, ba = s.object({
|
|
1137
1145
|
summary: s.string(),
|
|
1138
1146
|
followUpQuestions: s.array(s.string()).default([])
|
|
1139
|
-
}), F = (
|
|
1147
|
+
}), F = (e, t) => t ?? e, Ne = h.Root({
|
|
1140
1148
|
...G(),
|
|
1141
1149
|
groupSummaryIntent: h({
|
|
1142
1150
|
reducer: F,
|
|
@@ -1150,24 +1158,24 @@ Deterministic signals:
|
|
|
1150
1158
|
reducer: F,
|
|
1151
1159
|
default: () => ""
|
|
1152
1160
|
})
|
|
1153
|
-
}),
|
|
1161
|
+
}), va = () => new A(Ne).addNode("detectGroupSummaryIntent", sa).addNode("summarizePortalGroup", wa).addNode("answerGroupSummaryFollowUp", na).addNode("suggestGroupSummaryNavigation", ia).addEdge(N, "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), Ia = String.raw`- **portal-group-analytics** - Portal group analytics assistant:
|
|
1154
1162
|
- summarizes ArcGIS portal groups from group context and sourceJSON details
|
|
1155
1163
|
- answers follow-up questions grounded in the summarized group
|
|
1156
1164
|
- suggests navigation to groups when relevant
|
|
1157
|
-
`,
|
|
1165
|
+
`, Sa = {
|
|
1158
1166
|
id: "portal-group-analytics",
|
|
1159
1167
|
name: "Portal Group Analytics",
|
|
1160
|
-
description:
|
|
1161
|
-
createGraph:
|
|
1162
|
-
workspace:
|
|
1163
|
-
},
|
|
1164
|
-
const
|
|
1165
|
-
return
|
|
1166
|
-
},
|
|
1168
|
+
description: Ia,
|
|
1169
|
+
createGraph: va,
|
|
1170
|
+
workspace: Ne
|
|
1171
|
+
}, xa = () => ({ latestItemId: null, memory: {} }), _ = (e) => {
|
|
1172
|
+
const t = e?.agentExecutionContext.sharedState.portalItemAnalyticsSummaryMemory?.value;
|
|
1173
|
+
return t ? { latestItemId: t.latestItemId, memory: t.memory } : xa();
|
|
1174
|
+
}, re = s.object({
|
|
1167
1175
|
intent: s.enum(["summarize", "followUp", "clarify"]),
|
|
1168
1176
|
itemId: s.string().default(""),
|
|
1169
1177
|
question: s.string().default("")
|
|
1170
|
-
}),
|
|
1178
|
+
}), Ta = s.object({ summary: s.string(), followUpQuestions: s.array(s.string()).default([]) }), Ma = s.object({ answer: s.string(), isRelevant: s.boolean() }), Ca = `
|
|
1171
1179
|
You answer follow-up questions about an ArcGIS item.
|
|
1172
1180
|
|
|
1173
1181
|
Ground your answer in the provided item context.
|
|
@@ -1187,14 +1195,14 @@ Item full context
|
|
|
1187
1195
|
|
|
1188
1196
|
Question:
|
|
1189
1197
|
{question}
|
|
1190
|
-
`,
|
|
1191
|
-
await m({ text: "Answering follow-up...", agentName: "analytics" },
|
|
1192
|
-
const a = _(
|
|
1198
|
+
`, Aa = async (e, t) => {
|
|
1199
|
+
await m({ text: "Answering follow-up...", agentName: "analytics" }, t);
|
|
1200
|
+
const a = _(e), n = e.analyticsItemId ?? a.latestItemId, o = n ? a.memory[n] : void 0, r = e.analyticsQuestion || I(e.agentExecutionContext.messages);
|
|
1193
1201
|
return o ? {
|
|
1194
1202
|
status: "success",
|
|
1195
|
-
outputMessage: (await
|
|
1196
|
-
promptText:
|
|
1197
|
-
schema:
|
|
1203
|
+
outputMessage: (await v({
|
|
1204
|
+
promptText: Ca,
|
|
1205
|
+
schema: Ma,
|
|
1198
1206
|
modelTier: "default",
|
|
1199
1207
|
inputVariables: {
|
|
1200
1208
|
summary: o.summary,
|
|
@@ -1206,7 +1214,7 @@ Question:
|
|
|
1206
1214
|
status: "success",
|
|
1207
1215
|
outputMessage: "I don't have enough information yet. Please ask me to summarize the item first using summarize item <item id>."
|
|
1208
1216
|
};
|
|
1209
|
-
},
|
|
1217
|
+
}, Na = `
|
|
1210
1218
|
Classify the user analytics request.
|
|
1211
1219
|
|
|
1212
1220
|
Rules:
|
|
@@ -1236,27 +1244,27 @@ hasSummaryContext:
|
|
|
1236
1244
|
|
|
1237
1245
|
User message:
|
|
1238
1246
|
{userMessage}
|
|
1239
|
-
`,
|
|
1240
|
-
await m({ text: "Analyzing intent...", agentName: "analytics" },
|
|
1241
|
-
const a = I(
|
|
1247
|
+
`, Ga = async (e, t) => {
|
|
1248
|
+
await m({ text: "Analyzing intent...", agentName: "analytics" }, t);
|
|
1249
|
+
const a = I(e.agentExecutionContext.messages), n = !!_(e).latestItemId, o = await J.fromTemplate(Na).format({
|
|
1242
1250
|
userMessage: a,
|
|
1243
1251
|
hasSummaryContext: String(n)
|
|
1244
|
-
}), c = (await W({ modelTier: "fast" })).withStructuredOutput(
|
|
1252
|
+
}), c = (await W({ modelTier: "fast" })).withStructuredOutput(re), i = re.parse(await c.invoke(o));
|
|
1245
1253
|
let l = i.itemId;
|
|
1246
1254
|
if (i.intent === "summarize" && !l) {
|
|
1247
|
-
const y =
|
|
1248
|
-
y && (l = await
|
|
1255
|
+
const y = C(a, "#");
|
|
1256
|
+
y && (l = await xe.invoke({ itemTitle: y }, t) ?? "");
|
|
1249
1257
|
}
|
|
1250
1258
|
const { intent: u, question: d } = i, f = u === "clarify" || u === "summarize" && !l || u === "followUp" && !d;
|
|
1251
1259
|
return {
|
|
1252
|
-
agentExecutionContext: { ...
|
|
1260
|
+
agentExecutionContext: { ...e.agentExecutionContext },
|
|
1253
1261
|
analyticsIntent: f ? "clarify" : u,
|
|
1254
1262
|
analyticsItemId: l || null,
|
|
1255
1263
|
analyticsQuestion: d || "",
|
|
1256
1264
|
status: "success",
|
|
1257
1265
|
outputMessage: f ? 'Please clarify with summarize item <item id>, summarize item #<title>, or summarize item #"<title with spaces>".' : ""
|
|
1258
1266
|
};
|
|
1259
|
-
},
|
|
1267
|
+
}, Pa = `
|
|
1260
1268
|
You are a item summary tool for ArcGIS. Your job is to summarize an item's info based on the provided context.
|
|
1261
1269
|
Summary rules:
|
|
1262
1270
|
- The summary should be concise markdown, make sure to format the output nicely so it's easy to read.
|
|
@@ -1271,40 +1279,40 @@ Do not include internal identifiers.
|
|
|
1271
1279
|
If the user asks for a detailed summary, you may expand the response up to 300 words.
|
|
1272
1280
|
Item context:
|
|
1273
1281
|
{context}
|
|
1274
|
-
`,
|
|
1275
|
-
const a =
|
|
1282
|
+
`, qa = async (e, t) => {
|
|
1283
|
+
const a = e.analyticsItemId;
|
|
1276
1284
|
if (!a)
|
|
1277
1285
|
return {
|
|
1278
1286
|
status: "success",
|
|
1279
1287
|
outputMessage: 'Please clarify with summarize item <item id>, summarize item #<title>, or summarize item #"<title with spaces>".'
|
|
1280
1288
|
};
|
|
1281
|
-
await m({ text: `Summarizing item ${a}...`, agentName: "analytics" },
|
|
1282
|
-
const n =
|
|
1289
|
+
await m({ text: `Summarizing item ${a}...`, agentName: "analytics" }, t);
|
|
1290
|
+
const n = t?.configurable?.context;
|
|
1283
1291
|
T(n);
|
|
1284
|
-
const { portal: o, user: r } = n, { result: c, error: i } = await
|
|
1292
|
+
const { portal: o, user: r } = n, { result: c, error: i } = await Ye(r, o, a);
|
|
1285
1293
|
if (i || !c)
|
|
1286
|
-
return await m({ text: "Failed to get item context for summarization", agentName: "analytics" },
|
|
1294
|
+
return await m({ text: "Failed to get item context for summarization", agentName: "analytics" }, t), {
|
|
1287
1295
|
status: "success",
|
|
1288
1296
|
outputMessage: "Unable to retrieve item context for summarization."
|
|
1289
1297
|
};
|
|
1290
|
-
const { context: l } = c, u = await
|
|
1291
|
-
promptText:
|
|
1292
|
-
schema:
|
|
1298
|
+
const { context: l } = c, u = await v({
|
|
1299
|
+
promptText: Pa,
|
|
1300
|
+
schema: Ta,
|
|
1293
1301
|
modelTier: "default",
|
|
1294
1302
|
inputVariables: { context: JSON.stringify(l) }
|
|
1295
|
-
}), { followUpQuestions: d, summary: g } = u, p = _(
|
|
1303
|
+
}), { followUpQuestions: d, summary: g } = u, p = _(e), f = {
|
|
1296
1304
|
latestItemId: a,
|
|
1297
1305
|
memory: {
|
|
1298
1306
|
...p.memory,
|
|
1299
1307
|
[a]: { summary: g, followUpQuestions: d, fullContext: l }
|
|
1300
1308
|
}
|
|
1301
1309
|
};
|
|
1302
|
-
return d.length && await Q({ type: "suggested-prompts", data: { prompts: d } },
|
|
1310
|
+
return d.length && await Q({ type: "suggested-prompts", data: { prompts: d } }, t), {
|
|
1303
1311
|
status: "success",
|
|
1304
1312
|
outputMessage: g,
|
|
1305
1313
|
sharedStatePatch: { portalItemAnalyticsSummaryMemory: { value: f } }
|
|
1306
1314
|
};
|
|
1307
|
-
}, O = (
|
|
1315
|
+
}, O = (e, t) => t ?? e, Ge = h.Root({
|
|
1308
1316
|
...G(),
|
|
1309
1317
|
// States shared only across nodes in the graph, not between invocations
|
|
1310
1318
|
analyticsIntent: h({
|
|
@@ -1319,18 +1327,18 @@ Item context:
|
|
|
1319
1327
|
reducer: O,
|
|
1320
1328
|
default: () => ""
|
|
1321
1329
|
})
|
|
1322
|
-
}),
|
|
1330
|
+
}), Ea = () => new A(Ge).addNode("detectAnalyticsIntent", Ga).addNode("summarizePortalItem", qa).addNode("answerAnalyticsFollowUp", Aa).addEdge(N, "detectAnalyticsIntent").addConditionalEdges("detectAnalyticsIntent", (t) => t.analyticsIntent === "summarize" ? "summarizePortalItem" : t.analyticsIntent === "followUp" ? "answerAnalyticsFollowUp" : w).addEdge("summarizePortalItem", w).addEdge("answerAnalyticsFollowUp", w), ka = String.raw`- **portal-item-analytics** - Portal item analytics assistant:
|
|
1323
1331
|
- answers questions about one specific ArcGIS portal item when item context is present
|
|
1324
1332
|
- summarizes item details, metadata, and context grounded in that item
|
|
1325
1333
|
- suggests follow-up prompts grounded in the same item
|
|
1326
1334
|
- use for item-specific requests, not for gallery browsing, featured content, or opening Map Viewer
|
|
1327
|
-
`,
|
|
1335
|
+
`, za = {
|
|
1328
1336
|
id: "portal-item-analytics",
|
|
1329
1337
|
name: "Portal Item Analytics",
|
|
1330
|
-
description:
|
|
1331
|
-
createGraph:
|
|
1332
|
-
workspace:
|
|
1333
|
-
},
|
|
1338
|
+
description: ka,
|
|
1339
|
+
createGraph: Ea,
|
|
1340
|
+
workspace: Ge
|
|
1341
|
+
}, $a = {
|
|
1334
1342
|
schemaVersion: "1.0",
|
|
1335
1343
|
capabilities: [
|
|
1336
1344
|
{
|
|
@@ -1370,7 +1378,7 @@ Item context:
|
|
|
1370
1378
|
}
|
|
1371
1379
|
}
|
|
1372
1380
|
]
|
|
1373
|
-
},
|
|
1381
|
+
}, Ra = {
|
|
1374
1382
|
schemaVersion: "1.0",
|
|
1375
1383
|
capabilities: [
|
|
1376
1384
|
{
|
|
@@ -1424,7 +1432,7 @@ Item context:
|
|
|
1424
1432
|
}
|
|
1425
1433
|
}
|
|
1426
1434
|
]
|
|
1427
|
-
},
|
|
1435
|
+
}, Da = {
|
|
1428
1436
|
schemaVersion: "1.0",
|
|
1429
1437
|
capabilities: [
|
|
1430
1438
|
{
|
|
@@ -1444,34 +1452,34 @@ Item context:
|
|
|
1444
1452
|
}
|
|
1445
1453
|
}
|
|
1446
1454
|
]
|
|
1447
|
-
},
|
|
1448
|
-
"contentRouteRegistry.ts":
|
|
1449
|
-
"groupsRouteRegistry.ts":
|
|
1450
|
-
"orgSettingsRouteRegistry.ts":
|
|
1455
|
+
}, Ua = {
|
|
1456
|
+
"contentRouteRegistry.ts": $a,
|
|
1457
|
+
"groupsRouteRegistry.ts": Ra,
|
|
1458
|
+
"orgSettingsRouteRegistry.ts": Da
|
|
1451
1459
|
};
|
|
1452
|
-
function
|
|
1453
|
-
const
|
|
1454
|
-
for (const [n, o] of Object.entries(
|
|
1460
|
+
function se(e) {
|
|
1461
|
+
const t = [], a = /* @__PURE__ */ new Set();
|
|
1462
|
+
for (const [n, o] of Object.entries(e))
|
|
1455
1463
|
for (const r of o.capabilities) {
|
|
1456
1464
|
if (a.has(r.id))
|
|
1457
1465
|
throw new Error(`${n}: duplicate capability id "${r.id}" across registries`);
|
|
1458
|
-
a.add(r.id),
|
|
1466
|
+
a.add(r.id), t.push(r);
|
|
1459
1467
|
}
|
|
1460
|
-
return
|
|
1468
|
+
return t;
|
|
1461
1469
|
}
|
|
1462
1470
|
let E;
|
|
1463
|
-
function x(
|
|
1464
|
-
return
|
|
1471
|
+
function x(e) {
|
|
1472
|
+
return e ? E = se({ customCapabilities: e }) : E || (E = se(Ua)), E;
|
|
1465
1473
|
}
|
|
1466
|
-
const
|
|
1467
|
-
function $(
|
|
1468
|
-
return
|
|
1474
|
+
const Fa = /^(?:take me to|navigate to|go to|show me|open)\s+(?:the\s+)?/u;
|
|
1475
|
+
function $(e) {
|
|
1476
|
+
return e.toLowerCase().replace(/[^a-z0-9]+/gu, " ").trim().replace(Fa, "").trim();
|
|
1469
1477
|
}
|
|
1470
|
-
const
|
|
1478
|
+
const Oa = s.object({
|
|
1471
1479
|
capabilityIds: s.array(s.string()).default([]),
|
|
1472
1480
|
confidence: s.number().min(0).max(1).default(0),
|
|
1473
1481
|
reason: s.string().default("")
|
|
1474
|
-
}),
|
|
1482
|
+
}), ie = 0.8, La = String.raw`You select Portal navigation capabilities for a user's request.
|
|
1475
1483
|
|
|
1476
1484
|
Select only capability IDs from the supplied candidates. Return an empty array when none fit.
|
|
1477
1485
|
A named surface is required: do not select a capability on another Portal surface.
|
|
@@ -1481,19 +1489,19 @@ User request:
|
|
|
1481
1489
|
{userRequest}
|
|
1482
1490
|
|
|
1483
1491
|
Candidates:
|
|
1484
|
-
{candidates}`,
|
|
1485
|
-
if (
|
|
1492
|
+
{candidates}`, ja = async (e, t) => {
|
|
1493
|
+
if (e.outputMessage || e.targets.length === 0)
|
|
1486
1494
|
return {};
|
|
1487
|
-
const a = I(
|
|
1495
|
+
const a = I(e.agentExecutionContext.messages).trim(), n = Va(a, e);
|
|
1488
1496
|
if (n.length === 1)
|
|
1489
1497
|
return console.info("[arcgis-portal-ai-assistant] navigation capability selection:", {
|
|
1490
1498
|
method: "exact-match",
|
|
1491
1499
|
request: a,
|
|
1492
1500
|
selectedCapabilityIds: n
|
|
1493
1501
|
}), { chosenCapabilityIds: n };
|
|
1494
|
-
await m({ text: "Choosing a navigation destination...", agentName: "navigation" },
|
|
1502
|
+
await m({ text: "Choosing a navigation destination...", agentName: "navigation" }, t);
|
|
1495
1503
|
const o = JSON.stringify(
|
|
1496
|
-
|
|
1504
|
+
e.targets.map(({ capability: r, keywordScore: c, semanticScore: i }) => ({
|
|
1497
1505
|
id: r.id,
|
|
1498
1506
|
title: r.title,
|
|
1499
1507
|
description: r.description,
|
|
@@ -1503,22 +1511,22 @@ Candidates:
|
|
|
1503
1511
|
}))
|
|
1504
1512
|
);
|
|
1505
1513
|
try {
|
|
1506
|
-
const r = await
|
|
1507
|
-
promptText:
|
|
1508
|
-
schema:
|
|
1514
|
+
const r = await v({
|
|
1515
|
+
promptText: La,
|
|
1516
|
+
schema: Oa,
|
|
1509
1517
|
modelTier: "fast",
|
|
1510
1518
|
inputVariables: { candidates: o, userRequest: a }
|
|
1511
|
-
}), c = new Set(
|
|
1519
|
+
}), c = new Set(e.targets.map(({ capability: l }) => l.id)), i = r.capabilityIds.filter((l) => c.has(l));
|
|
1512
1520
|
return console.info("[arcgis-portal-ai-assistant] navigation capability selection:", {
|
|
1513
1521
|
confidence: r.confidence,
|
|
1514
1522
|
method: "structured-model",
|
|
1515
1523
|
reason: r.reason,
|
|
1516
1524
|
request: a,
|
|
1517
1525
|
selectedCapabilityIds: i
|
|
1518
|
-
}), r.confidence <
|
|
1526
|
+
}), r.confidence < ie ? {
|
|
1519
1527
|
chosenCapabilityIds: [],
|
|
1520
1528
|
status: "failed",
|
|
1521
|
-
summary: `Navigation selection confidence ${r.confidence} is below the required ${
|
|
1529
|
+
summary: `Navigation selection confidence ${r.confidence} is below the required ${ie}; defer to the Portal Doc Assistant.`
|
|
1522
1530
|
} : { chosenCapabilityIds: i };
|
|
1523
1531
|
} catch {
|
|
1524
1532
|
return console.info("[arcgis-portal-ai-assistant] navigation capability selection:", {
|
|
@@ -1528,19 +1536,19 @@ Candidates:
|
|
|
1528
1536
|
}), { chosenCapabilityIds: [] };
|
|
1529
1537
|
}
|
|
1530
1538
|
};
|
|
1531
|
-
function
|
|
1532
|
-
const a = $(
|
|
1533
|
-
return
|
|
1539
|
+
function Va(e, t) {
|
|
1540
|
+
const a = $(e);
|
|
1541
|
+
return t.targets.filter(
|
|
1534
1542
|
({ capability: n }) => [n.title, ...n.hints].some(
|
|
1535
1543
|
(o) => $(o) === a
|
|
1536
1544
|
)
|
|
1537
1545
|
).map(({ capability: n }) => n.id);
|
|
1538
1546
|
}
|
|
1539
|
-
const
|
|
1547
|
+
const Pe = /* @__PURE__ */ new Set(["1d", "7d", "14d", "30d", "3m", "6m"]), Ba = s.object({
|
|
1540
1548
|
period: s.string(),
|
|
1541
1549
|
startTime: s.string(),
|
|
1542
1550
|
endTime: s.string()
|
|
1543
|
-
}),
|
|
1551
|
+
}), Ka = String.raw`Extract temporal filters for an ArcGIS storage-credits query.
|
|
1544
1552
|
|
|
1545
1553
|
Return JSON only with these optional string fields:
|
|
1546
1554
|
- period
|
|
@@ -1566,34 +1574,34 @@ Now UTC:
|
|
|
1566
1574
|
|
|
1567
1575
|
User request:
|
|
1568
1576
|
{userRequest}`;
|
|
1569
|
-
async function
|
|
1570
|
-
const a =
|
|
1577
|
+
async function Qa(e, t = /* @__PURE__ */ new Date()) {
|
|
1578
|
+
const a = e.trim();
|
|
1571
1579
|
if (!a)
|
|
1572
1580
|
return {};
|
|
1573
1581
|
try {
|
|
1574
|
-
const n = await
|
|
1575
|
-
promptText:
|
|
1576
|
-
schema:
|
|
1582
|
+
const n = await v({
|
|
1583
|
+
promptText: Ka,
|
|
1584
|
+
schema: Ba,
|
|
1577
1585
|
modelTier: "fast",
|
|
1578
1586
|
inputVariables: {
|
|
1579
|
-
nowEpochMs: String(
|
|
1580
|
-
nowIso:
|
|
1587
|
+
nowEpochMs: String(t.getTime()),
|
|
1588
|
+
nowIso: t.toISOString(),
|
|
1581
1589
|
userRequest: a
|
|
1582
1590
|
}
|
|
1583
1591
|
});
|
|
1584
|
-
return
|
|
1592
|
+
return Wa(n, t);
|
|
1585
1593
|
} catch (n) {
|
|
1586
1594
|
return console.error(n), {};
|
|
1587
1595
|
}
|
|
1588
1596
|
}
|
|
1589
|
-
function
|
|
1590
|
-
const a =
|
|
1597
|
+
function Wa(e, t = /* @__PURE__ */ new Date()) {
|
|
1598
|
+
const a = ce(e.startTime), n = ce(e.endTime), o = Ja(e.period);
|
|
1591
1599
|
if (o) {
|
|
1592
1600
|
if (a !== void 0 && n !== void 0 && a < n)
|
|
1593
1601
|
return { period: o, startTime: String(a), endTime: String(n) };
|
|
1594
|
-
const r =
|
|
1595
|
-
if (!r || n !== void 0 && !
|
|
1596
|
-
const i = n ??
|
|
1602
|
+
const r = Pe.has(o);
|
|
1603
|
+
if (!r || n !== void 0 && !Ya(n, t.getTime())) {
|
|
1604
|
+
const i = n ?? t.getTime(), l = _a(o, new Date(i));
|
|
1597
1605
|
if (l !== void 0)
|
|
1598
1606
|
return {
|
|
1599
1607
|
period: o,
|
|
@@ -1607,25 +1615,25 @@ function _a(t, e = /* @__PURE__ */ new Date()) {
|
|
|
1607
1615
|
...n !== void 0 ? { endTime: String(n) } : {}
|
|
1608
1616
|
} : { period: o };
|
|
1609
1617
|
}
|
|
1610
|
-
return a !== void 0 && n !== void 0 && a < n ? { startTime: String(a), endTime: String(n) } : a !== void 0 ? { startTime: String(a), endTime: String(
|
|
1618
|
+
return a !== void 0 && n !== void 0 && a < n ? { startTime: String(a), endTime: String(n) } : a !== void 0 ? { startTime: String(a), endTime: String(t.getTime()) } : {};
|
|
1611
1619
|
}
|
|
1612
|
-
function
|
|
1613
|
-
const
|
|
1614
|
-
if (!
|
|
1620
|
+
function Ja(e) {
|
|
1621
|
+
const t = e?.trim().match(/^(\d+)\s*([dwm])$/iu);
|
|
1622
|
+
if (!t)
|
|
1615
1623
|
return;
|
|
1616
|
-
const a = Number.parseInt(
|
|
1624
|
+
const a = Number.parseInt(t[1], 10);
|
|
1617
1625
|
if (!Number.isFinite(a) || a <= 0)
|
|
1618
1626
|
return;
|
|
1619
|
-
const n =
|
|
1627
|
+
const n = t[2].toLowerCase();
|
|
1620
1628
|
if (n === "w") {
|
|
1621
1629
|
const o = a * 7;
|
|
1622
|
-
if (
|
|
1630
|
+
if (Pe.has(`${o}d`))
|
|
1623
1631
|
return `${o}d`;
|
|
1624
1632
|
}
|
|
1625
1633
|
return `${a}${n}`;
|
|
1626
1634
|
}
|
|
1627
|
-
function
|
|
1628
|
-
const a =
|
|
1635
|
+
function _a(e, t) {
|
|
1636
|
+
const a = e.match(/^(\d+)([dwm])$/u);
|
|
1629
1637
|
if (!a)
|
|
1630
1638
|
return;
|
|
1631
1639
|
const n = Number.parseInt(a[1], 10);
|
|
@@ -1633,35 +1641,35 @@ function Ha(t, e) {
|
|
|
1633
1641
|
return;
|
|
1634
1642
|
const o = a[2];
|
|
1635
1643
|
if (o === "d")
|
|
1636
|
-
return
|
|
1644
|
+
return t.getTime() - n * 24 * 60 * 60 * 1e3;
|
|
1637
1645
|
if (o === "w")
|
|
1638
|
-
return
|
|
1639
|
-
const r = new Date(
|
|
1646
|
+
return t.getTime() - n * 7 * 24 * 60 * 60 * 1e3;
|
|
1647
|
+
const r = new Date(t.getTime());
|
|
1640
1648
|
return r.setUTCMonth(r.getUTCMonth() - n), r.getTime();
|
|
1641
1649
|
}
|
|
1642
|
-
function
|
|
1643
|
-
if (!
|
|
1650
|
+
function ce(e) {
|
|
1651
|
+
if (!e)
|
|
1644
1652
|
return;
|
|
1645
|
-
const
|
|
1646
|
-
if (!(!Number.isFinite(
|
|
1647
|
-
return
|
|
1653
|
+
const t = Number.parseInt(e, 10);
|
|
1654
|
+
if (!(!Number.isFinite(t) || t <= 0))
|
|
1655
|
+
return t;
|
|
1648
1656
|
}
|
|
1649
|
-
function
|
|
1650
|
-
const a = new Date(
|
|
1657
|
+
function Ya(e, t) {
|
|
1658
|
+
const a = new Date(e), n = new Date(t);
|
|
1651
1659
|
return a.getUTCFullYear() === n.getUTCFullYear() && a.getUTCMonth() === n.getUTCMonth() && a.getUTCDate() === n.getUTCDate();
|
|
1652
1660
|
}
|
|
1653
|
-
async function
|
|
1654
|
-
const n = x().find((r) => r.id ===
|
|
1661
|
+
async function Ha(e, t, a) {
|
|
1662
|
+
const n = x().find((r) => r.id === e);
|
|
1655
1663
|
if (!n)
|
|
1656
1664
|
return;
|
|
1657
|
-
const o = await
|
|
1658
|
-
return o &&
|
|
1665
|
+
const o = await Za(Xa(n), a);
|
|
1666
|
+
return o && tn(o, t) ? { capability: n, target: o } : void 0;
|
|
1659
1667
|
}
|
|
1660
|
-
function
|
|
1661
|
-
const { hash:
|
|
1668
|
+
function Xa(e) {
|
|
1669
|
+
const { hash: t, queryParams: a, routeKey: n } = e.resolutions.navigate;
|
|
1662
1670
|
switch (n) {
|
|
1663
1671
|
case "content":
|
|
1664
|
-
switch (
|
|
1672
|
+
switch (e.id) {
|
|
1665
1673
|
case "my-content":
|
|
1666
1674
|
return { destinationType: "portal-content" };
|
|
1667
1675
|
case "create-feature-layer":
|
|
@@ -1672,11 +1680,11 @@ function tn(t) {
|
|
|
1672
1680
|
return { destinationType: "portal-content" };
|
|
1673
1681
|
}
|
|
1674
1682
|
case "groups":
|
|
1675
|
-
if (
|
|
1683
|
+
if (t === "featured")
|
|
1676
1684
|
return { destinationType: "portal-groups", hash: "featured" };
|
|
1677
|
-
if (
|
|
1685
|
+
if (t === "organization")
|
|
1678
1686
|
return { destinationType: "portal-groups", hash: "organization" };
|
|
1679
|
-
switch (
|
|
1687
|
+
switch (e.id) {
|
|
1680
1688
|
case "my groups":
|
|
1681
1689
|
return { destinationType: "portal-groups", hash: "my" };
|
|
1682
1690
|
case "create-group":
|
|
@@ -1687,50 +1695,50 @@ function tn(t) {
|
|
|
1687
1695
|
case "organization":
|
|
1688
1696
|
return {
|
|
1689
1697
|
destinationType: "portal-org",
|
|
1690
|
-
hash:
|
|
1698
|
+
hash: t,
|
|
1691
1699
|
queryParams: a,
|
|
1692
|
-
buttonLabel:
|
|
1700
|
+
buttonLabel: e.buttonLabel
|
|
1693
1701
|
};
|
|
1694
1702
|
default:
|
|
1695
1703
|
return;
|
|
1696
1704
|
}
|
|
1697
1705
|
}
|
|
1698
|
-
async function
|
|
1699
|
-
if (!
|
|
1700
|
-
return
|
|
1701
|
-
const a = await
|
|
1706
|
+
async function Za(e, t) {
|
|
1707
|
+
if (!e || !t || !en(e))
|
|
1708
|
+
return e;
|
|
1709
|
+
const a = await Qa(t);
|
|
1702
1710
|
if (!a.period && !a.startTime && !a.endTime)
|
|
1703
|
-
return
|
|
1711
|
+
return e;
|
|
1704
1712
|
const n = {
|
|
1705
|
-
...
|
|
1713
|
+
...e.queryParams ?? {},
|
|
1706
1714
|
...a.period ? { period: a.period } : {},
|
|
1707
1715
|
...a.startTime ? { startTime: a.startTime } : {},
|
|
1708
1716
|
...a.endTime ? { endTime: a.endTime } : {}
|
|
1709
1717
|
};
|
|
1710
|
-
return { ...
|
|
1718
|
+
return { ...e, queryParams: n };
|
|
1711
1719
|
}
|
|
1712
|
-
function
|
|
1713
|
-
return
|
|
1720
|
+
function en(e) {
|
|
1721
|
+
return e.destinationType === "portal-org" && e.hash === "status";
|
|
1714
1722
|
}
|
|
1715
|
-
function
|
|
1716
|
-
return !
|
|
1723
|
+
function tn(e, t) {
|
|
1724
|
+
return !t || !!t[e.destinationType];
|
|
1717
1725
|
}
|
|
1718
|
-
const
|
|
1719
|
-
if (
|
|
1726
|
+
const an = async (e, t) => {
|
|
1727
|
+
if (e.outputMessage || e.status === "failed")
|
|
1720
1728
|
return {};
|
|
1721
|
-
const a =
|
|
1729
|
+
const a = e.targets.find(({ capability: r }) => e.chosenCapabilityIds.includes(r.id)) ?? e.targets[0];
|
|
1722
1730
|
if (!a)
|
|
1723
1731
|
return {
|
|
1724
1732
|
outputMessage: "I couldn't find a matching Portal page. Try asking to open your content, groups, or organization settings.",
|
|
1725
|
-
sharedStatePatch: { navLastAnsweredRequest: { value:
|
|
1733
|
+
sharedStatePatch: { navLastAnsweredRequest: { value: ue(e) } },
|
|
1726
1734
|
status: "success",
|
|
1727
1735
|
summary: "Navigation could not find a matching capability; route another agent if appropriate."
|
|
1728
1736
|
};
|
|
1729
|
-
const n =
|
|
1730
|
-
return o ? (await m({ text: "Preparing navigation...", agentName: "navigation" },
|
|
1731
|
-
outputMessage:
|
|
1737
|
+
const n = ue(e), o = await Ha(a.capability.id, void 0, n);
|
|
1738
|
+
return o ? (await m({ text: "Preparing navigation...", agentName: "navigation" }, t), await D(o.target, t), {
|
|
1739
|
+
outputMessage: e.chosenCapabilityIds.length ? a.capability.description : `The closest place to start is ${a.capability.title}. Click the button below to open it.`,
|
|
1732
1740
|
status: "success",
|
|
1733
|
-
summary: `Navigation suggested ${a.capability.id}${
|
|
1741
|
+
summary: `Navigation suggested ${a.capability.id}${e.retrievalDegraded ? " using keyword-only retrieval" : ""}.`,
|
|
1734
1742
|
sharedStatePatch: { navLastAnsweredRequest: { value: n } }
|
|
1735
1743
|
}) : (console.warn(`Navigation capability ${a.capability.id} was not found in the resolver.`), {
|
|
1736
1744
|
outputMessage: "I found a possible destination, but couldn't resolve a valid Portal navigation target. Try asking to open your content, groups, or organization settings.",
|
|
@@ -1739,87 +1747,87 @@ const on = async (t, e) => {
|
|
|
1739
1747
|
sharedStatePatch: { navLastAnsweredRequest: { value: n } }
|
|
1740
1748
|
});
|
|
1741
1749
|
};
|
|
1742
|
-
function
|
|
1743
|
-
return I(
|
|
1750
|
+
function ue(e) {
|
|
1751
|
+
return I(e.agentExecutionContext.messages) || e.agentExecutionContext.userRequest;
|
|
1744
1752
|
}
|
|
1745
|
-
async function
|
|
1746
|
-
return
|
|
1753
|
+
async function qe(e) {
|
|
1754
|
+
return e.length === 0 ? [] : (await at.getDefault().load(), await Ve(e));
|
|
1747
1755
|
}
|
|
1748
|
-
const
|
|
1756
|
+
const nn = /* @__PURE__ */ Object.freeze(/* @__PURE__ */ Object.defineProperty({
|
|
1749
1757
|
__proto__: null,
|
|
1750
|
-
generateEmbeddings:
|
|
1758
|
+
generateEmbeddings: qe
|
|
1751
1759
|
}, Symbol.toStringTag, { value: "Module" }));
|
|
1752
|
-
function
|
|
1753
|
-
const
|
|
1754
|
-
a.trim().length > 0 &&
|
|
1755
|
-
const n =
|
|
1760
|
+
function on(e) {
|
|
1761
|
+
const t = [], a = `${e.title}. ${e.description}`;
|
|
1762
|
+
a.trim().length > 0 && t.push({ field: "summary", text: a });
|
|
1763
|
+
const n = e.hints;
|
|
1756
1764
|
if (Array.isArray(n))
|
|
1757
1765
|
for (const o of n)
|
|
1758
|
-
typeof o == "string" && o.trim().length > 0 &&
|
|
1759
|
-
return
|
|
1766
|
+
typeof o == "string" && o.trim().length > 0 && t.push({ field: "hint", text: o });
|
|
1767
|
+
return t;
|
|
1760
1768
|
}
|
|
1761
|
-
let
|
|
1762
|
-
async function
|
|
1763
|
-
const
|
|
1764
|
-
return
|
|
1765
|
-
throw
|
|
1766
|
-
}), await
|
|
1769
|
+
let k, Y, z = 0;
|
|
1770
|
+
async function rn(e = {}) {
|
|
1771
|
+
const t = z;
|
|
1772
|
+
return k ??= cn(e.embed ?? un).then((a) => (t === z && (Y = a), a)).catch((a) => {
|
|
1773
|
+
throw t === z && (k = void 0), a;
|
|
1774
|
+
}), await k;
|
|
1767
1775
|
}
|
|
1768
|
-
function
|
|
1776
|
+
function sn() {
|
|
1769
1777
|
return Y;
|
|
1770
1778
|
}
|
|
1771
|
-
function
|
|
1772
|
-
|
|
1779
|
+
function le() {
|
|
1780
|
+
z += 1, Y = void 0, k = void 0;
|
|
1773
1781
|
}
|
|
1774
|
-
async function
|
|
1775
|
-
const
|
|
1776
|
-
if (a.length !==
|
|
1777
|
-
throw new Error(`Expected ${
|
|
1778
|
-
return
|
|
1782
|
+
async function cn(e) {
|
|
1783
|
+
const t = ln(), a = await e(t.map((n) => n.text));
|
|
1784
|
+
if (a.length !== t.length)
|
|
1785
|
+
throw new Error(`Expected ${t.length} vectors, got ${a.length}`);
|
|
1786
|
+
return t.map((n, o) => ({
|
|
1779
1787
|
...n,
|
|
1780
1788
|
vector: a[o]
|
|
1781
1789
|
}));
|
|
1782
1790
|
}
|
|
1783
|
-
async function
|
|
1784
|
-
const { generateEmbeddings:
|
|
1785
|
-
return await e
|
|
1791
|
+
async function un(e) {
|
|
1792
|
+
const { generateEmbeddings: t } = await Promise.resolve().then(() => nn);
|
|
1793
|
+
return await t(e);
|
|
1786
1794
|
}
|
|
1787
|
-
function
|
|
1795
|
+
function ln() {
|
|
1788
1796
|
return x().flatMap(
|
|
1789
|
-
(
|
|
1790
|
-
capabilityId:
|
|
1791
|
-
field:
|
|
1797
|
+
(e) => on(e).map(({ field: t, text: a }) => ({
|
|
1798
|
+
capabilityId: e.id,
|
|
1799
|
+
field: t,
|
|
1792
1800
|
text: a
|
|
1793
1801
|
}))
|
|
1794
1802
|
);
|
|
1795
1803
|
}
|
|
1796
|
-
const
|
|
1804
|
+
const de = 1.2, pe = 0.75, dn = 60, pn = 0.65, L = {
|
|
1797
1805
|
description: 1,
|
|
1798
1806
|
hint: 2,
|
|
1799
1807
|
title: 3
|
|
1800
1808
|
};
|
|
1801
1809
|
let K;
|
|
1802
|
-
function
|
|
1810
|
+
function mn() {
|
|
1803
1811
|
K = void 0;
|
|
1804
1812
|
}
|
|
1805
|
-
async function
|
|
1806
|
-
const a =
|
|
1813
|
+
async function gn(e, t = {}) {
|
|
1814
|
+
const a = wn(Ee(e));
|
|
1807
1815
|
let n = [], o = !1, r;
|
|
1808
|
-
if (
|
|
1809
|
-
const c =
|
|
1816
|
+
if (e.trim()) {
|
|
1817
|
+
const c = t.loadEmbeddings, i = sn();
|
|
1810
1818
|
if (!c && !i)
|
|
1811
1819
|
o = !0, r = "Capability embeddings are still loading.";
|
|
1812
1820
|
else
|
|
1813
1821
|
try {
|
|
1814
1822
|
if (c) {
|
|
1815
1823
|
const [l, u] = await Promise.all([
|
|
1816
|
-
(
|
|
1824
|
+
(t.embedQuery ?? ge)(e),
|
|
1817
1825
|
c()
|
|
1818
1826
|
]);
|
|
1819
|
-
n =
|
|
1827
|
+
n = me(l, u);
|
|
1820
1828
|
} else if (i) {
|
|
1821
|
-
const l = await (
|
|
1822
|
-
n =
|
|
1829
|
+
const l = await (t.embedQuery ?? ge)(e);
|
|
1830
|
+
n = me(l, i);
|
|
1823
1831
|
}
|
|
1824
1832
|
} catch {
|
|
1825
1833
|
o = !0, r = "Semantic search is unavailable.";
|
|
@@ -1830,60 +1838,60 @@ async function fn(t, e = {}) {
|
|
|
1830
1838
|
...r ? { degradedReason: r } : {},
|
|
1831
1839
|
// RRF combines ranks rather than raw scores because BM25 and cosine
|
|
1832
1840
|
// similarity are on different scales.
|
|
1833
|
-
matches:
|
|
1841
|
+
matches: vn(a, n, t.topN ?? 5)
|
|
1834
1842
|
};
|
|
1835
1843
|
}
|
|
1836
|
-
function
|
|
1837
|
-
return K ??=
|
|
1844
|
+
function hn() {
|
|
1845
|
+
return K ??= fn(x()), K;
|
|
1838
1846
|
}
|
|
1839
|
-
function
|
|
1840
|
-
const
|
|
1847
|
+
function fn(e) {
|
|
1848
|
+
const t = /* @__PURE__ */ new Map(), a = e.map((n) => {
|
|
1841
1849
|
const o = /* @__PURE__ */ new Map();
|
|
1842
1850
|
j(o, n.title, L.title), j(o, n.description, L.description);
|
|
1843
1851
|
for (const r of n.hints)
|
|
1844
1852
|
j(o, r, L.hint);
|
|
1845
1853
|
for (const r of o.keys())
|
|
1846
|
-
|
|
1854
|
+
t.set(r, (t.get(r) ?? 0) + 1);
|
|
1847
1855
|
return {
|
|
1848
1856
|
capability: n,
|
|
1849
|
-
length:
|
|
1857
|
+
length: yn(o),
|
|
1850
1858
|
termFrequencies: o
|
|
1851
1859
|
};
|
|
1852
1860
|
});
|
|
1853
1861
|
return {
|
|
1854
1862
|
averageDocumentLength: a.length ? a.reduce((n, o) => n + o.length, 0) / a.length : 0,
|
|
1855
|
-
documentFrequency:
|
|
1863
|
+
documentFrequency: t,
|
|
1856
1864
|
documents: a
|
|
1857
1865
|
};
|
|
1858
1866
|
}
|
|
1859
|
-
function j(
|
|
1860
|
-
for (const n of
|
|
1861
|
-
|
|
1867
|
+
function j(e, t, a) {
|
|
1868
|
+
for (const n of Ee(t))
|
|
1869
|
+
e.set(n, (e.get(n) ?? 0) + a);
|
|
1862
1870
|
}
|
|
1863
|
-
function
|
|
1864
|
-
return [...
|
|
1871
|
+
function yn(e) {
|
|
1872
|
+
return [...e.values()].reduce((t, a) => t + a, 0);
|
|
1865
1873
|
}
|
|
1866
|
-
function
|
|
1867
|
-
return
|
|
1874
|
+
function Ee(e) {
|
|
1875
|
+
return e.toLowerCase().split(/[^a-z0-9]+/u).filter(Boolean);
|
|
1868
1876
|
}
|
|
1869
|
-
function
|
|
1870
|
-
const
|
|
1871
|
-
return
|
|
1877
|
+
function wn(e) {
|
|
1878
|
+
const t = hn(), a = new Set(e), n = t.documents.length;
|
|
1879
|
+
return t.documents.map(({ capability: o, length: r, termFrequencies: c }) => {
|
|
1872
1880
|
let i = 0;
|
|
1873
1881
|
for (const l of a) {
|
|
1874
|
-
const u = c.get(l), d =
|
|
1882
|
+
const u = c.get(l), d = t.documentFrequency.get(l);
|
|
1875
1883
|
if (!u || !d)
|
|
1876
1884
|
continue;
|
|
1877
|
-
const g = Math.log(1 + (n - d + 0.5) / (d + 0.5)), p =
|
|
1878
|
-
i += g * (u * (
|
|
1885
|
+
const g = Math.log(1 + (n - d + 0.5) / (d + 0.5)), p = de * (1 - pe + pe * (r / t.averageDocumentLength));
|
|
1886
|
+
i += g * (u * (de + 1) / (u + p));
|
|
1879
1887
|
}
|
|
1880
1888
|
return { capability: o, score: i };
|
|
1881
|
-
}).filter(({ score: o }) => o > 0).sort(
|
|
1889
|
+
}).filter(({ score: o }) => o > 0).sort(ke);
|
|
1882
1890
|
}
|
|
1883
|
-
function
|
|
1891
|
+
function me(e, t) {
|
|
1884
1892
|
const a = /* @__PURE__ */ new Map();
|
|
1885
|
-
for (const o of
|
|
1886
|
-
const r =
|
|
1893
|
+
for (const o of t) {
|
|
1894
|
+
const r = bn(e, o.vector);
|
|
1887
1895
|
if (r === void 0)
|
|
1888
1896
|
continue;
|
|
1889
1897
|
const c = a.get(o.capabilityId);
|
|
@@ -1892,42 +1900,42 @@ function mt(t, e) {
|
|
|
1892
1900
|
const n = new Map(x().map((o) => [o.id, o]));
|
|
1893
1901
|
return [...a.entries()].flatMap(([o, r]) => {
|
|
1894
1902
|
const c = n.get(o);
|
|
1895
|
-
return c && r >=
|
|
1896
|
-
}).sort(
|
|
1903
|
+
return c && r >= pn ? [{ capability: c, score: r }] : [];
|
|
1904
|
+
}).sort(ke);
|
|
1897
1905
|
}
|
|
1898
|
-
function
|
|
1899
|
-
if (
|
|
1906
|
+
function bn(e, t) {
|
|
1907
|
+
if (e.length === 0 || e.length !== t.length)
|
|
1900
1908
|
return;
|
|
1901
1909
|
let a = 0, n = 0, o = 0;
|
|
1902
|
-
for (let c = 0; c <
|
|
1903
|
-
a +=
|
|
1910
|
+
for (let c = 0; c < e.length; c += 1)
|
|
1911
|
+
a += e[c] * t[c], n += e[c] ** 2, o += t[c] ** 2;
|
|
1904
1912
|
const r = Math.sqrt(n) * Math.sqrt(o);
|
|
1905
1913
|
return r === 0 ? void 0 : a / r;
|
|
1906
1914
|
}
|
|
1907
|
-
async function
|
|
1908
|
-
const [
|
|
1909
|
-
if (!
|
|
1915
|
+
async function ge(e) {
|
|
1916
|
+
const [t] = await qe([e]);
|
|
1917
|
+
if (!t)
|
|
1910
1918
|
throw new Error("Expected one query embedding.");
|
|
1911
|
-
return
|
|
1919
|
+
return t;
|
|
1912
1920
|
}
|
|
1913
|
-
function
|
|
1921
|
+
function vn(e, t, a) {
|
|
1914
1922
|
const n = /* @__PURE__ */ new Map();
|
|
1915
|
-
return
|
|
1923
|
+
return he(n, e, "keyword"), he(n, t, "semantic"), [...n.values()].sort((o, r) => r.score !== o.score ? r.score - o.score : (r.semanticScore ?? 0) !== (o.semanticScore ?? 0) ? (r.semanticScore ?? 0) - (o.semanticScore ?? 0) : (r.keywordScore ?? 0) !== (o.keywordScore ?? 0) ? (r.keywordScore ?? 0) - (o.keywordScore ?? 0) : o.capability.id.localeCompare(r.capability.id)).slice(0, Math.max(0, a));
|
|
1916
1924
|
}
|
|
1917
|
-
function
|
|
1918
|
-
for (const [n, { capability: o, score: r }] of
|
|
1919
|
-
const c = n + 1, i =
|
|
1920
|
-
i.score += 1 / (
|
|
1925
|
+
function he(e, t, a) {
|
|
1926
|
+
for (const [n, { capability: o, score: r }] of t.entries()) {
|
|
1927
|
+
const c = n + 1, i = e.get(o.id) ?? { capability: o, score: 0 };
|
|
1928
|
+
i.score += 1 / (dn + c), a === "keyword" ? (i.keywordRank = c, i.keywordScore = r) : (i.semanticRank = c, i.semanticScore = r), e.set(o.id, i);
|
|
1921
1929
|
}
|
|
1922
1930
|
}
|
|
1923
|
-
function
|
|
1924
|
-
return
|
|
1931
|
+
function ke(e, t) {
|
|
1932
|
+
return t.score - e.score || e.capability.id.localeCompare(t.capability.id);
|
|
1925
1933
|
}
|
|
1926
|
-
const
|
|
1927
|
-
await m({ text: "Finding a place to navigate...", agentName: "navigation" },
|
|
1928
|
-
const a = I(
|
|
1934
|
+
const In = async (e, t) => {
|
|
1935
|
+
await m({ text: "Finding a place to navigate...", agentName: "navigation" }, t);
|
|
1936
|
+
const a = I(e.agentExecutionContext.messages).trim();
|
|
1929
1937
|
try {
|
|
1930
|
-
const n = await
|
|
1938
|
+
const n = await gn(a, { topN: 5 });
|
|
1931
1939
|
return console.table(
|
|
1932
1940
|
n.matches.map(({ capability: o, keywordRank: r, keywordScore: c, semanticRank: i, semanticScore: l, score: u }) => ({
|
|
1933
1941
|
capability: o.title,
|
|
@@ -1940,7 +1948,7 @@ const xn = async (t, e) => {
|
|
|
1940
1948
|
), n.degradedReason && console.info("[arcgis-portal-ai-assistant] navigation semantic search:", n.degradedReason), {
|
|
1941
1949
|
chosenCapabilityIds: [],
|
|
1942
1950
|
retrievalDegraded: n.degradedReason ?? "",
|
|
1943
|
-
targets:
|
|
1951
|
+
targets: Sn(a, n.matches)
|
|
1944
1952
|
};
|
|
1945
1953
|
} catch {
|
|
1946
1954
|
return {
|
|
@@ -1951,78 +1959,78 @@ const xn = async (t, e) => {
|
|
|
1951
1959
|
};
|
|
1952
1960
|
}
|
|
1953
1961
|
};
|
|
1954
|
-
function
|
|
1955
|
-
const a = $(
|
|
1962
|
+
function Sn(e, t) {
|
|
1963
|
+
const a = $(e), n = t.filter(
|
|
1956
1964
|
({ capability: r }) => [r.title, ...r.hints].some(
|
|
1957
1965
|
(c) => $(c) === a
|
|
1958
1966
|
)
|
|
1959
1967
|
);
|
|
1960
1968
|
if (n.length !== 1)
|
|
1961
|
-
return
|
|
1969
|
+
return t;
|
|
1962
1970
|
const [o] = n;
|
|
1963
|
-
return [o, ...
|
|
1971
|
+
return [o, ...t.filter((r) => r !== o)];
|
|
1964
1972
|
}
|
|
1965
|
-
const V = (
|
|
1973
|
+
const V = (e, t) => t ?? e, ze = h.Root({
|
|
1966
1974
|
...G(),
|
|
1967
1975
|
chosenCapabilityIds: h({ reducer: V, default: () => [] }),
|
|
1968
1976
|
// Empty when hybrid keyword-and-semantic retrieval succeeds; otherwise
|
|
1969
1977
|
// contains the semantic-search failure reason for response diagnostics.
|
|
1970
1978
|
retrievalDegraded: h({ reducer: V, default: () => "" }),
|
|
1971
1979
|
targets: h({ reducer: V, default: () => [] })
|
|
1972
|
-
}),
|
|
1973
|
-
function
|
|
1974
|
-
const
|
|
1980
|
+
}), xn = () => new A(ze).addNode("retrieveNavigationTargets", In).addNode("chooseNavigationTargets", ja).addNode("respondWithNavigation", an).addEdge(N, "retrieveNavigationTargets").addEdge("retrieveNavigationTargets", "chooseNavigationTargets").addEdge("chooseNavigationTargets", "respondWithNavigation").addEdge("respondWithNavigation", w);
|
|
1981
|
+
function Tn() {
|
|
1982
|
+
const e = x().map(({ hints: t, title: a }) => t[0] ?? a).join(", ");
|
|
1975
1983
|
return String.raw`- **portal-navigation** - Portal page navigation assistant:
|
|
1976
1984
|
- routes requests to open, show, or navigate to a Portal page, including creation-flow pages
|
|
1977
1985
|
- falls back to the closest Portal page where a workflow starts when another agent cannot perform the action
|
|
1978
1986
|
- handles short navigation follow-ups after asking the user to open a page
|
|
1979
|
-
- capability examples: ${
|
|
1987
|
+
- capability examples: ${e}
|
|
1980
1988
|
- do not use for general "how do I" questions unless the user explicitly asks to reach a page
|
|
1981
1989
|
`;
|
|
1982
1990
|
}
|
|
1983
|
-
const
|
|
1991
|
+
const Mn = {
|
|
1984
1992
|
id: "navigation",
|
|
1985
1993
|
name: "Portal Navigation",
|
|
1986
1994
|
get description() {
|
|
1987
|
-
return
|
|
1995
|
+
return Tn();
|
|
1988
1996
|
},
|
|
1989
|
-
createGraph:
|
|
1990
|
-
workspace:
|
|
1991
|
-
},
|
|
1992
|
-
function
|
|
1993
|
-
if (!
|
|
1997
|
+
createGraph: xn,
|
|
1998
|
+
workspace: ze
|
|
1999
|
+
}, Cn = Oe`: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)}`;
|
|
2000
|
+
function An(e, t) {
|
|
2001
|
+
if (!t)
|
|
1994
2002
|
return;
|
|
1995
|
-
const { destinationType: a } =
|
|
2003
|
+
const { destinationType: a } = e;
|
|
1996
2004
|
switch (a) {
|
|
1997
2005
|
case "portal-content":
|
|
1998
|
-
return
|
|
2006
|
+
return t[a]?.(e.hash, e.queryParams);
|
|
1999
2007
|
case "portal-groups":
|
|
2000
|
-
return
|
|
2008
|
+
return t[a]?.(e.hash);
|
|
2001
2009
|
case "portal-org":
|
|
2002
|
-
return
|
|
2010
|
+
return t[a]?.(e.hash, e.queryParams);
|
|
2003
2011
|
case "portal-gallery":
|
|
2004
|
-
return
|
|
2012
|
+
return t[a];
|
|
2005
2013
|
case "portal-map-viewer":
|
|
2006
2014
|
case "portal-notebooks":
|
|
2007
2015
|
case "portal-scene-viewer":
|
|
2008
|
-
return
|
|
2016
|
+
return t[a];
|
|
2009
2017
|
case "portal-item":
|
|
2010
|
-
return
|
|
2018
|
+
return t[a]?.(e.itemId);
|
|
2011
2019
|
case "portal-group":
|
|
2012
|
-
return
|
|
2020
|
+
return t[a]?.(e.groupId);
|
|
2013
2021
|
default:
|
|
2014
|
-
return
|
|
2022
|
+
return R(a);
|
|
2015
2023
|
}
|
|
2016
2024
|
}
|
|
2017
|
-
function
|
|
2018
|
-
const
|
|
2019
|
-
return
|
|
2025
|
+
function Nn(e) {
|
|
2026
|
+
const t = Ct.safeParse(e);
|
|
2027
|
+
return t.success ? t.data : void 0;
|
|
2020
2028
|
}
|
|
2021
|
-
function
|
|
2022
|
-
const a =
|
|
2023
|
-
switch (
|
|
2029
|
+
function Gn(e, t) {
|
|
2030
|
+
const a = t.navigation;
|
|
2031
|
+
switch (e.destinationType) {
|
|
2024
2032
|
case "portal-content":
|
|
2025
|
-
switch (
|
|
2033
|
+
switch (e.hash) {
|
|
2026
2034
|
case "favorites":
|
|
2027
2035
|
return a.openContentFavorites;
|
|
2028
2036
|
case "group":
|
|
@@ -2037,7 +2045,7 @@ function qn(t, e) {
|
|
|
2037
2045
|
case "portal-gallery":
|
|
2038
2046
|
return a.openGallery;
|
|
2039
2047
|
case "portal-groups":
|
|
2040
|
-
switch (
|
|
2048
|
+
switch (e.hash) {
|
|
2041
2049
|
case "featured":
|
|
2042
2050
|
return a.openGroupsFeatured;
|
|
2043
2051
|
case "my":
|
|
@@ -2060,74 +2068,74 @@ function qn(t, e) {
|
|
|
2060
2068
|
case "portal-group":
|
|
2061
2069
|
return a.openGroup;
|
|
2062
2070
|
default:
|
|
2063
|
-
return
|
|
2071
|
+
return R(e);
|
|
2064
2072
|
}
|
|
2065
2073
|
}
|
|
2066
|
-
class
|
|
2074
|
+
class Pn extends Ue {
|
|
2067
2075
|
constructor() {
|
|
2068
|
-
super(), this.t9n =
|
|
2069
|
-
const a =
|
|
2076
|
+
super(), this.t9n = je({ blocking: !0 }), this.assistantEl = P(), this.formEl = P(), this.voiceInputEl = P(), this.inputEl = P(), this.navigationSlotElements = /* @__PURE__ */ new Map(), this.handleSlottableRequest = (t) => {
|
|
2077
|
+
const a = t.detail, n = a.data?.block;
|
|
2070
2078
|
if (!n)
|
|
2071
2079
|
return;
|
|
2072
2080
|
const o = this.getNavigationAction(n);
|
|
2073
2081
|
o && this.upsertNavigationSlotElement(a.slotName, o);
|
|
2074
|
-
}, this.inputText = "", this.showVoiceInput = !0, this.isListening = !1, this.isVoiceInputDisabled = !1, this.interrupt = null, this.autoDestroyDisabled = !1, this.defaultClosed = !1, this.arcgisPortalNavigationRequest =
|
|
2082
|
+
}, this.inputText = "", this.showVoiceInput = !0, this.isListening = !1, this.isVoiceInputDisabled = !1, this.interrupt = null, this.autoDestroyDisabled = !1, this.defaultClosed = !1, this.arcgisPortalNavigationRequest = Fe(), x();
|
|
2075
2083
|
}
|
|
2076
2084
|
static {
|
|
2077
2085
|
this.properties = { inputText: 16, showVoiceInput: 16, isListening: 16, isVoiceInputDisabled: 16, interrupt: 16, autoDestroyDisabled: 5, portal: 0, user: 0, config: 0, navigationTargetMap: 0, disabledAgents: 0, defaultClosed: 5, navigationCapabilities: 0 };
|
|
2078
2086
|
}
|
|
2079
2087
|
static {
|
|
2080
|
-
this.styles =
|
|
2088
|
+
this.styles = Cn;
|
|
2081
2089
|
}
|
|
2082
2090
|
async load() {
|
|
2083
2091
|
await this.refreshCapabilityEmbeddings();
|
|
2084
2092
|
}
|
|
2085
|
-
willUpdate(
|
|
2086
|
-
!this.hasUpdated || !
|
|
2093
|
+
willUpdate(t) {
|
|
2094
|
+
!this.hasUpdated || !t.has("navigationCapabilities") || this.refreshCapabilityEmbeddings();
|
|
2087
2095
|
}
|
|
2088
2096
|
async clearEmbeddingsCache() {
|
|
2089
|
-
|
|
2097
|
+
le();
|
|
2090
2098
|
}
|
|
2091
|
-
isAgentEnabled(
|
|
2092
|
-
return !this.disabledAgents?.[
|
|
2099
|
+
isAgentEnabled(t) {
|
|
2100
|
+
return !this.disabledAgents?.[t];
|
|
2093
2101
|
}
|
|
2094
2102
|
async refreshCapabilityEmbeddings() {
|
|
2095
2103
|
try {
|
|
2096
|
-
x(this.navigationCapabilities),
|
|
2097
|
-
} catch (
|
|
2098
|
-
console.warn("[arcgis-portal-ai-assistant] embeddings warm-up failed:",
|
|
2104
|
+
x(this.navigationCapabilities), mn(), le(), await rn();
|
|
2105
|
+
} catch (t) {
|
|
2106
|
+
console.warn("[arcgis-portal-ai-assistant] embeddings warm-up failed:", t);
|
|
2099
2107
|
}
|
|
2100
2108
|
}
|
|
2101
|
-
getNavigationAction(
|
|
2102
|
-
if (
|
|
2109
|
+
getNavigationAction(t) {
|
|
2110
|
+
if (t?.type !== be)
|
|
2103
2111
|
return;
|
|
2104
|
-
const a =
|
|
2112
|
+
const a = t.data, n = Nn(a);
|
|
2105
2113
|
if (!n)
|
|
2106
2114
|
return;
|
|
2107
|
-
const o =
|
|
2115
|
+
const o = An(a, this.navigationTargetMap);
|
|
2108
2116
|
if (o)
|
|
2109
2117
|
return {
|
|
2110
2118
|
href: o,
|
|
2111
2119
|
targetDetail: a,
|
|
2112
|
-
label: a?.buttonLabel ||
|
|
2120
|
+
label: a?.buttonLabel || Gn(n, this.t9n)
|
|
2113
2121
|
};
|
|
2114
2122
|
}
|
|
2115
|
-
upsertNavigationSlotElement(
|
|
2123
|
+
upsertNavigationSlotElement(t, a) {
|
|
2116
2124
|
const n = this.assistantEl.value;
|
|
2117
2125
|
if (!n)
|
|
2118
2126
|
return;
|
|
2119
|
-
const o = `navigation:${
|
|
2127
|
+
const o = `navigation:${t}`;
|
|
2120
2128
|
let r = this.navigationSlotElements.get(o);
|
|
2121
|
-
r || (r = document.createElement("div"), r.slot =
|
|
2129
|
+
r || (r = document.createElement("div"), r.slot = t, this.navigationSlotElements.set(o, r), n.append(r)), Le(b`<div><calcite-button class="navigation-button" appearance=outline width=full .href=${a.href} icon-end=launch @click=${(c) => {
|
|
2122
2130
|
c.preventDefault(), this.arcgisPortalNavigationRequest.emit({
|
|
2123
2131
|
href: a.href,
|
|
2124
2132
|
targetDetail: a.targetDetail
|
|
2125
2133
|
});
|
|
2126
|
-
}}>${a.label}</calcite-button>${a.description ?
|
|
2134
|
+
}}>${a.label}</calcite-button>${a.description ? b`<div class="navigation-block-description">${a.description}</div>` : null}</div>`, r);
|
|
2127
2135
|
}
|
|
2128
2136
|
render() {
|
|
2129
|
-
const { t9n:
|
|
2130
|
-
return
|
|
2137
|
+
const { t9n: t, inputText: a, portal: n, user: o, navigationTargetMap: r, showVoiceInput: c, isListening: i, isVoiceInputDisabled: l } = this;
|
|
2138
|
+
return b`<arcgis-assistant log-enabled keep-suggested-prompts .heading=${t.heading} .entryMessage=${t.entryMessage} @arcgisSlottableRequest=${this.handleSlottableRequest} @arcgisInterrupt=${({ detail: u }) => {
|
|
2131
2139
|
this.interrupt = u;
|
|
2132
2140
|
}} @arcgisInterruptCancel=${() => {
|
|
2133
2141
|
this.interrupt = null;
|
|
@@ -2141,7 +2149,7 @@ class En extends Ut {
|
|
|
2141
2149
|
u.preventDefault();
|
|
2142
2150
|
const d = a.trim();
|
|
2143
2151
|
d && (this.assistantEl.value?.submitMessage(d), this.inputText = "");
|
|
2144
|
-
}} ${q(this.formEl)}><arcgis-portal-mentionable-text-area .portal=${n} .user=${o} rows=3 .popoverListLabel=${
|
|
2152
|
+
}} ${q(this.formEl)}><arcgis-portal-mentionable-text-area .portal=${n} .user=${o} rows=3 .popoverListLabel=${t.mentionEntities} .placeholder=${t.placeholder} .value=${a} @arcgisUserMentionableTextAreaKeyDown=${({ detail: u }) => {
|
|
2145
2153
|
u.key === "Enter" && !u.shiftKey && (u.preventDefault(), this.formEl.value?.requestSubmit());
|
|
2146
2154
|
}} @arcgisUserMentionableTextAreaChange=${({ detail: u }) => {
|
|
2147
2155
|
this.inputText = u ?? "";
|
|
@@ -2153,18 +2161,18 @@ class En extends Ut {
|
|
|
2153
2161
|
u.detail.errorCode === "not-supported" && (this.showVoiceInput = !1);
|
|
2154
2162
|
}} @arcgisVoiceInputInterimTranscription=${(u) => {
|
|
2155
2163
|
this.inputText = u.detail.text;
|
|
2156
|
-
}} ${q(this.voiceInputEl)}></arcgis-portal-voice-input>${c &&
|
|
2164
|
+
}} ${q(this.voiceInputEl)}></arcgis-portal-voice-input>${c && b`<calcite-button icon-start=microphone .label=${t.voiceInput} round .disabled=${l} .appearance=${i ? "solid" : "outline-fill"} @click=${async () => {
|
|
2157
2165
|
this.isVoiceInputDisabled = !0;
|
|
2158
2166
|
const u = this.voiceInputEl.value;
|
|
2159
2167
|
i ? await u?.stopListening() : await u?.startListening();
|
|
2160
|
-
}}></calcite-button>` || ""}<calcite-button type=submit icon-start=send round .disabled=${!a.trim()} .label=${
|
|
2168
|
+
}}></calcite-button>` || ""}<calcite-button type=submit icon-start=send round .disabled=${!a.trim()} .label=${t.send}>${t.send}</calcite-button></div></form>${this.isAgentEnabled("itemAnalytics") && b`<arcgis-assistant-agent .agent=${za} .context=${{ portal: n, user: o, navigationTargetMap: r }}></arcgis-assistant-agent>` || ""}${this.isAgentEnabled("groupCreation") && b`<arcgis-assistant-agent .agent=${Pt} .context=${{ portal: n, user: o, navigationTargetMap: r }}></arcgis-assistant-agent>` || ""}${this.isAgentEnabled("docAssistant") && b`<arcgis-assistant-agent .agent=${ea} .context=${{ portal: n, user: o, navigationTargetMap: r }}></arcgis-assistant-agent>` || ""}${this.isAgentEnabled("groupAnalytics") && b`<arcgis-assistant-agent .agent=${Sa} .context=${{ portal: n, user: o, navigationTargetMap: r }}></arcgis-assistant-agent>` || ""}${this.isAgentEnabled("navigation") && b`<arcgis-assistant-agent .agent=${Mn} .context=${{ portal: n, user: o, navigationTargetMap: r }}></arcgis-assistant-agent>` || ""}${this.interrupt && b`<arcgis-portal-ai-assistant-interrupt slot=interrupt .type=${this.interrupt.type} .message=${this.interrupt.message} .options=${this.interrupt.options} @arcgisSubmit=${({ detail: u }) => {
|
|
2161
2169
|
this.assistantEl.value?.submitInterrupt(u);
|
|
2162
2170
|
}} @arcgisCancel=${() => {
|
|
2163
2171
|
this.assistantEl.value?.cancelInterrupt();
|
|
2164
2172
|
}}></arcgis-portal-ai-assistant-interrupt>` || ""}</arcgis-assistant>`;
|
|
2165
2173
|
}
|
|
2166
2174
|
}
|
|
2167
|
-
|
|
2175
|
+
De("arcgis-portal-ai-assistant", Pn);
|
|
2168
2176
|
export {
|
|
2169
|
-
|
|
2177
|
+
Pn as ArcgisPortalAiAssistant
|
|
2170
2178
|
};
|