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