@esri/solutions-components 5.1.0-next.136 → 5.1.0-next.138
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/{JSQHZGE3.js → 33UAZ7BX.js} +42 -42
- package/dist/cdn/3CSMIYZV.js +2 -0
- package/dist/cdn/{3JAQDSSF.js → 4753O4WX.js} +1 -1
- package/dist/cdn/{FOTFZKKU.js → 52QHFDTC.js} +1 -1
- package/dist/cdn/{YZVDT3ZT.js → 6RHH635X.js} +1 -1
- package/dist/cdn/{S5F6KJQM.js → 7J2F4TFI.js} +1 -1
- package/dist/cdn/{NOI3DSNQ.js → 7MFLK6JZ.js} +1 -1
- package/dist/cdn/{6SSQ6MIC.js → 7NAC32PQ.js} +1 -1
- package/dist/cdn/{WQVOA4KV.js → AYQT4HC4.js} +1 -1
- package/dist/cdn/BNRFT546.js +2 -0
- package/dist/cdn/{75WQ7UGJ.js → D4MZYBH7.js} +1 -1
- package/dist/cdn/DGNAMFJN.js +9 -0
- package/dist/cdn/{ZTO4S3BZ.js → E5EU4SVV.js} +1 -1
- package/dist/cdn/F3NG6RFP.js +117 -0
- package/dist/cdn/GWWU6HWB.js +48 -0
- package/dist/cdn/{TWJSFINX.js → KGSB4I6Y.js} +1 -1
- package/dist/cdn/{OPKSJ73H.js → NPYWZIAM.js} +1 -1
- package/dist/cdn/{VFBFI3KQ.js → NWCKV677.js} +1 -1
- package/dist/cdn/{P6ANTPJW.js → OYBEDO63.js} +1 -1
- package/dist/cdn/{I26GSBKY.js → RDAHPMNW.js} +1 -1
- package/dist/cdn/{TV3ZHJ7B.js → SAJPXZDW.js} +1 -1
- package/dist/cdn/SEHNIZKR.js +2 -0
- package/dist/cdn/WGOI2WQZ.js +2 -0
- package/dist/cdn/{R7NCPIS3.js → XVRJTKAB.js} +26 -26
- package/dist/cdn/{PPRV6EZZ.js → ZIX74MNU.js} +1 -1
- package/dist/cdn/assets/arcgis-solutions-assistant/t9n/messages.en.json +1 -1
- package/dist/cdn/assets/arcgis-solutions-assistant/t9n/messages.json +1 -1
- package/dist/cdn/assets/solution-builder-assistant/t9n/messages.en.json +1 -1
- package/dist/cdn/assets/solution-builder-assistant/t9n/messages.json +1 -1
- package/dist/cdn/index.js +1 -1
- package/dist/chunks/assistantResponse.js +51 -0
- package/dist/chunks/classifyIntent.js +120 -0
- package/dist/chunks/description.js +7 -31
- package/dist/chunks/description2.js +36 -0
- package/dist/chunks/solution-builder-assistant.js +935 -0
- package/dist/chunks/validators.js +1 -1
- package/dist/components/arcgis-solutions-assistant/customElement.js +596 -564
- package/dist/components/crowdsource-manager/customElement.js +7 -6
- package/dist/components/solution-builder-assistant/customElement.d.ts +62 -2
- package/dist/components/solution-builder-assistant/customElement.js +14 -883
- package/dist/components/solutions-deploy-app/customElement.js +21 -20
- package/dist/docs/api.json +1 -1
- package/dist/docs/docs.json +1 -1
- package/dist/docs/web-types.json +1 -1
- package/dist/solutions-components_commit.txt +5 -8
- package/package.json +5 -4
- package/dist/cdn/DJMULVG5.js +0 -2
- package/dist/cdn/JMO7ZFWL.js +0 -26
- package/dist/cdn/JQLLXM7G.js +0 -11
- package/dist/cdn/PSHFIPGT.js +0 -2
- package/dist/cdn/RSPGZ5RN.js +0 -2
- package/dist/cdn/ZS3UOY5Q.js +0 -2
- package/dist/chunks/solutions_assistant_description.js +0 -14
- package/dist/chunks/solutions_assistant_prompts.js +0 -29
- /package/dist/cdn/{GYL4W6ZG.js → JDCZUOU6.js} +0 -0
|
@@ -1,29 +1,29 @@
|
|
|
1
1
|
/* COPYRIGHT Esri - https://js.arcgis.com/5.1/LICENSE.txt */
|
|
2
|
-
import { c as
|
|
3
|
-
import { u as
|
|
4
|
-
import { LitElement as
|
|
5
|
-
import { css as
|
|
6
|
-
import { unsafeHTML as
|
|
7
|
-
import { useContextConsumer as
|
|
8
|
-
import { c as
|
|
9
|
-
import { T as
|
|
2
|
+
import { c as Se } from "../../chunks/runtime.js";
|
|
3
|
+
import { u as Ie } from "../../chunks/useT9n.js";
|
|
4
|
+
import { LitElement as Ce, createEvent as Y, nothing as Z } from "@arcgis/lumina";
|
|
5
|
+
import { css as _e, html as k } from "lit";
|
|
6
|
+
import { unsafeHTML as ke } from "lit/directives/unsafe-html.js";
|
|
7
|
+
import { useContextConsumer as X } from "@arcgis/lumina/context";
|
|
8
|
+
import { c as Te, b as Ee } from "../../chunks/deployAppContexts.js";
|
|
9
|
+
import { T as Ae } from "../../chunks/interfaces.js";
|
|
10
10
|
import { c as De } from "../../chunks/helpers.js";
|
|
11
|
-
import
|
|
12
|
-
import { createRef as
|
|
13
|
-
import {
|
|
14
|
-
import { createAgentRuntimeState as
|
|
15
|
-
import
|
|
16
|
-
import
|
|
11
|
+
import ee from "@arcgis/core/config.js";
|
|
12
|
+
import { createRef as Le, ref as Me } from "lit-html/directives/ref.js";
|
|
13
|
+
import { StateGraph as U, START as z, END as I, Annotation as f, NodeInterrupt as se } from "@langchain/langgraph/web";
|
|
14
|
+
import { createAgentRuntimeState as O, sendTraceMessage as w, invokeStructuredPrompt as A, getEmbeddings as Re, cosineSimilarity as $e, invokeTextPrompt as Fe } from "@arcgis/ai-orchestrator";
|
|
15
|
+
import r, { z as M } from "zod";
|
|
16
|
+
import * as j from "@esri/arcgis-rest-portal";
|
|
17
|
+
import { applyPatch as Pe } from "fast-json-patch";
|
|
17
18
|
import "@langchain/core/messages";
|
|
18
|
-
import { C as
|
|
19
|
-
import
|
|
20
|
-
import
|
|
21
|
-
import Ue from "@arcgis/core/portal/Portal.js";
|
|
19
|
+
import { C as ne } from "../../chunks/converter.js";
|
|
20
|
+
import { g as P, d as ie, r as oe, t as Ne, T as E } from "../../chunks/templates.js";
|
|
21
|
+
import Be from "@arcgis/core/portal/Portal.js";
|
|
22
22
|
import qe from "@arcgis/core/portal/PortalItem.js";
|
|
23
|
-
const
|
|
24
|
-
async function
|
|
23
|
+
const Ue = _e`:host{display:block;height:100%}.margin-lg{margin:var(--calcite-spacing-lg)}.display-flex-row{display:flex;flex-direction:row}.assistant-split-container{display:flex;width:100%;height:calc(100vh - 78px);overflow:hidden;border-radius:10px}.assistant-panel{display:flex;flex-direction:column;height:100%;border:1px solid var(--calcite-color-surface-3);background-color:var(--calcite-color-surface-2);overflow:hidden}.chat-panel{min-width:320px}.builder-panel{min-width:320px;max-width:100%;border-left:1px solid var(--calcite-color-surface-3)}.panel-actions{display:flex;gap:8px;padding:6px;align-items:center}.builder-header,.builder-footer{padding:10px;background:var(--calcite-color-surface-1);border-bottom:1px solid var(--calcite-color-surface-3)}.builder-content{flex:1;overflow:auto;padding:12px}.builder-content pre{white-space:pre-wrap;word-wrap:break-word;max-height:100%;overflow:auto}.builder-actions{display:flex;gap:6px;align-items:center}.padding-left-10{padding-left:10px}.chat-container{display:flex;flex-direction:column;gap:0px;max-width:600px;height:75%;background-color:var(--calcite-color-surface-4);padding:1px}.chat-container_expanded{display:flex;flex-direction:column;gap:0px;max-width:100%;height:95%;background-color:var(--calcite-color-surface-1);border-radius:10px;padding:10px}.chat-panel{--calcite-color-focus: var(--calcite-color-brand);--calcite-panel-border-color: var(--calcite-color-border-2);--calcite-internal-panel-header-vertical-padding: 0px;--calcite-panel-header-content-space: 0px;border:var(--calcite-border-width-sm) solid var(--calcite-color-border-2);height:100%}.header-content{display:flex;align-items:center;gap:var(--calcite-spacing-sm);height:65px;box-sizing:border-box;padding-inline-start:var(--calcite-space-2xl)}.header-title{font-size:var(--calcite-font-size-md);font-weight:var(--calcite-font-weight-medium);color:var(--calcite-color-text-1)}.beta-chip{--calcite-chip-corner-radius: var(--calcite-corner-radius-half)}.chat-panel calcite-card,.chat-panel calcite-text-area,.chat-panel calcite-button,.chat-panel .chat-messages,.chat-panel .chat-input{--calcite-color-focus: var(--calcite-color-brand)}.assistant-followup-chip:focus{outline:2px solid var(--calcite-color-brand)}.chat-panel-heading{font-size:var(--calcite-font-size-0);font-weight:var(--calcite-font-weight-medium);color:var(--calcite-color-surface-1, var(--calcite-color-text-1))}.chat-messages{display:flex;flex-direction:column;gap:20px;padding:4px;height:100%;overflow-y:auto}.user-message{align-self:flex-end;background:var(--calcite-color-brand);border-radius:8px;max-width:90%;--calcite-card-corner-radius: 8px;--calcite-card-background-color: var(--calcite-color-brand);--calcite-card-border-color: var(--calcite-color-brand);color:var(--calcite-color-text-inverse);text-align:left}.system-message{align-self:flex-start;background:var(--calcite-color-surface-3);border-radius:8px;max-width:90%;--calcite-card-corner-radius: 8px;--calcite-card-background-color: var(--calcite-color-surface-4);--calcite-card-border-color: var(--calcite-color-surface-4);color:var(--calcite-color-inverse);text-align:left}.loader-message{align-self:flex-start;background:var(--calcite-color-surface-4);border-radius:8px;--calcite-card-corner-radius: 8px;--calcite-card-background-color: var(--calcite-color-surface-4);--calcite-card-border-color: var(--calcite-color-surface-4)}.message-content{padding:0;font-size:14px}.response-message.message-content>p:first-of-type{margin-top:0}.message-content img{max-width:100%;height:auto;display:block;object-fit:contain}.message-content-pad{padding-bottom:10px;font-size:14px}.message-content-summary{padding-bottom:14px}.message-content-alignment{display:flex;align-items:center;gap:var(--calcite-spacing-md);font-size:var(--calcite-font-size--1);color:var(--calcite-color-text-1)}.padding-top-10{padding-top:10px}.padding-right-8{padding-right:8px}.padding-left-right-5{padding-right:5px;padding-left:5px}.chip-content{padding:5px 5px 5px 0}.chat-input{display:flex;flex-direction:row;flex-grow:1}.table-cell{--calcite-table-cell-background: var(--calcite-color-surface-4)}.cursor-pointer{cursor:pointer}.notice-border-color{--temp-initial-brand: var(--calcite-color-brand)}.notice-border-color calcite-notice{--calcite-color-brand: #ddd;--calcite-icon-color: var(--temp-initial-brand)}.notice-border-color calcite-notice *{--calcite-color-brand: var(--temp-initial-brand)}.solution-card{padding:5px 0;text-decoration:none;display:block;width:100%;cursor:pointer}.solution-card calcite-card{display:flex;flex-direction:column;max-width:520px;overflow:hidden;--calcite-card-corner-radius: var(--calcite-corner-radius-round) !important;--calcite-card-shadow: var(--calcite-shadow-sm);--calcite-card-background-color: var(--calcite-card-background-color) }.solution-card div[slot=thumbnail]{max-height:100%;width:100%;position:relative;&:after{content:"";position:absolute;top:0;left:0;width:100%;height:100%;transition:all .15s ease-in-out}}.solution-card div[slot=thumbnail] img{max-height:100%;width:100%;object-fit:cover}.solution-card span[slot=description]{padding-top:10px}.solution-card calcite-chip{position:absolute;top:50%;left:50%;transform:translate(-50%,-50%);visibility:hidden;pointer-events:none;opacity:0;transition:all .15s ease-in-out;z-index:9999}.solution-card:hover calcite-chip{visibility:visible;opacity:1}.solution-card:hover div[slot=thumbnail]:after{background-color:#00000080}.solution-card:hover h3{text-decoration:underline}.solution-card:focus{outline:2px solid var(--calcite-color-brand)}.references-container{padding-top:10px;display:block}.references-container.collapsed{display:none}.width-100{width:100%}.disclaimer-div{display:flex;align-items:center;gap:var(--calcite-spacing-sm);font-size:var(--calcite-font-size--0);color:var(--calcite-color-text-1)}.display-none{display:none}.chat-messages calcite-fab{position:absolute;bottom:16px;left:50%;transform:translate(-50%);z-index:999}.icon-color-background{--calcite-button-icon-color: var(--calcite-color-surface-1)}#closeAssistantButton{--calcite-action-text-color: var(--calcite-color-text-1)}.icon-color-background:focus{--calcite-color-focus: var(--calcite-color-surface-1)}@media(max-width:430px){.solution-card .solution-snippet{display:none}}.height-32-flex-auto{height:32px;flex:0 0 auto}.margin-top-0.message-content>p:first-of-type{margin-top:0}a:not(.solution-card){color:var(--calcite-link-text-color, var(--calcite-color-text-link));cursor:pointer;text-decoration:none;line-height:inherit;background-image:linear-gradient(currentColor,currentColor),linear-gradient(var(--calcite-color-brand-underline),var(--calcite-color-brand-underline));background-position-x:0%,100%;background-position-y:min(1.5em,100%);background-repeat:no-repeat,no-repeat;background-size:0% 1px,100% 1px;transition-property:background-size,color;transition-duration:var(--calcite-animation-timing, .15s);transition-timing-function:ease-in-out;outline-color:transparent;position:relative}a:not(.solution-card):hover{background-size:100% 1px,100% 1px}a:not(.solution-card):focus{outline:2px solid var(--calcite-color-brand);outline-offset:2px;outline-color:var(--calcite-color-brand)}a:not(.solution-card):active{color:var(--calcite-color-brand-press)}`;
|
|
24
|
+
async function x(t, e) {
|
|
25
25
|
const s = Object.entries(t).find(
|
|
26
|
-
([
|
|
26
|
+
([n]) => n.endsWith(`/${e}.md`)
|
|
27
27
|
);
|
|
28
28
|
if (!s)
|
|
29
29
|
throw new Error(
|
|
@@ -34,13 +34,13 @@ ${Object.keys(t).join(`
|
|
|
34
34
|
);
|
|
35
35
|
return await s[1]();
|
|
36
36
|
}
|
|
37
|
-
function
|
|
37
|
+
function N(t) {
|
|
38
38
|
return t?.configurable?.context?.translations;
|
|
39
39
|
}
|
|
40
|
-
function
|
|
40
|
+
function ae(t) {
|
|
41
41
|
if (typeof window > "u" || t.length <= 1)
|
|
42
42
|
return;
|
|
43
|
-
const e = t.map((
|
|
43
|
+
const e = t.map((n) => n.solution.id), s = t.map((n) => n.solution.title);
|
|
44
44
|
window.dispatchEvent(new CustomEvent("searchTermSet", {
|
|
45
45
|
detail: {
|
|
46
46
|
scope: "all-solutions",
|
|
@@ -59,7 +59,7 @@ function ne(t) {
|
|
|
59
59
|
}
|
|
60
60
|
}));
|
|
61
61
|
}
|
|
62
|
-
function
|
|
62
|
+
function re(t) {
|
|
63
63
|
if (typeof window > "u" || !t)
|
|
64
64
|
return;
|
|
65
65
|
const e = new CustomEvent("solutionIDFromAssistant", {
|
|
@@ -69,35 +69,165 @@ function oe(t) {
|
|
|
69
69
|
});
|
|
70
70
|
window.dispatchEvent(e);
|
|
71
71
|
}
|
|
72
|
-
const
|
|
73
|
-
"./prompts/
|
|
74
|
-
|
|
75
|
-
|
|
76
|
-
|
|
77
|
-
}
|
|
78
|
-
|
|
79
|
-
|
|
80
|
-
|
|
72
|
+
const ze = /* @__PURE__ */ Object.assign({
|
|
73
|
+
"./prompts/solutions_explorer_description.md": () => import("../../chunks/solutions_explorer_description.js").then((t) => t.default)
|
|
74
|
+
});
|
|
75
|
+
function Oe(t) {
|
|
76
|
+
return t.replace(/<sup>\[\[(\d+)\]\]\(([^)]+)\)<\/sup>/g, '<sup><a href="$2">[$1]</a></sup>');
|
|
77
|
+
}
|
|
78
|
+
function je(t, e) {
|
|
79
|
+
const s = [];
|
|
80
|
+
return (e?.configurable?.context?.configContext.allCards ?? []).forEach((i) => {
|
|
81
|
+
const o = i.title;
|
|
82
|
+
if (t.toLowerCase().includes(o.toLowerCase())) {
|
|
83
|
+
const a = `<a href="" target="solutionId:${i.deployCommonId}">${o}</a>`, l = new RegExp(o, "gi");
|
|
84
|
+
t = t.replace(l, a), s.push({
|
|
85
|
+
solution: {
|
|
86
|
+
title: i.title,
|
|
87
|
+
id: i.deployCommonId,
|
|
88
|
+
snippet: i.snippet,
|
|
89
|
+
description: i.description
|
|
90
|
+
},
|
|
91
|
+
score: 100
|
|
92
|
+
});
|
|
93
|
+
}
|
|
94
|
+
}), { source: t, allMatches: s };
|
|
95
|
+
}
|
|
96
|
+
function Je(t) {
|
|
97
|
+
return t && t.helperServices.aiAssistantServices ? `${t.helperServices.aiAssistantServices.url}/skills/doc_ai_assistant/chat` : null;
|
|
98
|
+
}
|
|
99
|
+
function le(t) {
|
|
100
|
+
return t && t.helperServices.aiAssistantServices ? `${t.helperServices.aiAssistantServices.url}/skills/doc_ai_assistant/api/pre-chat` : null;
|
|
101
|
+
}
|
|
102
|
+
async function q(t, e, s) {
|
|
103
|
+
const n = await fetch(e, {
|
|
104
|
+
method: "POST",
|
|
105
|
+
headers: {
|
|
106
|
+
"Content-Type": "application/json",
|
|
107
|
+
token: s
|
|
108
|
+
},
|
|
109
|
+
body: JSON.stringify(t)
|
|
110
|
+
});
|
|
111
|
+
if (!n.ok)
|
|
112
|
+
throw new Error(`HTTP ${n.status} calling ${e}`);
|
|
113
|
+
return n.json();
|
|
114
|
+
}
|
|
115
|
+
const Ge = (t) => new Promise((e) => setTimeout(e, t)), He = f.Root({
|
|
116
|
+
// Provides agentExecutionContext, outputMessage, summary, and status
|
|
117
|
+
// channels with the orchestrator's standard reducers/defaults so the
|
|
118
|
+
// sub-agent reports back through the same shape the orchestrator
|
|
119
|
+
// persists into priorSteps.
|
|
120
|
+
...O(),
|
|
121
|
+
solutionResponse: f({
|
|
122
|
+
reducer: (t, e) => e ?? null,
|
|
123
|
+
default: () => null
|
|
124
|
+
}),
|
|
125
|
+
documentSkillUrl: f({
|
|
126
|
+
reducer: (t, e) => e ?? null,
|
|
127
|
+
default: () => null
|
|
128
|
+
}),
|
|
129
|
+
// Persisted across turns via the graph checkpointer so follow-up questions
|
|
130
|
+
// continue the same service conversation. Null on the very first interaction
|
|
131
|
+
// or after messages are cleared.
|
|
132
|
+
conversationId: f({
|
|
133
|
+
reducer: (t, e) => e ?? t,
|
|
134
|
+
default: () => null
|
|
135
|
+
})
|
|
136
|
+
}), Ve = () => new U(He).addNode("initializeAgent", Ke).addNode("askSolutionsQuestions", Qe).addEdge(z, "initializeAgent").addEdge("initializeAgent", "askSolutionsQuestions").addEdge("askSolutionsQuestions", I), ce = async (t, e, s) => {
|
|
137
|
+
if (!t) return;
|
|
138
|
+
const n = le(t);
|
|
139
|
+
if (!n) return;
|
|
140
|
+
const o = { context: {
|
|
141
|
+
kind: "DocAIAssistantRequest",
|
|
142
|
+
filters: {
|
|
143
|
+
products: "ArcGIS Solutions",
|
|
144
|
+
persona: { persona: "apps-solutions" }
|
|
145
|
+
}
|
|
146
|
+
} };
|
|
147
|
+
s && (o.conversationId = s), q(o, n, e ?? "");
|
|
148
|
+
}, Qe = async (t, e) => {
|
|
149
|
+
const s = N(e), n = t.documentSkillUrl;
|
|
150
|
+
let i = [];
|
|
151
|
+
await w(
|
|
152
|
+
{ text: s.agentProgress.explorerAgentSearching },
|
|
81
153
|
e
|
|
82
154
|
);
|
|
83
|
-
|
|
84
|
-
|
|
85
|
-
|
|
86
|
-
|
|
87
|
-
|
|
88
|
-
|
|
89
|
-
|
|
90
|
-
|
|
91
|
-
|
|
92
|
-
|
|
93
|
-
|
|
94
|
-
},
|
|
95
|
-
|
|
96
|
-
|
|
97
|
-
|
|
98
|
-
|
|
99
|
-
|
|
100
|
-
|
|
155
|
+
let o = await q(
|
|
156
|
+
{
|
|
157
|
+
message: t.agentExecutionContext.userRequest,
|
|
158
|
+
conversationId: e?.configurable?.context?.convoId ?? void 0,
|
|
159
|
+
context: {
|
|
160
|
+
kind: "DocAIAssistantRequest",
|
|
161
|
+
filters: {
|
|
162
|
+
products: "ArcGIS Solutions",
|
|
163
|
+
persona: { persona: "apps-solutions" }
|
|
164
|
+
}
|
|
165
|
+
}
|
|
166
|
+
},
|
|
167
|
+
n,
|
|
168
|
+
e?.configurable?.context?.token ?? ""
|
|
169
|
+
);
|
|
170
|
+
o.conversationId && e?.configurable?.context?.setConversationId && e.configurable.context.setConversationId(o.conversationId);
|
|
171
|
+
let a = {
|
|
172
|
+
message: o.message,
|
|
173
|
+
conversationId: o.conversationId,
|
|
174
|
+
hasMore: o.hasMore,
|
|
175
|
+
ackSequenceNumber: o.sequenceNumber,
|
|
176
|
+
inquiryId: o.inquiryId
|
|
177
|
+
}, l = "", d = null;
|
|
178
|
+
const u = async (p) => {
|
|
179
|
+
const c = p.context?.results?.[0]?.reply ?? "";
|
|
180
|
+
if (c !== "") {
|
|
181
|
+
const y = Oe(c), S = je(y, e);
|
|
182
|
+
l = S.source, i = [
|
|
183
|
+
...i,
|
|
184
|
+
...S.allMatches.filter(
|
|
185
|
+
(_) => !i.some((v) => v.solution.id === _.solution.id)
|
|
186
|
+
)
|
|
187
|
+
];
|
|
188
|
+
}
|
|
189
|
+
c !== "" && p.context?.results?.[0]?.followupQuestions && (d = p.context.results[0].followupQuestions);
|
|
190
|
+
const h = p.context?.results?.[0]?.status?.currentStatusStep;
|
|
191
|
+
if (h) {
|
|
192
|
+
let y = "";
|
|
193
|
+
h === 1 ? y = s.agentProgress.explorerAgentReading : h === 2 ? y = s.agentProgress.explorerAgentReviewing : h === 3 && (y = s.agentProgress.explorerAgentPreparing), await w({ text: y }, e);
|
|
194
|
+
}
|
|
195
|
+
};
|
|
196
|
+
for (await u(o); a.hasMore; )
|
|
197
|
+
await Ge(500), o = await q(
|
|
198
|
+
{
|
|
199
|
+
conversationId: a.conversationId,
|
|
200
|
+
ackSequenceNumber: a.ackSequenceNumber,
|
|
201
|
+
inquiryId: a.inquiryId
|
|
202
|
+
},
|
|
203
|
+
n,
|
|
204
|
+
e?.configurable?.context?.token ?? ""
|
|
205
|
+
), a = {
|
|
206
|
+
message: o.message,
|
|
207
|
+
conversationId: o.conversationId,
|
|
208
|
+
hasMore: o.hasMore,
|
|
209
|
+
ackSequenceNumber: o.sequenceNumber,
|
|
210
|
+
inquiryId: o.inquiryId
|
|
211
|
+
}, await u(o);
|
|
212
|
+
if (d && e?.configurable?.context?.updateSuggestedPrompts) {
|
|
213
|
+
const p = e.configurable.context.updateSuggestedPrompts, c = d;
|
|
214
|
+
setTimeout(() => p(c), 0);
|
|
215
|
+
}
|
|
216
|
+
return le(e?.configurable?.context.portal) && ce(e?.configurable?.context.portal, e?.configurable?.context.token ?? "", a.conversationId), i.length && (i.length === 1 ? re(i[0].solution.id) : ae(i)), {
|
|
217
|
+
outputMessage: l,
|
|
218
|
+
summary: l,
|
|
219
|
+
status: "success",
|
|
220
|
+
solutionResponse: a,
|
|
221
|
+
conversationId: a.conversationId
|
|
222
|
+
};
|
|
223
|
+
}, Ke = async (t, e) => {
|
|
224
|
+
let s = null;
|
|
225
|
+
return t.documentSkillUrl === null && e?.configurable?.context?.portal && (s = Je(e.configurable.context.portal)), {
|
|
226
|
+
documentSkillUrl: s
|
|
227
|
+
};
|
|
228
|
+
};
|
|
229
|
+
await x(ze, "solutions_explorer_description");
|
|
230
|
+
const de = (t) => {
|
|
101
231
|
if (t && Array.isArray(t.id) && t.id.length > 0)
|
|
102
232
|
return t.id[t.id.length - 1].replace("Message", "").toLowerCase();
|
|
103
233
|
if (t && typeof t._getType == "function")
|
|
@@ -107,8 +237,8 @@ const ae = /* @__PURE__ */ Object.assign({
|
|
|
107
237
|
return "human";
|
|
108
238
|
}
|
|
109
239
|
return "human";
|
|
110
|
-
},
|
|
111
|
-
const e =
|
|
240
|
+
}, We = (t) => {
|
|
241
|
+
const e = de(t);
|
|
112
242
|
if (t && t.kwargs)
|
|
113
243
|
return {
|
|
114
244
|
role: e,
|
|
@@ -123,9 +253,9 @@ const ae = /* @__PURE__ */ Object.assign({
|
|
|
123
253
|
return t.id && (s.id = t.id), t.name && (s.name = t.name), t.additional_kwargs && (s.additional_kwargs = t.additional_kwargs), t.response_metadata && (s.response_metadata = t.response_metadata), s;
|
|
124
254
|
}
|
|
125
255
|
return { role: "human", content: String(t) };
|
|
126
|
-
},
|
|
127
|
-
builderMessages:
|
|
128
|
-
},
|
|
256
|
+
}, Ye = (t) => de(t) === "human", Ze = (t, e = 3) => t.filter((s) => Ye(s)).slice(-e).map(We), Xe = (t, e = " ") => Ze(t).map((i) => i.content).join(e).trim(), et = { understandingRequest: "Understanding your request...", selectTemplatePrompt: "This use case could be supported in a few different ways. Choose the option that best matches what you want to accomplish.", searchingExistingSolutions: "Searching for existing solutions...", existingSolutionMatch: "I found an existing solution that closely matches your use case and may already meet your needs: {{solutionMatch}}. Do you want to continue building your solution?", creatingDesign: "Generating solution design...", updatingDesign: "Updating solution design...", applyChangeFailed: "I wasn't able to apply that change. The design was not modified. Please try rephrasing your request.", createDesignFailed: "I wasn't able to create a solution design from that request. Please try rephrasing and try again.", discardMessage: "Are you sure you want to discard your solution?", discardForNewSolution: "I can help you build a new solution, but I will need to discard your current solution design. Do you want to continue?" }, tt = {
|
|
257
|
+
builderMessages: et
|
|
258
|
+
}, st = /* @__PURE__ */ new Set([
|
|
129
259
|
"add",
|
|
130
260
|
"all",
|
|
131
261
|
"alter",
|
|
@@ -188,9 +318,9 @@ const ae = /* @__PURE__ */ Object.assign({
|
|
|
188
318
|
"view",
|
|
189
319
|
"where"
|
|
190
320
|
]);
|
|
191
|
-
class
|
|
192
|
-
constructor(e, s,
|
|
193
|
-
this.isValid = !0, this.issues = [], this.response = e, this.template = s, this.newDesign =
|
|
321
|
+
class ue {
|
|
322
|
+
constructor(e, s, n = !0) {
|
|
323
|
+
this.isValid = !0, this.issues = [], this.response = e, this.template = s, this.newDesign = n, this.validate();
|
|
194
324
|
}
|
|
195
325
|
validate() {
|
|
196
326
|
this.compareModels(), this.validateResponse();
|
|
@@ -199,14 +329,14 @@ class ce {
|
|
|
199
329
|
this.compareStrings(), this.compareItems(), this.compareFeatureLayers();
|
|
200
330
|
}
|
|
201
331
|
compareStrings() {
|
|
202
|
-
const e = new Set(this.template.solution.strings.map((
|
|
203
|
-
(e.size !== s.size || [...e].some((
|
|
204
|
-
for (const
|
|
205
|
-
|
|
332
|
+
const e = new Set(this.template.solution.strings.map((n) => n.key)), s = new Set(this.response.solution.strings.map((n) => n.key));
|
|
333
|
+
(e.size !== s.size || [...e].some((n) => !s.has(n))) && this.logIssue("String keys in llm response do not match the template.");
|
|
334
|
+
for (const n of this.response.solution.strings)
|
|
335
|
+
n.value || this.logIssue(`String key '${n.key}' has no value.`);
|
|
206
336
|
}
|
|
207
337
|
compareItems() {
|
|
208
|
-
const e = new Set(this.template.items.map((
|
|
209
|
-
(e.size !== s.size || [...e].some((
|
|
338
|
+
const e = new Set(this.template.items.map((n) => n.id)), s = new Set(this.response.items.map((n) => n.id));
|
|
339
|
+
(e.size !== s.size || [...e].some((n) => !s.has(n))) && this.logIssue("Item ids in llm response do not match the template.");
|
|
210
340
|
}
|
|
211
341
|
compareFeatureLayers() {
|
|
212
342
|
const e = this.template.featureLayer, s = this.response.featureLayer;
|
|
@@ -215,25 +345,25 @@ class ce {
|
|
|
215
345
|
return;
|
|
216
346
|
}
|
|
217
347
|
if (!e.addLayers) {
|
|
218
|
-
const
|
|
219
|
-
(
|
|
348
|
+
const n = new Set(e.layers.map((o) => o.id)), i = new Set(s.layers.map((o) => o.id));
|
|
349
|
+
(n.size !== i.size || [...n].some((o) => !i.has(o))) && this.logIssue(`Feature Layer '${e.itemId}' had its layer ids altered.`);
|
|
220
350
|
}
|
|
221
351
|
}
|
|
222
352
|
validateResponse() {
|
|
223
353
|
const e = this.template.featureLayer.layers;
|
|
224
354
|
this.response.featureLayer.layers.length || this.logIssue("Feature layer item must contain at least one layer.");
|
|
225
|
-
const s = this.response.featureLayer.layers.map((
|
|
355
|
+
const s = this.response.featureLayer.layers.map((n) => n.name.toLowerCase());
|
|
226
356
|
s.length !== new Set(s).size && this.logIssue("Layer names must be unique (case-insensitive).");
|
|
227
|
-
for (const
|
|
228
|
-
this.validateLayer(
|
|
229
|
-
const
|
|
230
|
-
|
|
357
|
+
for (const n of this.response.featureLayer.layers) {
|
|
358
|
+
this.validateLayer(n);
|
|
359
|
+
const i = e.find((o) => o.id === n.id);
|
|
360
|
+
i && this.validateRequiredFields(n, i);
|
|
231
361
|
}
|
|
232
362
|
}
|
|
233
363
|
validateRequiredFields(e, s) {
|
|
234
|
-
const
|
|
235
|
-
for (const
|
|
236
|
-
|
|
364
|
+
const n = new Set(e.requiredFields.map((i) => i.name));
|
|
365
|
+
for (const i of s.requiredFields)
|
|
366
|
+
n.has(i.name) || this.logIssue(`Layer '${e.name}' is missing required field '${i.name}'.`);
|
|
237
367
|
}
|
|
238
368
|
validateLayer(e) {
|
|
239
369
|
const s = /* @__PURE__ */ new Set([
|
|
@@ -243,25 +373,25 @@ class ce {
|
|
|
243
373
|
"created_user",
|
|
244
374
|
"last_edited_date",
|
|
245
375
|
"last_edited_user"
|
|
246
|
-
]),
|
|
247
|
-
if (
|
|
248
|
-
const o = new Set(
|
|
376
|
+
]), n = e.systemFields ?? [];
|
|
377
|
+
if (n.length) {
|
|
378
|
+
const o = new Set(n.map((l) => l.name));
|
|
249
379
|
(o.size !== s.size || [...s].some((l) => !o.has(l))) && this.logIssue(
|
|
250
380
|
`Layer '${e.name}' has invalid system fields: ${JSON.stringify([...o])}.`
|
|
251
381
|
);
|
|
252
382
|
}
|
|
253
|
-
const
|
|
383
|
+
const i = [
|
|
254
384
|
...e.customFields,
|
|
255
385
|
...e.requiredFields,
|
|
256
|
-
...
|
|
386
|
+
...n
|
|
257
387
|
].map((o) => o.name);
|
|
258
|
-
|
|
259
|
-
for (const o of [...e.customFields, ...e.requiredFields, ...
|
|
388
|
+
i.length !== new Set(i).size && this.logIssue(`Layer '${e.name}' has duplicate fields: ${JSON.stringify(i)}.`);
|
|
389
|
+
for (const o of [...e.customFields, ...e.requiredFields, ...n])
|
|
260
390
|
this.validateField(o);
|
|
261
391
|
}
|
|
262
392
|
validateField(e) {
|
|
263
|
-
if (e.alias || this.logIssue(`Field '${e.name}' has no display name (alias).`), /^[A-Za-z]/u.test(e.name) || this.logIssue(`Field '${e.name}' does not start with a letter.`), /^[A-Za-z][A-Za-z0-9_]*$/u.test(e.name) || this.logIssue(`Field '${e.name}' contains invalid characters (only letters, numbers, and underscores allowed).`), e.name.length > 31 && this.logIssue(`Field '${e.name}' exceeds 31 characters.`),
|
|
264
|
-
const s = Math.max(...e.choiceList.map((
|
|
393
|
+
if (e.alias || this.logIssue(`Field '${e.name}' has no display name (alias).`), /^[A-Za-z]/u.test(e.name) || this.logIssue(`Field '${e.name}' does not start with a letter.`), /^[A-Za-z][A-Za-z0-9_]*$/u.test(e.name) || this.logIssue(`Field '${e.name}' contains invalid characters (only letters, numbers, and underscores allowed).`), e.name.length > 31 && this.logIssue(`Field '${e.name}' exceeds 31 characters.`), st.has(e.name.toLowerCase()) && this.logIssue(`Field '${e.name}' is a SQL reserved keyword.`), e.choiceList && (e.choiceList.some((s) => !s) && this.logIssue(`Field '${e.name}' has empty domain values.`), e.choiceList.length !== new Set(e.choiceList).size && this.logIssue(`Field '${e.name}' has duplicate domain values.`), e.length != null)) {
|
|
394
|
+
const s = Math.max(...e.choiceList.map((n) => n.length));
|
|
265
395
|
s > e.length && (this.newDesign ? (console.debug(`Field '${e.name}' length ${e.length} is insufficient for choiceList value of length ${s}. Auto-fixing to ${s}.`), e.length = s) : this.logIssue(`Field '${e.name}' length ${e.length} is insufficient for choiceList value of length ${s}.`));
|
|
266
396
|
}
|
|
267
397
|
}
|
|
@@ -269,15 +399,15 @@ class ce {
|
|
|
269
399
|
console.debug(e), this.issues.push(e), this.isValid = !1;
|
|
270
400
|
}
|
|
271
401
|
}
|
|
272
|
-
const
|
|
273
|
-
key:
|
|
274
|
-
value:
|
|
275
|
-
description:
|
|
276
|
-
}),
|
|
277
|
-
id:
|
|
278
|
-
title:
|
|
279
|
-
description:
|
|
280
|
-
type:
|
|
402
|
+
const nt = r.object({
|
|
403
|
+
key: r.string().describe("Stable key identifier for the string."),
|
|
404
|
+
value: r.string().describe("Display value for the string."),
|
|
405
|
+
description: r.string().describe("Explanation of where/how the string is used.")
|
|
406
|
+
}), it = r.object({
|
|
407
|
+
id: r.string().describe("ArcGIS item id (32 hex characters)."),
|
|
408
|
+
title: r.string().describe("Item title."),
|
|
409
|
+
description: r.string().describe("Item description."),
|
|
410
|
+
type: r.enum([
|
|
281
411
|
"Feature Layer (hosted)",
|
|
282
412
|
"Feature Layer (hosted, view)",
|
|
283
413
|
"Web Map",
|
|
@@ -296,116 +426,116 @@ const Xe = a.object({
|
|
|
296
426
|
"Notebook",
|
|
297
427
|
"QuickCapture Project"
|
|
298
428
|
]).describe("ArcGIS item type.")
|
|
299
|
-
}),
|
|
300
|
-
name:
|
|
301
|
-
type:
|
|
302
|
-
alias:
|
|
303
|
-
description:
|
|
304
|
-
choiceList:
|
|
429
|
+
}), te = r.object({
|
|
430
|
+
name: r.string().describe("Field name."),
|
|
431
|
+
type: r.enum(["string", "integer", "double", "date", "oid", "guid", "globalid"]).describe("Field data type."),
|
|
432
|
+
alias: r.string().describe("Field alias for display."),
|
|
433
|
+
description: r.string().describe("Field description."),
|
|
434
|
+
choiceList: r.array(r.string()).nullable().describe(
|
|
305
435
|
"List of allowed values for string fields with a controlled vocabulary. Null if unrestricted or not applicable."
|
|
306
436
|
),
|
|
307
|
-
length:
|
|
308
|
-
}),
|
|
309
|
-
id:
|
|
310
|
-
type:
|
|
311
|
-
name:
|
|
312
|
-
description:
|
|
313
|
-
customFields:
|
|
314
|
-
requiredFields:
|
|
315
|
-
}),
|
|
316
|
-
itemId:
|
|
317
|
-
addLayers:
|
|
318
|
-
layers:
|
|
319
|
-
}), J =
|
|
320
|
-
response:
|
|
321
|
-
solution:
|
|
322
|
-
itemId:
|
|
323
|
-
title:
|
|
324
|
-
description:
|
|
325
|
-
tags:
|
|
326
|
-
strings:
|
|
437
|
+
length: r.number().int().nullable().describe("Maximum string length for string fields. Null for non-string fields.")
|
|
438
|
+
}), ot = r.object({
|
|
439
|
+
id: r.number().int().describe("Layer/table id within the feature service."),
|
|
440
|
+
type: r.enum(["Point", "Polyline", "Polygon", "Table"]).describe("Layer type."),
|
|
441
|
+
name: r.string().describe("Layer/table name."),
|
|
442
|
+
description: r.string().describe("Layer/table description."),
|
|
443
|
+
customFields: r.array(te).describe("User/business fields specific to the solution."),
|
|
444
|
+
requiredFields: r.array(te).describe("Fields required for solution functionality (e.g., relationship keys).")
|
|
445
|
+
}), at = r.object({
|
|
446
|
+
itemId: r.string().describe("ArcGIS item id for the feature layer."),
|
|
447
|
+
addLayers: r.boolean().describe("Indicates whether new layers can be added during solution design."),
|
|
448
|
+
layers: r.array(ot)
|
|
449
|
+
}), J = r.object({
|
|
450
|
+
response: r.string().describe("Conversational response to the user's query."),
|
|
451
|
+
solution: r.object({
|
|
452
|
+
itemId: r.string().nullable().describe("ArcGIS item id of the source Solution template used for deployment. Preserve the existing value exactly when known; otherwise use null."),
|
|
453
|
+
title: r.string().describe("Title of the solution."),
|
|
454
|
+
description: r.string().describe("Description of the solution."),
|
|
455
|
+
tags: r.array(r.string()).describe("Keywords/tags associated with the solution."),
|
|
456
|
+
strings: r.array(nt).describe("Localized strings/labels used by apps (dashboards, forms, etc.).")
|
|
327
457
|
}),
|
|
328
|
-
items:
|
|
329
|
-
featureLayer:
|
|
330
|
-
}),
|
|
331
|
-
op:
|
|
332
|
-
path:
|
|
333
|
-
value:
|
|
334
|
-
from:
|
|
335
|
-
}),
|
|
336
|
-
response:
|
|
337
|
-
patches:
|
|
338
|
-
}),
|
|
339
|
-
matchedTitles:
|
|
340
|
-
}),
|
|
341
|
-
templateId:
|
|
342
|
-
confidence:
|
|
343
|
-
templateDescription:
|
|
344
|
-
}),
|
|
345
|
-
assistantResponse:
|
|
346
|
-
isValidUseCase:
|
|
347
|
-
matchedTemplates:
|
|
348
|
-
}), G = (t) => t in
|
|
349
|
-
let
|
|
350
|
-
const
|
|
351
|
-
"./prompts/description.md": () => import("../../chunks/
|
|
458
|
+
items: r.array(it).describe("ArcGIS items that belong to the solution (apps, maps, layers, etc.)."),
|
|
459
|
+
featureLayer: at.describe("Primary feature layer item and its schema/layers/tables details.")
|
|
460
|
+
}), rt = r.object({
|
|
461
|
+
op: r.enum(["add", "remove", "replace", "move", "copy"]).describe("RFC 6902 operation type."),
|
|
462
|
+
path: r.string().describe("RFC 6901 JSON Pointer to the target location."),
|
|
463
|
+
value: r.string().nullable().describe(`JSON-encoded value to apply (required for add and replace). Must be null — not an empty string — for remove, move, and copy operations. Serialize as a JSON string, e.g. '\\"text\\"' for a string, '[\\"a\\",\\"b\\"]' for an array, or '{\\"name\\":\\"x\\"}' for an object.`),
|
|
464
|
+
from: r.string().nullable().describe("RFC 6901 JSON Pointer to the source location (required for move and copy). Must be null — not an empty string — for all other operations.")
|
|
465
|
+
}), lt = r.object({
|
|
466
|
+
response: r.string().describe("Conversational response describing the accepted design changes."),
|
|
467
|
+
patches: r.array(rt).describe("Minimal RFC 6902 patch operations needed to update the current design.")
|
|
468
|
+
}), ct = r.object({
|
|
469
|
+
matchedTitles: r.array(r.string()).describe("Titles of solutions that match the user's request. Empty array if no strong match.")
|
|
470
|
+
}), dt = r.object({
|
|
471
|
+
templateId: r.string().min(1).describe("Template id from the available template list."),
|
|
472
|
+
confidence: r.number().min(0).max(1).describe("Confidence score from 0 to 1 for this template match."),
|
|
473
|
+
templateDescription: r.string().min(1).describe("Short description this template in the user's use case/workflow.")
|
|
474
|
+
}), ut = r.object({
|
|
475
|
+
assistantResponse: r.string().describe("Natural-language response for the user."),
|
|
476
|
+
isValidUseCase: r.boolean().describe("True only when the request is concrete, appropriate, and has at least one matching template."),
|
|
477
|
+
matchedTemplates: r.array(dt).describe("Ordered list of matching templates, best match first. Empty when no valid match exists.")
|
|
478
|
+
}), G = (t) => t in E, pt = 5, mt = 0.8, gt = 0.15, ht = "Web Mapping Application", ft = "Embeddings";
|
|
479
|
+
let R = null, B = null, $ = null, F = null;
|
|
480
|
+
const bt = "Build", D = /* @__PURE__ */ Object.assign({
|
|
481
|
+
"./prompts/description.md": () => import("../../chunks/description2.js").then((t) => t.default),
|
|
352
482
|
"./prompts/designSolution.md": () => import("../../chunks/designSolution.js").then((t) => t.default),
|
|
353
483
|
"./prompts/findExistingSolution.md": () => import("../../chunks/findExistingSolution.js").then((t) => t.default),
|
|
354
484
|
"./prompts/initialAssessment.md": () => import("../../chunks/initialAssessment.js").then((t) => t.default),
|
|
355
485
|
"./prompts/updateDesign.md": () => import("../../chunks/updateDesign.js").then((t) => t.default)
|
|
356
|
-
}),
|
|
357
|
-
let
|
|
486
|
+
}), yt = tt.builderMessages, b = (t, e, s) => {
|
|
487
|
+
let i = N(e)?.builderMessages?.[t] ?? yt[t];
|
|
358
488
|
if (!s)
|
|
359
|
-
return
|
|
360
|
-
for (const [o,
|
|
361
|
-
|
|
362
|
-
return
|
|
363
|
-
},
|
|
489
|
+
return i;
|
|
490
|
+
for (const [o, a] of Object.entries(s))
|
|
491
|
+
i = i.replaceAll(`{{${o}}}`, a);
|
|
492
|
+
return i;
|
|
493
|
+
}, pe = (t) => {
|
|
364
494
|
typeof window < "u" && window.dispatchEvent(new CustomEvent("arcgis-solution-design-update", {
|
|
365
495
|
detail: t
|
|
366
496
|
}));
|
|
367
|
-
},
|
|
497
|
+
}, vt = async (t, e, s) => {
|
|
368
498
|
if (!t) return null;
|
|
369
|
-
const
|
|
370
|
-
return (await
|
|
371
|
-
q:
|
|
499
|
+
const n = `type:"${ht}" AND typekeywords:${ft} AND group:${t}`;
|
|
500
|
+
return (await j.searchItems({
|
|
501
|
+
q: n,
|
|
372
502
|
params: e ? { token: e } : void 0,
|
|
373
503
|
portal: s,
|
|
374
504
|
num: 1
|
|
375
505
|
}))?.results?.[0] ?? null;
|
|
376
506
|
};
|
|
377
|
-
async function
|
|
507
|
+
async function xt(t, e, s) {
|
|
378
508
|
try {
|
|
379
|
-
const
|
|
380
|
-
if (!
|
|
381
|
-
const
|
|
382
|
-
return await
|
|
509
|
+
const n = await vt(t, e, s);
|
|
510
|
+
if (!n) return null;
|
|
511
|
+
const i = new qe({ id: n.id });
|
|
512
|
+
return await i.load(), await i.fetchData("json");
|
|
383
513
|
} catch {
|
|
384
514
|
return null;
|
|
385
515
|
}
|
|
386
516
|
}
|
|
387
|
-
const
|
|
517
|
+
const wt = async (t, e, s) => {
|
|
388
518
|
if (!t) return [];
|
|
389
|
-
const
|
|
390
|
-
return (await
|
|
391
|
-
q:
|
|
519
|
+
const n = `type:Solution AND typekeywords:${bt} AND group:${t}`;
|
|
520
|
+
return (await j.searchItems({
|
|
521
|
+
q: n,
|
|
392
522
|
params: e ? { token: e } : void 0,
|
|
393
523
|
portal: s,
|
|
394
524
|
num: 100
|
|
395
525
|
}))?.results ?? [];
|
|
396
|
-
},
|
|
526
|
+
}, St = async (t, e, s) => {
|
|
397
527
|
try {
|
|
398
|
-
const
|
|
528
|
+
const n = await j.getItemData(t, {
|
|
399
529
|
params: e ? { token: e } : void 0,
|
|
400
530
|
portal: s
|
|
401
|
-
}),
|
|
402
|
-
if (!
|
|
403
|
-
const o =
|
|
404
|
-
return { buildSolution:
|
|
531
|
+
}), i = n?.buildSolution;
|
|
532
|
+
if (!i) return null;
|
|
533
|
+
const o = n?.params, a = o && typeof o == "object" && !Array.isArray(o) ? o : null;
|
|
534
|
+
return { buildSolution: i, params: a };
|
|
405
535
|
} catch {
|
|
406
536
|
return null;
|
|
407
537
|
}
|
|
408
|
-
},
|
|
538
|
+
}, C = (t, e = {}) => {
|
|
409
539
|
let s = t;
|
|
410
540
|
return "itemId" in e && (s = {
|
|
411
541
|
...s,
|
|
@@ -423,12 +553,12 @@ const bt = async (t, e, s) => {
|
|
|
423
553
|
...s,
|
|
424
554
|
templateId: e.templateId ?? null
|
|
425
555
|
}), s;
|
|
426
|
-
},
|
|
556
|
+
}, me = (t, e) => {
|
|
427
557
|
if (t == null || e == null)
|
|
428
558
|
return { ok: !1, error: "design or sourceBuildSolution is null/undefined" };
|
|
429
559
|
try {
|
|
430
560
|
const s = structuredClone(e);
|
|
431
|
-
return new
|
|
561
|
+
return new ne({ buildSolution: s }).applyLlmTemplate(t), { ok: !0 };
|
|
432
562
|
} catch (s) {
|
|
433
563
|
return {
|
|
434
564
|
ok: !1,
|
|
@@ -436,95 +566,95 @@ const bt = async (t, e, s) => {
|
|
|
436
566
|
};
|
|
437
567
|
}
|
|
438
568
|
}, H = async (t) => {
|
|
439
|
-
if (
|
|
440
|
-
Object.entries(
|
|
441
|
-
|
|
569
|
+
if (B) {
|
|
570
|
+
Object.entries(B).forEach(([a, l]) => {
|
|
571
|
+
E[a] && (E[a].initialTemplate = l);
|
|
442
572
|
});
|
|
443
573
|
return;
|
|
444
574
|
}
|
|
445
|
-
const e = t?.configurable?.context?.token, s =
|
|
575
|
+
const e = t?.configurable?.context?.token, s = he(t), n = fe(t);
|
|
446
576
|
if (!s) {
|
|
447
577
|
console.warn("Solution Builder: missing primarySolutionsGroupId in appConfig; skipping live template hydration.");
|
|
448
578
|
return;
|
|
449
579
|
}
|
|
450
|
-
const
|
|
451
|
-
await Promise.all(
|
|
452
|
-
const l =
|
|
580
|
+
const i = await wt(s, e, n), o = {};
|
|
581
|
+
await Promise.all(i.map(async (a) => {
|
|
582
|
+
const l = a.properties?.templateInfo;
|
|
453
583
|
if (!l || typeof l != "object") return;
|
|
454
584
|
const d = l.id;
|
|
455
585
|
if (typeof d != "string" || o[d]) return;
|
|
456
|
-
const u = await
|
|
586
|
+
const u = await St(a.id, e, n);
|
|
457
587
|
if (!u) return;
|
|
458
|
-
const { buildSolution:
|
|
459
|
-
if (typeof
|
|
460
|
-
const
|
|
461
|
-
|
|
588
|
+
const { buildSolution: g, params: p } = u;
|
|
589
|
+
if (typeof g == "object" && g !== null && "solution" in g) {
|
|
590
|
+
const h = g.solution;
|
|
591
|
+
h.thumbnailUrl = a.thumbnail ? `${n ?? "https://www.arcgis.com/sharing/rest"}/content/items/${a.id}/info/${a.thumbnail}` : void 0;
|
|
462
592
|
}
|
|
463
593
|
const c = {
|
|
464
594
|
...l,
|
|
465
|
-
buildSolution:
|
|
595
|
+
buildSolution: g
|
|
466
596
|
};
|
|
467
|
-
o[d] =
|
|
468
|
-
new
|
|
597
|
+
o[d] = C(
|
|
598
|
+
new ne(c).dumpToLlmTemplate(),
|
|
469
599
|
{
|
|
470
|
-
itemId:
|
|
471
|
-
sourceBuildSolution: structuredClone(
|
|
472
|
-
params:
|
|
600
|
+
itemId: a.id,
|
|
601
|
+
sourceBuildSolution: structuredClone(g),
|
|
602
|
+
params: p ? structuredClone(p) : null
|
|
473
603
|
}
|
|
474
|
-
),
|
|
604
|
+
), E[d] = {
|
|
475
605
|
...l,
|
|
476
606
|
initialTemplate: o[d]
|
|
477
607
|
};
|
|
478
|
-
})),
|
|
479
|
-
},
|
|
608
|
+
})), B = o;
|
|
609
|
+
}, ge = (t) => {
|
|
480
610
|
const e = t?.configurable?.context?.token;
|
|
481
611
|
return typeof e != "string" || !e.trim() ? null : e;
|
|
482
|
-
},
|
|
612
|
+
}, he = (t) => {
|
|
483
613
|
const e = t?.configurable?.context?.configContext?.primarySolutionsGroupId;
|
|
484
614
|
return typeof e != "string" || !e.trim() ? null : e;
|
|
485
|
-
},
|
|
615
|
+
}, fe = (t) => {
|
|
486
616
|
const e = t?.configurable?.context?.configContext?.portalURL;
|
|
487
617
|
if (!(typeof e != "string" || !e.trim()))
|
|
488
618
|
return `${e.replace(/\/+$/, "")}/sharing/rest`;
|
|
489
|
-
},
|
|
619
|
+
}, It = async (t) => {
|
|
490
620
|
await Promise.all([
|
|
491
|
-
|
|
621
|
+
ye(t),
|
|
492
622
|
H(t)
|
|
493
623
|
]);
|
|
494
|
-
},
|
|
495
|
-
const e =
|
|
496
|
-
(!$ || e && e !==
|
|
497
|
-
throw $ = null,
|
|
624
|
+
}, be = async (t) => {
|
|
625
|
+
const e = ge(t);
|
|
626
|
+
(!$ || e && e !== F) && (F = e ?? F, $ = It(t).catch((n) => {
|
|
627
|
+
throw $ = null, F = null, n;
|
|
498
628
|
})), await $;
|
|
499
629
|
};
|
|
500
|
-
async function
|
|
501
|
-
if (
|
|
502
|
-
const e =
|
|
630
|
+
async function ye(t) {
|
|
631
|
+
if (R) return R;
|
|
632
|
+
const e = he(t);
|
|
503
633
|
if (!e)
|
|
504
634
|
return console.warn("Solution Builder: missing primarySolutionsGroupId in appConfig; skipping embeddings load."), null;
|
|
505
|
-
const s =
|
|
506
|
-
await new
|
|
507
|
-
const o =
|
|
508
|
-
return
|
|
635
|
+
const s = fe(t), n = t?.configurable?.context?.configContext?.portalURL;
|
|
636
|
+
await new Be(n ? { url: n } : void 0).load();
|
|
637
|
+
const o = ge(t) ?? void 0, a = await xt(e, o, s);
|
|
638
|
+
return a ? (R = a.items, R) : null;
|
|
509
639
|
}
|
|
510
|
-
const
|
|
640
|
+
const Ct = () => Object.entries(E).map(([t, e]) => `ID: ${t}
|
|
511
641
|
Label: ${e.label}
|
|
512
642
|
Description: ${e.description}`).join(`
|
|
513
643
|
|
|
514
|
-
`),
|
|
644
|
+
`), _t = (t) => {
|
|
515
645
|
const e = t?.configurable?.context?.solutionDesignJson;
|
|
516
646
|
if (typeof e != "string" || !e.trim())
|
|
517
647
|
return null;
|
|
518
648
|
try {
|
|
519
|
-
const s = JSON.parse(e),
|
|
649
|
+
const s = JSON.parse(e), n = C(
|
|
520
650
|
{ response: "", ...s },
|
|
521
651
|
{ itemId: s?.solution?.itemId ?? null }
|
|
522
|
-
),
|
|
523
|
-
if (!
|
|
652
|
+
), i = J.safeParse(n);
|
|
653
|
+
if (!i.success)
|
|
524
654
|
return null;
|
|
525
|
-
const { response: o, ...
|
|
526
|
-
return
|
|
527
|
-
|
|
655
|
+
const { response: o, ...a } = i.data, l = s.templateId, d = typeof l == "string" && G(l) ? l : null;
|
|
656
|
+
return C(
|
|
657
|
+
a,
|
|
528
658
|
{
|
|
529
659
|
sourceBuildSolution: s.sourceBuildSolution,
|
|
530
660
|
templateId: d,
|
|
@@ -534,99 +664,94 @@ Description: ${e.description}`).join(`
|
|
|
534
664
|
} catch {
|
|
535
665
|
return null;
|
|
536
666
|
}
|
|
537
|
-
},
|
|
538
|
-
|
|
539
|
-
detail: t
|
|
540
|
-
});
|
|
541
|
-
window.dispatchEvent(e);
|
|
542
|
-
}, be = y.Root({
|
|
543
|
-
...z(),
|
|
667
|
+
}, kt = f.Root({
|
|
668
|
+
...O(),
|
|
544
669
|
/** Optional human-readable template description retained for UI use. */
|
|
545
|
-
templateDescription:
|
|
670
|
+
templateDescription: f({
|
|
546
671
|
reducer: (t, e) => typeof e == "string" || e === null ? e : t ?? null,
|
|
547
672
|
default: () => null
|
|
548
673
|
}),
|
|
549
674
|
/** Current editable design payload being refined across turns. */
|
|
550
|
-
currentDesign:
|
|
675
|
+
currentDesign: f({
|
|
551
676
|
reducer: (t = null, e) => e === void 0 ? t : e ?? null,
|
|
552
677
|
default: () => null
|
|
553
678
|
}),
|
|
554
679
|
/** Initial request assessment produced by the intake prompt. */
|
|
555
|
-
assessment:
|
|
680
|
+
assessment: f({
|
|
556
681
|
reducer: (t = null, e) => e === void 0 ? t : e ?? null,
|
|
557
682
|
default: () => null
|
|
558
683
|
}),
|
|
559
684
|
/** Template selected automatically or by human-in-the-loop choice. */
|
|
560
|
-
selectedTemplate:
|
|
685
|
+
selectedTemplate: f({
|
|
561
686
|
reducer: (t = null, e) => e === void 0 ? t : e ?? null,
|
|
562
687
|
default: () => null
|
|
563
688
|
}),
|
|
564
689
|
/** Existing solution matches surfaced before building a new solution. */
|
|
565
|
-
existingMatches:
|
|
690
|
+
existingMatches: f({
|
|
566
691
|
reducer: (t = [], e) => e === void 0 ? t : e ?? [],
|
|
567
692
|
default: () => []
|
|
568
693
|
})
|
|
569
|
-
}),
|
|
570
|
-
const s =
|
|
571
|
-
return JSON.stringify(t.currentDesign) !== JSON.stringify(s) && (
|
|
572
|
-
},
|
|
573
|
-
await
|
|
574
|
-
const s = t.agentExecutionContext.userRequest,
|
|
575
|
-
promptText: await
|
|
694
|
+
}), Tt = (t, e) => {
|
|
695
|
+
const s = _t(e), n = s?.templateId ?? null, i = {};
|
|
696
|
+
return JSON.stringify(t.currentDesign) !== JSON.stringify(s) && (i.currentDesign = s), n && t.selectedTemplate !== n && (i.selectedTemplate = n), i;
|
|
697
|
+
}, Et = async (t, e) => {
|
|
698
|
+
await w({ text: b("understandingRequest", e) }, e), await be(e);
|
|
699
|
+
const s = t.agentExecutionContext.userRequest, n = Ct(), i = t.agentExecutionContext.messages.slice(-11), o = await A({
|
|
700
|
+
promptText: await x(D, "initialAssessment"),
|
|
576
701
|
modelTier: "advanced",
|
|
577
702
|
temperature: 0,
|
|
578
|
-
schema:
|
|
579
|
-
messages:
|
|
580
|
-
inputVariables: { query: s, availableTemplates:
|
|
581
|
-
}),
|
|
703
|
+
schema: ut,
|
|
704
|
+
messages: i,
|
|
705
|
+
inputVariables: { query: s, availableTemplates: n }
|
|
706
|
+
}), a = o.matchedTemplates.filter(
|
|
582
707
|
(c) => G(c.templateId)
|
|
583
708
|
), l = {
|
|
584
709
|
...o,
|
|
585
|
-
matchedTemplates:
|
|
586
|
-
}, [d, u] =
|
|
710
|
+
matchedTemplates: a
|
|
711
|
+
}, [d, u] = a, p = !!d && d.confidence >= mt && (u === void 0 || d.confidence - u.confidence >= gt) ? d.templateId : null;
|
|
587
712
|
return {
|
|
588
713
|
assessment: l,
|
|
589
|
-
selectedTemplate:
|
|
714
|
+
selectedTemplate: p,
|
|
590
715
|
existingMatches: []
|
|
591
716
|
};
|
|
592
|
-
},
|
|
717
|
+
}, At = (t) => {
|
|
593
718
|
const e = t.assessment?.assistantResponse ?? "";
|
|
594
|
-
return
|
|
719
|
+
return {
|
|
595
720
|
outputMessage: e,
|
|
596
721
|
summary: e,
|
|
597
722
|
status: "success"
|
|
598
723
|
};
|
|
599
|
-
},
|
|
600
|
-
const { hitlResponse: s } = e.configurable,
|
|
724
|
+
}, Dt = (t, e) => {
|
|
725
|
+
const { hitlResponse: s } = e.configurable, n = "selectTemplate", i = t.assessment?.matchedTemplates.filter(
|
|
601
726
|
(u) => G(u.templateId)
|
|
602
|
-
) ?? [], o =
|
|
603
|
-
if (s?.agentId !== "solutionBuilder" || s.id !==
|
|
727
|
+
) ?? [], o = i.map((u) => `${u.templateDescription}`);
|
|
728
|
+
if (s?.agentId !== "solutionBuilder" || s.id !== n) {
|
|
604
729
|
const u = {
|
|
605
730
|
agentId: "solutionBuilder",
|
|
606
|
-
id:
|
|
731
|
+
id: n,
|
|
607
732
|
kind: "singleSelection",
|
|
608
|
-
message:
|
|
733
|
+
message: b("selectTemplatePrompt", e),
|
|
609
734
|
metadata: [...o]
|
|
610
735
|
};
|
|
611
|
-
throw new
|
|
736
|
+
throw new se(u);
|
|
612
737
|
}
|
|
613
|
-
const
|
|
738
|
+
const a = String(s.payload ?? ""), l = o.findIndex((u) => u === a);
|
|
614
739
|
return {
|
|
615
|
-
selectedTemplate: (l >= 0 ?
|
|
740
|
+
selectedTemplate: (l >= 0 ? i[l] : void 0)?.templateId ?? i[0]?.templateId ?? null
|
|
616
741
|
};
|
|
617
|
-
},
|
|
618
|
-
await
|
|
619
|
-
const s = t.agentExecutionContext.userRequest,
|
|
620
|
-
if (!
|
|
742
|
+
}, Lt = async (t, e) => {
|
|
743
|
+
await w({ text: b("searchingExistingSolutions", e) }, e);
|
|
744
|
+
const s = t.agentExecutionContext.userRequest, n = Xe(t.agentExecutionContext.messages) || s, i = await ye(e);
|
|
745
|
+
if (!i)
|
|
621
746
|
return console.warn("Solutions Search: failed to load solution embeddings cache; skipping search."), { existingMatches: [] };
|
|
622
|
-
if (!
|
|
747
|
+
if (!i.length)
|
|
623
748
|
return { existingMatches: [] };
|
|
624
|
-
const [o] = await
|
|
749
|
+
const [o] = await Re([n]), a = i.map((c) => ({
|
|
625
750
|
solution: c,
|
|
626
|
-
score:
|
|
751
|
+
score: $e(o, c.embedding)
|
|
627
752
|
}));
|
|
628
|
-
|
|
629
|
-
const l =
|
|
753
|
+
a.sort((c, h) => h.score - c.score);
|
|
754
|
+
const l = a.slice(0, pt);
|
|
630
755
|
if (!l.length)
|
|
631
756
|
return { existingMatches: [] };
|
|
632
757
|
const d = l.map(({ solution: c }) => `${c.title}
|
|
@@ -634,157 +759,157 @@ Snippet: ${c.snippet}
|
|
|
634
759
|
Description: ${c.description}`).join(`
|
|
635
760
|
|
|
636
761
|
`), u = t.agentExecutionContext.messages.slice(-11);
|
|
637
|
-
return { existingMatches: (await
|
|
638
|
-
promptText: await
|
|
762
|
+
return { existingMatches: (await A({
|
|
763
|
+
promptText: await x(D, "findExistingSolution"),
|
|
639
764
|
modelTier: "fast",
|
|
640
765
|
temperature: 0,
|
|
641
|
-
schema:
|
|
766
|
+
schema: ct,
|
|
642
767
|
messages: u,
|
|
643
768
|
inputVariables: { query: s, candidates: d }
|
|
644
|
-
})).matchedTitles.map((c) => l.find(({ solution:
|
|
645
|
-
},
|
|
646
|
-
const { existingMatches: s } = t, { hitlResponse:
|
|
647
|
-
if (
|
|
648
|
-
s.length === 1 ?
|
|
649
|
-
const o = s.map((d) => `${d.solution.title}`).join(", "),
|
|
769
|
+
})).matchedTitles.map((c) => l.find(({ solution: h }) => h.title === c)).filter((c) => c !== void 0) };
|
|
770
|
+
}, Mt = (t, e) => {
|
|
771
|
+
const { existingMatches: s } = t, { hitlResponse: n } = e.configurable, i = `confirmExistingSolution:${s[0].solution.id}`;
|
|
772
|
+
if (n?.agentId !== "solutionBuilder" || n.id !== i) {
|
|
773
|
+
s.length === 1 ? re(s[0].solution.id) : ae(s);
|
|
774
|
+
const o = s.map((d) => `${d.solution.title}`).join(", "), a = b("existingSolutionMatch", e, { solutionMatch: o }), l = {
|
|
650
775
|
agentId: "solutionBuilder",
|
|
651
|
-
id:
|
|
776
|
+
id: i,
|
|
652
777
|
kind: "booleanChoice",
|
|
653
|
-
message:
|
|
778
|
+
message: a,
|
|
654
779
|
metadata: []
|
|
655
780
|
};
|
|
656
|
-
throw new
|
|
781
|
+
throw new se(l);
|
|
657
782
|
}
|
|
658
783
|
return {};
|
|
659
|
-
},
|
|
660
|
-
await
|
|
661
|
-
const { currentDesign: s } = t,
|
|
662
|
-
await
|
|
663
|
-
let
|
|
664
|
-
if (
|
|
784
|
+
}, ve = async (t, e) => {
|
|
785
|
+
await be(e);
|
|
786
|
+
const { currentDesign: s } = t, n = t.agentExecutionContext.userRequest;
|
|
787
|
+
await w({ text: b("creatingDesign", e) }, e);
|
|
788
|
+
let i = P(t.selectedTemplate);
|
|
789
|
+
if (i?.initialTemplate || (await H(e), i = P(t.selectedTemplate)), !i?.initialTemplate)
|
|
665
790
|
throw new Error("No hydrated templates are available for solution design.");
|
|
666
|
-
const o =
|
|
667
|
-
s ??
|
|
791
|
+
const o = C(
|
|
792
|
+
s ?? i.initialTemplate,
|
|
668
793
|
{
|
|
669
|
-
itemId: (s ??
|
|
670
|
-
sourceBuildSolution: s?.sourceBuildSolution ??
|
|
671
|
-
params: s?.params ??
|
|
794
|
+
itemId: (s ?? i.initialTemplate)?.solution?.itemId ?? null,
|
|
795
|
+
sourceBuildSolution: s?.sourceBuildSolution ?? i.initialTemplate.sourceBuildSolution,
|
|
796
|
+
params: s?.params ?? i.initialTemplate.params ?? null
|
|
672
797
|
}
|
|
673
|
-
),
|
|
674
|
-
promptText: await
|
|
798
|
+
), a = t.agentExecutionContext.messages.slice(-11), l = await A({
|
|
799
|
+
promptText: await x(D, "designSolution"),
|
|
675
800
|
modelTier: "advanced",
|
|
676
801
|
temperature: 0,
|
|
677
802
|
schema: J,
|
|
678
|
-
messages:
|
|
803
|
+
messages: a,
|
|
679
804
|
inputVariables: {
|
|
680
|
-
currentDesign: JSON.stringify(
|
|
681
|
-
templateInstructions:
|
|
682
|
-
query:
|
|
805
|
+
currentDesign: JSON.stringify(ie(o)),
|
|
806
|
+
templateInstructions: i.instructions,
|
|
807
|
+
query: n
|
|
683
808
|
}
|
|
684
|
-
}), { response: d, featureLayer: u, ...
|
|
809
|
+
}), { response: d, featureLayer: u, ...g } = l, p = oe(
|
|
685
810
|
u,
|
|
686
811
|
o.featureLayer
|
|
687
|
-
), c =
|
|
688
|
-
{ ...
|
|
812
|
+
), c = C(
|
|
813
|
+
{ ...g, featureLayer: p },
|
|
689
814
|
{
|
|
690
815
|
itemId: o?.solution?.itemId,
|
|
691
816
|
sourceBuildSolution: o.sourceBuildSolution,
|
|
692
817
|
templateId: t.selectedTemplate ?? null,
|
|
693
818
|
params: o.params ?? null
|
|
694
819
|
}
|
|
695
|
-
),
|
|
696
|
-
if (!
|
|
820
|
+
), h = new ue(c, i.initialTemplate);
|
|
821
|
+
if (!h.isValid)
|
|
697
822
|
return console.warn(
|
|
698
823
|
"[SolutionBuilder] designSolution validation failed:",
|
|
699
|
-
{ issues:
|
|
824
|
+
{ issues: h.issues, llmResponse: l }
|
|
700
825
|
), {
|
|
701
|
-
outputMessage:
|
|
826
|
+
outputMessage: b("createDesignFailed", e)
|
|
702
827
|
};
|
|
703
|
-
const
|
|
704
|
-
if (!
|
|
828
|
+
const y = c.sourceBuildSolution, S = me(c, y);
|
|
829
|
+
if (!S.ok) {
|
|
705
830
|
console.warn(
|
|
706
831
|
"[SolutionBuilder] designSolution Esri JSON conversion failed:",
|
|
707
|
-
{ error:
|
|
832
|
+
{ error: S.error, llmResponse: l, design: c }
|
|
708
833
|
);
|
|
709
|
-
const
|
|
834
|
+
const _ = b("createDesignFailed", e);
|
|
710
835
|
return {
|
|
711
|
-
outputMessage:
|
|
712
|
-
summary:
|
|
836
|
+
outputMessage: _,
|
|
837
|
+
summary: _,
|
|
713
838
|
status: "success"
|
|
714
839
|
};
|
|
715
840
|
}
|
|
716
|
-
return
|
|
841
|
+
return pe(c), {
|
|
717
842
|
outputMessage: d,
|
|
718
843
|
summary: d,
|
|
719
844
|
status: "success",
|
|
720
845
|
currentDesign: c
|
|
721
846
|
};
|
|
722
|
-
},
|
|
847
|
+
}, Rt = async (t, e) => {
|
|
723
848
|
const { currentDesign: s } = t;
|
|
724
849
|
if (!s)
|
|
725
|
-
return
|
|
726
|
-
const
|
|
727
|
-
await
|
|
728
|
-
const o = await
|
|
729
|
-
promptText: await
|
|
850
|
+
return ve(t, e);
|
|
851
|
+
const n = t.agentExecutionContext.userRequest, i = t.agentExecutionContext.messages.slice(-11);
|
|
852
|
+
await w({ text: b("updatingDesign", e) }, e);
|
|
853
|
+
const o = await A({
|
|
854
|
+
promptText: await x(D, "updateDesign"),
|
|
730
855
|
modelTier: "advanced",
|
|
731
856
|
temperature: 0,
|
|
732
|
-
schema:
|
|
733
|
-
messages:
|
|
857
|
+
schema: lt,
|
|
858
|
+
messages: i,
|
|
734
859
|
inputVariables: {
|
|
735
|
-
currentDesign: JSON.stringify(
|
|
736
|
-
query:
|
|
860
|
+
currentDesign: JSON.stringify(Ne(s)),
|
|
861
|
+
query: n
|
|
737
862
|
}
|
|
738
|
-
}), { response:
|
|
863
|
+
}), { response: a, patches: l } = o;
|
|
739
864
|
if (!l || l.length === 0)
|
|
740
|
-
return
|
|
741
|
-
outputMessage:
|
|
742
|
-
summary:
|
|
865
|
+
return {
|
|
866
|
+
outputMessage: a,
|
|
867
|
+
summary: a,
|
|
743
868
|
status: "success"
|
|
744
869
|
};
|
|
745
|
-
const u = [...l.map((
|
|
746
|
-
op:
|
|
747
|
-
path:
|
|
748
|
-
...
|
|
749
|
-
...
|
|
750
|
-
}))].sort((
|
|
751
|
-
|
|
870
|
+
const u = [...l.map((m) => ({
|
|
871
|
+
op: m.op,
|
|
872
|
+
path: m.path.replace(/\/+$/, ""),
|
|
873
|
+
...m.value != null && m.value !== "" ? { value: JSON.parse(m.value) } : {},
|
|
874
|
+
...m.from != null && m.from !== "" ? { from: m.from } : {}
|
|
875
|
+
}))].sort((m, T) => m.op !== "remove" || T.op !== "remove" ? 0 : T.path.localeCompare(m.path, void 0, { numeric: !0 })), g = structuredClone(
|
|
876
|
+
ie(s)
|
|
752
877
|
);
|
|
753
878
|
try {
|
|
754
|
-
|
|
755
|
-
} catch (
|
|
879
|
+
Pe(g, u, !0);
|
|
880
|
+
} catch (m) {
|
|
756
881
|
console.warn(
|
|
757
882
|
"[SolutionBuilder] updateDesign JSON patch failed:",
|
|
758
|
-
{ error:
|
|
759
|
-
)
|
|
760
|
-
const
|
|
883
|
+
{ error: m, llmResponse: o, patches: u, patchTarget: g }
|
|
884
|
+
);
|
|
885
|
+
const T = b("applyChangeFailed", e);
|
|
761
886
|
return {
|
|
762
|
-
outputMessage:
|
|
763
|
-
summary:
|
|
887
|
+
outputMessage: T,
|
|
888
|
+
summary: T,
|
|
764
889
|
status: "success"
|
|
765
890
|
};
|
|
766
891
|
}
|
|
767
|
-
const
|
|
768
|
-
{ response: "", ...
|
|
892
|
+
const p = C(
|
|
893
|
+
{ response: "", ...g },
|
|
769
894
|
{ itemId: s.solution?.itemId ?? null }
|
|
770
|
-
), c = J.safeParse(
|
|
895
|
+
), c = J.safeParse(p);
|
|
771
896
|
if (!c.success) {
|
|
772
897
|
console.warn(
|
|
773
898
|
"[SolutionBuilder] updateDesign schema validation failed:",
|
|
774
|
-
{ errors: c.error.issues, llmResponse: o, patchedDesign:
|
|
775
|
-
)
|
|
776
|
-
const
|
|
899
|
+
{ errors: c.error.issues, llmResponse: o, patchedDesign: p }
|
|
900
|
+
);
|
|
901
|
+
const m = b("applyChangeFailed", e);
|
|
777
902
|
return {
|
|
778
|
-
outputMessage:
|
|
779
|
-
summary:
|
|
903
|
+
outputMessage: m,
|
|
904
|
+
summary: m,
|
|
780
905
|
status: "success"
|
|
781
906
|
};
|
|
782
907
|
}
|
|
783
|
-
const { response:
|
|
784
|
-
|
|
908
|
+
const { response: h, featureLayer: y, ...S } = c.data, _ = oe(
|
|
909
|
+
y,
|
|
785
910
|
s.featureLayer
|
|
786
|
-
), v =
|
|
787
|
-
{ ...
|
|
911
|
+
), v = C(
|
|
912
|
+
{ ...S, featureLayer: _ },
|
|
788
913
|
{
|
|
789
914
|
itemId: s.solution?.itemId,
|
|
790
915
|
sourceBuildSolution: s.sourceBuildSolution,
|
|
@@ -792,232 +917,145 @@ Description: ${c.description}`).join(`
|
|
|
792
917
|
params: s.params ?? null
|
|
793
918
|
}
|
|
794
919
|
);
|
|
795
|
-
let
|
|
796
|
-
if (
|
|
920
|
+
let L = P(t.selectedTemplate);
|
|
921
|
+
if (L?.initialTemplate || (await H(e), L = P(t.selectedTemplate)), !L?.initialTemplate)
|
|
797
922
|
throw new Error("No hydrated templates are available for solution design.");
|
|
798
|
-
const
|
|
799
|
-
if (!
|
|
923
|
+
const K = new ue(v, L.initialTemplate, !1);
|
|
924
|
+
if (!K.isValid)
|
|
800
925
|
return console.warn(
|
|
801
926
|
"[SolutionBuilder] updateDesign validation failed:",
|
|
802
|
-
{ issues:
|
|
803
|
-
),
|
|
804
|
-
outputMessage:
|
|
927
|
+
{ issues: K.issues, llmResponse: o, patchedDesign: v }
|
|
928
|
+
), {
|
|
929
|
+
outputMessage: b("applyChangeFailed", e)
|
|
805
930
|
};
|
|
806
|
-
const
|
|
807
|
-
if (!
|
|
931
|
+
const we = v.sourceBuildSolution, W = me(v, we);
|
|
932
|
+
if (!W.ok) {
|
|
808
933
|
console.warn(
|
|
809
934
|
"[SolutionBuilder] updateDesign Esri JSON conversion failed:",
|
|
810
|
-
{ error:
|
|
935
|
+
{ error: W.error, llmResponse: o, design: v }
|
|
811
936
|
);
|
|
812
|
-
const
|
|
813
|
-
return
|
|
814
|
-
outputMessage:
|
|
815
|
-
summary:
|
|
937
|
+
const m = b("applyChangeFailed", e);
|
|
938
|
+
return {
|
|
939
|
+
outputMessage: m,
|
|
940
|
+
summary: m,
|
|
816
941
|
status: "success"
|
|
817
942
|
};
|
|
818
943
|
}
|
|
819
|
-
return
|
|
820
|
-
outputMessage:
|
|
821
|
-
summary:
|
|
944
|
+
return pe(v), {
|
|
945
|
+
outputMessage: a,
|
|
946
|
+
summary: a,
|
|
822
947
|
status: "success",
|
|
823
948
|
currentDesign: v
|
|
824
949
|
};
|
|
825
|
-
},
|
|
950
|
+
}, $t = (t) => t.currentDesign !== null ? "updateDesign" : "assessInitialRequest", Ft = (t) => !t.assessment || !t.assessment.isValidUseCase ? "invalidUseCaseExit" : !t.selectedTemplate && t.assessment.matchedTemplates.length > 1 ? "selectTemplateHIL" : "findExistingSolutions", Pt = (t) => t.existingMatches.length > 0 ? "confirmContinueBuildingHIL" : "designSolution", Nt = () => new U(kt).addNode("syncCurrentDesignFromContext", Tt).addNode("assessInitialRequest", Et).addNode("invalidUseCaseExit", At).addNode("selectTemplateHIL", Dt).addNode("findExistingSolutions", Lt).addNode("confirmContinueBuildingHIL", Mt).addNode("designSolution", ve).addNode("updateDesign", Rt).addEdge(z, "syncCurrentDesignFromContext").addConditionalEdges("syncCurrentDesignFromContext", $t, {
|
|
826
951
|
updateDesign: "updateDesign",
|
|
827
952
|
assessInitialRequest: "assessInitialRequest"
|
|
828
|
-
}).addConditionalEdges("assessInitialRequest",
|
|
953
|
+
}).addConditionalEdges("assessInitialRequest", Ft, {
|
|
829
954
|
invalidUseCaseExit: "invalidUseCaseExit",
|
|
830
955
|
selectTemplateHIL: "selectTemplateHIL",
|
|
831
956
|
findExistingSolutions: "findExistingSolutions"
|
|
832
|
-
}).addEdge("invalidUseCaseExit",
|
|
957
|
+
}).addEdge("invalidUseCaseExit", I).addEdge("selectTemplateHIL", "findExistingSolutions").addConditionalEdges("findExistingSolutions", Pt, {
|
|
833
958
|
confirmContinueBuildingHIL: "confirmContinueBuildingHIL",
|
|
834
959
|
designSolution: "designSolution"
|
|
835
|
-
}).addEdge("confirmContinueBuildingHIL", "designSolution").addEdge("designSolution",
|
|
836
|
-
|
|
837
|
-
|
|
838
|
-
|
|
839
|
-
|
|
840
|
-
|
|
841
|
-
},
|
|
842
|
-
"./prompts/
|
|
843
|
-
|
|
844
|
-
|
|
845
|
-
|
|
846
|
-
|
|
847
|
-
|
|
848
|
-
const s = [];
|
|
849
|
-
return (e?.configurable?.context?.configContext.allCards ?? []).forEach((n) => {
|
|
850
|
-
const o = n.title;
|
|
851
|
-
if (t.toLowerCase().includes(o.toLowerCase())) {
|
|
852
|
-
const r = `<a href="" target="solutionId:${n.deployCommonId}">${o}</a>`, l = new RegExp(o, "gi");
|
|
853
|
-
t = t.replace(l, r), s.push({
|
|
854
|
-
solution: {
|
|
855
|
-
title: n.title,
|
|
856
|
-
id: n.deployCommonId,
|
|
857
|
-
snippet: n.snippet,
|
|
858
|
-
description: n.description
|
|
859
|
-
},
|
|
860
|
-
score: 100
|
|
861
|
-
});
|
|
862
|
-
}
|
|
863
|
-
}), { source: t, allMatches: s };
|
|
864
|
-
}
|
|
865
|
-
function Bt(t) {
|
|
866
|
-
return t && t.helperServices.aiAssistantServices ? `${t.helperServices.aiAssistantServices.url}/skills/doc_ai_assistant/chat` : null;
|
|
867
|
-
}
|
|
868
|
-
function ve(t) {
|
|
869
|
-
return t && t.helperServices.aiAssistantServices ? `${t.helperServices.aiAssistantServices.url}/skills/doc_ai_assistant/api/pre-chat` : null;
|
|
870
|
-
}
|
|
871
|
-
async function B(t, e, s) {
|
|
872
|
-
const i = await fetch(e, {
|
|
873
|
-
method: "POST",
|
|
874
|
-
headers: {
|
|
875
|
-
"Content-Type": "application/json",
|
|
876
|
-
token: s
|
|
877
|
-
},
|
|
878
|
-
body: JSON.stringify(t)
|
|
960
|
+
}).addEdge("confirmContinueBuildingHIL", "designSolution").addEdge("designSolution", I).addEdge("updateDesign", I);
|
|
961
|
+
await x(D, "description");
|
|
962
|
+
const Bt = M.object({
|
|
963
|
+
tool: M.enum(["explorer", "builder", "other"]).describe("The selected tool based on the user's query."),
|
|
964
|
+
confidence: M.number().min(0).max(1).describe("A confidence score (0.00–1.00)."),
|
|
965
|
+
rationale: M.string().min(1).describe("A brief rationale for the tool choice (≤140 characters)")
|
|
966
|
+
}), V = /* @__PURE__ */ Object.assign({
|
|
967
|
+
"./prompts/assistantResponse.md": () => import("../../chunks/assistantResponse.js").then((t) => t.default),
|
|
968
|
+
"./prompts/classifyIntent.md": () => import("../../chunks/classifyIntent.js").then((t) => t.default),
|
|
969
|
+
"./prompts/description.md": () => import("../../chunks/description.js").then((t) => t.default)
|
|
970
|
+
}), Q = () => {
|
|
971
|
+
const t = new CustomEvent("assistantProcessing", {
|
|
972
|
+
detail: !1
|
|
879
973
|
});
|
|
880
|
-
|
|
881
|
-
|
|
882
|
-
|
|
883
|
-
|
|
884
|
-
const Ut = (t) => new Promise((e) => setTimeout(e, t)), xe = y.Root({
|
|
885
|
-
// Provides agentExecutionContext, outputMessage, summary, and status
|
|
886
|
-
// channels with the orchestrator's standard reducers/defaults so the
|
|
887
|
-
// sub-agent reports back through the same shape the orchestrator
|
|
888
|
-
// persists into priorSteps.
|
|
889
|
-
...z(),
|
|
890
|
-
solutionResponse: y({
|
|
974
|
+
window.dispatchEvent(t);
|
|
975
|
+
}, xe = f.Root({
|
|
976
|
+
...O(),
|
|
977
|
+
selectedTool: f({
|
|
891
978
|
reducer: (t, e) => e ?? null,
|
|
892
979
|
default: () => null
|
|
893
980
|
}),
|
|
894
|
-
|
|
981
|
+
intentRationale: f({
|
|
895
982
|
reducer: (t, e) => e ?? null,
|
|
896
983
|
default: () => null
|
|
897
|
-
}),
|
|
898
|
-
// Persisted across turns via the graph checkpointer so follow-up questions
|
|
899
|
-
// continue the same service conversation. Null on the very first interaction
|
|
900
|
-
// or after messages are cleared.
|
|
901
|
-
conversationId: y({
|
|
902
|
-
reducer: (t, e) => e ?? t,
|
|
903
|
-
default: () => null
|
|
904
984
|
})
|
|
905
|
-
}), qt =
|
|
906
|
-
|
|
907
|
-
|
|
908
|
-
|
|
909
|
-
const o = { context: {
|
|
910
|
-
kind: "DocAIAssistantRequest",
|
|
911
|
-
filters: {
|
|
912
|
-
products: "ArcGIS Solutions",
|
|
913
|
-
persona: { persona: "apps-solutions" }
|
|
914
|
-
}
|
|
915
|
-
} };
|
|
916
|
-
s && (o.conversationId = s), B(o, i, e ?? "");
|
|
917
|
-
}, zt = async (t, e) => {
|
|
918
|
-
const s = j(e), i = t.documentSkillUrl;
|
|
919
|
-
let n = [];
|
|
920
|
-
await C(
|
|
921
|
-
{ text: s.agentProgress.explorerAgentSearching },
|
|
985
|
+
}), qt = async (t, e) => {
|
|
986
|
+
const s = N(e);
|
|
987
|
+
await w(
|
|
988
|
+
{ text: s?.builderMessages.understandingRequest },
|
|
922
989
|
e
|
|
923
990
|
);
|
|
924
|
-
|
|
925
|
-
|
|
926
|
-
|
|
927
|
-
|
|
928
|
-
|
|
929
|
-
|
|
930
|
-
|
|
931
|
-
products: "ArcGIS Solutions",
|
|
932
|
-
persona: { persona: "apps-solutions" }
|
|
933
|
-
}
|
|
934
|
-
}
|
|
935
|
-
},
|
|
936
|
-
i,
|
|
937
|
-
e?.configurable?.context?.token ?? ""
|
|
938
|
-
);
|
|
939
|
-
o.conversationId && e?.configurable?.context?.setConversationId && e.configurable.context.setConversationId(o.conversationId);
|
|
940
|
-
let r = {
|
|
941
|
-
message: o.message,
|
|
942
|
-
conversationId: o.conversationId,
|
|
943
|
-
hasMore: o.hasMore,
|
|
944
|
-
ackSequenceNumber: o.sequenceNumber,
|
|
945
|
-
inquiryId: o.inquiryId
|
|
946
|
-
}, l = "", d = null;
|
|
947
|
-
const u = async (c) => {
|
|
948
|
-
const g = c.context?.results?.[0]?.reply ?? "";
|
|
949
|
-
if (g !== "") {
|
|
950
|
-
const b = Rt(g), I = Nt(b, e);
|
|
951
|
-
l = I.source, n = [
|
|
952
|
-
...n,
|
|
953
|
-
...I.allMatches.filter(
|
|
954
|
-
(v) => !n.some((k) => k.solution.id === v.solution.id)
|
|
955
|
-
)
|
|
956
|
-
];
|
|
957
|
-
}
|
|
958
|
-
g !== "" && c.context?.results?.[0]?.followupQuestions && (d = c.context.results[0].followupQuestions);
|
|
959
|
-
const x = c.context?.results?.[0]?.status?.currentStatusStep;
|
|
960
|
-
if (x) {
|
|
961
|
-
let b = "";
|
|
962
|
-
x === 1 ? b = s.agentProgress.explorerAgentReading : x === 2 ? b = s.agentProgress.explorerAgentReviewing : x === 3 && (b = s.agentProgress.explorerAgentPreparing), await C({ text: b }, e);
|
|
991
|
+
const n = t.agentExecutionContext.userRequest, i = t.agentExecutionContext.messages.slice(-11), o = e?.configurable?.context?.solutionDesignJson;
|
|
992
|
+
let a = !1;
|
|
993
|
+
if (typeof o == "string" && o.trim())
|
|
994
|
+
try {
|
|
995
|
+
a = JSON.parse(o).solution != null;
|
|
996
|
+
} catch {
|
|
997
|
+
a = !1;
|
|
963
998
|
}
|
|
999
|
+
const l = await x(V, "classifyIntent"), d = await A({
|
|
1000
|
+
promptText: l,
|
|
1001
|
+
modelTier: "advanced",
|
|
1002
|
+
temperature: 0,
|
|
1003
|
+
schema: Bt,
|
|
1004
|
+
messages: i,
|
|
1005
|
+
inputVariables: { query: n, activeSolutionDesign: a }
|
|
1006
|
+
});
|
|
1007
|
+
return {
|
|
1008
|
+
selectedTool: d.tool,
|
|
1009
|
+
intentRationale: d.rationale
|
|
964
1010
|
};
|
|
965
|
-
|
|
966
|
-
|
|
967
|
-
|
|
968
|
-
|
|
969
|
-
|
|
970
|
-
|
|
971
|
-
|
|
972
|
-
|
|
973
|
-
|
|
974
|
-
|
|
975
|
-
|
|
976
|
-
|
|
977
|
-
|
|
978
|
-
|
|
979
|
-
|
|
980
|
-
|
|
981
|
-
|
|
982
|
-
|
|
983
|
-
setTimeout(() => c(g), 0);
|
|
984
|
-
}
|
|
985
|
-
ve(e?.configurable?.context.portal) && we(e?.configurable?.context.portal, e?.configurable?.context.token ?? "", r.conversationId), n.length && (n.length === 1 ? oe(n[0].solution.id) : ne(n));
|
|
986
|
-
const h = new CustomEvent("assistantProcessing", {
|
|
987
|
-
detail: !1
|
|
1011
|
+
}, Ut = async (t, e) => {
|
|
1012
|
+
const n = await Ve().compile().invoke(t, e);
|
|
1013
|
+
return Q(), n;
|
|
1014
|
+
}, zt = async (t, e) => {
|
|
1015
|
+
const n = await Nt().compile().invoke(t, e);
|
|
1016
|
+
return Q(), n;
|
|
1017
|
+
}, Ot = async (t, e) => {
|
|
1018
|
+
const s = N(e), n = t.agentExecutionContext.userRequest, i = t.intentRationale ?? "No rationale available.";
|
|
1019
|
+
await w(
|
|
1020
|
+
{ text: s?.executingSolutionsAssistantAgent },
|
|
1021
|
+
e
|
|
1022
|
+
);
|
|
1023
|
+
const o = await x(V, "assistantResponse"), a = t.agentExecutionContext.messages.slice(-11), l = await Fe({
|
|
1024
|
+
promptText: o,
|
|
1025
|
+
modelTier: "fast",
|
|
1026
|
+
temperature: 0,
|
|
1027
|
+
messages: a,
|
|
1028
|
+
inputVariables: { query: n, rationale: i }
|
|
988
1029
|
});
|
|
989
|
-
return
|
|
1030
|
+
return Q(), {
|
|
990
1031
|
outputMessage: l,
|
|
991
1032
|
summary: l,
|
|
992
|
-
status: "success"
|
|
993
|
-
solutionResponse: r,
|
|
994
|
-
conversationId: r.conversationId
|
|
995
|
-
};
|
|
996
|
-
}, Ot = async (t, e) => {
|
|
997
|
-
let s = null;
|
|
998
|
-
return t.documentSkillUrl === null && e?.configurable?.context?.portal && (s = Bt(e.configurable.context.portal)), {
|
|
999
|
-
documentSkillUrl: s
|
|
1033
|
+
status: "success"
|
|
1000
1034
|
};
|
|
1001
|
-
}, jt =
|
|
1002
|
-
|
|
1003
|
-
|
|
1004
|
-
|
|
1005
|
-
|
|
1035
|
+
}, jt = (t) => t.selectedTool ?? "other", Jt = () => new U(xe).addNode("classifyIntent", qt).addNode("routeToExplorer", Ut).addNode("routeToBuilder", zt).addNode("assistantResponse", Ot).addEdge(z, "classifyIntent").addConditionalEdges("classifyIntent", jt, {
|
|
1036
|
+
explorer: "routeToExplorer",
|
|
1037
|
+
builder: "routeToBuilder",
|
|
1038
|
+
other: "assistantResponse"
|
|
1039
|
+
}).addEdge("routeToExplorer", I).addEdge("routeToBuilder", I).addEdge("assistantResponse", I), Gt = await x(V, "description"), Ht = {
|
|
1040
|
+
id: "solutionsAssistant",
|
|
1041
|
+
name: "Solutions Assistant Agent",
|
|
1042
|
+
description: Gt,
|
|
1043
|
+
createGraph: Jt,
|
|
1006
1044
|
workspace: xe
|
|
1007
|
-
},
|
|
1008
|
-
class
|
|
1045
|
+
}, Vt = "https://links.esri.com/solutions/agol-organizational-account", Qt = "https://links.esri.com/solutions/configure-assistants";
|
|
1046
|
+
class Kt extends Ce {
|
|
1009
1047
|
constructor() {
|
|
1010
1048
|
super(), this.open = !1, this.userFirstName = "", this.builderVisible = !1, this.hasActiveBuilderDesign = !1, this._conversationId = void 0, this._orgSettings = {
|
|
1011
1049
|
aiAssistantsEnabled: !1,
|
|
1012
1050
|
blockBetaApps: !0,
|
|
1013
1051
|
colocateCompute: !1
|
|
1014
|
-
}, this._suggestedPrompts = [], this._hasInteracted = !1, this._isMobile = window.innerWidth <= 800, this._translations =
|
|
1015
|
-
context:
|
|
1052
|
+
}, this._suggestedPrompts = [], this._hasInteracted = !1, this._isMobile = window.innerWidth <= 800, this._translations = Ie({ name: "arcgis-solutions-assistant", blocking: !0 }), this._builderWidth = 48, this._solutionDesignJson = '{ "solution": null }', this._isAssistantBusy = !1, this._isBuilderBusy = !1, this._preChatCheck = !1, this._assistantRef = Le(), this._configContextConsumer = X({
|
|
1053
|
+
context: Te,
|
|
1016
1054
|
subscribe: !0,
|
|
1017
1055
|
callback: (e) => {
|
|
1018
|
-
e?.portalURL && (
|
|
1056
|
+
e?.portalURL && (ee.portalUrl = e.portalURL), e?.userSession && !this.userFirstName && this._loadUserFirstName(), e?.authentication?.PortalSubset?.orgSettings && (this._orgSettings = e?.authentication?.PortalSubset?.orgSettings);
|
|
1019
1057
|
}
|
|
1020
|
-
}), this._builderDesignContextConsumer =
|
|
1058
|
+
}), this._builderDesignContextConsumer = X({
|
|
1021
1059
|
context: Ee,
|
|
1022
1060
|
subscribe: !0,
|
|
1023
1061
|
callback: (e) => {
|
|
@@ -1025,31 +1063,31 @@ class Qt extends _e {
|
|
|
1025
1063
|
}
|
|
1026
1064
|
}), this._handleResize = () => {
|
|
1027
1065
|
this._isMobile = window.innerWidth <= 800;
|
|
1028
|
-
}, this.closeAssistant =
|
|
1029
|
-
const s = e.composedPath().find((
|
|
1066
|
+
}, this.closeAssistant = Y(), this.assistantProcessing = Y(), this._handleAssistantLinkClick = (e) => {
|
|
1067
|
+
const s = e.composedPath().find((n) => n instanceof HTMLAnchorElement);
|
|
1030
1068
|
if (s?.href)
|
|
1031
1069
|
if (e.preventDefault(), s.target.indexOf("solutionId:") > -1) {
|
|
1032
|
-
const
|
|
1033
|
-
this._emitItemIdFromAI(
|
|
1070
|
+
const n = s.target.split("solutionId:")[1];
|
|
1071
|
+
this._emitItemIdFromAI(n);
|
|
1034
1072
|
} else
|
|
1035
1073
|
window.open(s.href, "_blank", "noopener,noreferrer");
|
|
1036
1074
|
}, this._onSolutionDesignUpdate = (e) => {
|
|
1037
|
-
const
|
|
1038
|
-
this._solutionDesignJson =
|
|
1075
|
+
const n = e.detail;
|
|
1076
|
+
this._solutionDesignJson = n ? JSON.stringify(n, null, 2) : '{ "solution": null }';
|
|
1039
1077
|
}, this._handleSignIn = () => {
|
|
1040
1078
|
this._configContextConsumer.value?.authentication?.signIn("aiOpen");
|
|
1041
1079
|
}, this._checkURLOpenParameter = () => {
|
|
1042
1080
|
this.open = this._configContextConsumer.value?.authentication?.SignInParam === "aiOpen" || this.open;
|
|
1043
1081
|
}, this.listenOn(window, "arcgisFeedback", (e) => {
|
|
1044
|
-
const s = e.detail, { agentPicked:
|
|
1045
|
-
this._sendFeedback(s.content, o ??
|
|
1082
|
+
const s = e.detail, { agentPicked: n, taskAssigned: i, userMessage: o } = this._parseAgentPickedAndTask(s);
|
|
1083
|
+
this._sendFeedback(s.content, o ?? i ?? "", s.feedback?.positive ? "Good" : s.feedback?.positive == "Bad" ? "Bad" : "N/A", n ?? "");
|
|
1046
1084
|
});
|
|
1047
1085
|
}
|
|
1048
1086
|
static {
|
|
1049
1087
|
this.properties = { open: 5, userFirstName: 1, builderVisible: 5, hasActiveBuilderDesign: 5, _conversationId: 16, _orgSettings: 16, _suggestedPrompts: 16, _hasInteracted: 16, _isMobile: 16, _translations: 16, _builderWidth: 16, _solutionDesignJson: 16, _isAssistantBusy: 16, _isBuilderBusy: 16, _preChatCheck: 16 };
|
|
1050
1088
|
}
|
|
1051
1089
|
static {
|
|
1052
|
-
this.styles =
|
|
1090
|
+
this.styles = Ue;
|
|
1053
1091
|
}
|
|
1054
1092
|
get _telemetry() {
|
|
1055
1093
|
return this._configContextConsumer.value?.telemetrySession;
|
|
@@ -1064,66 +1102,60 @@ class Qt extends _e {
|
|
|
1064
1102
|
this._checkURLOpenParameter();
|
|
1065
1103
|
}
|
|
1066
1104
|
load() {
|
|
1067
|
-
this._configContextConsumer.value?.portalURL && (
|
|
1105
|
+
this._configContextConsumer.value?.portalURL && (ee.portalUrl = this._configContextConsumer.value.portalURL);
|
|
1068
1106
|
}
|
|
1069
1107
|
firstUpdated(e) {
|
|
1070
1108
|
this._loadUserFirstName();
|
|
1071
1109
|
}
|
|
1072
1110
|
willUpdate(e) {
|
|
1073
|
-
e.has("open") && this.open && window.dispatchEvent(new CustomEvent("openAssistant")), this._configContextConsumer.value?.authentication && this._configContextConsumer.value?.userSession?.token && (this._preChatCheck || (
|
|
1111
|
+
e.has("open") && this.open && window.dispatchEvent(new CustomEvent("openAssistant")), this._configContextConsumer.value?.authentication && this._configContextConsumer.value?.userSession?.token && (this._preChatCheck || (ce(this._configContextConsumer.value?.authentication.Portal, this._configContextConsumer.value?.userSession?.token), this._preChatCheck = !0)), this._configContextConsumer.value?.userSession?.token && this._configContextConsumer.value?.authentication?.CanUseAI;
|
|
1074
1112
|
}
|
|
1075
1113
|
_renderNoSign() {
|
|
1076
|
-
return
|
|
1114
|
+
return k`<calcite-notice class="margin-lg" open scale=m icon=effects kind=info><div slot=message>${this._translations.signInMessage}</div><calcite-link @click=${this._handleSignIn} slot=link title=${this._translations.signInMessage ?? Z} class="padding-top-10">${this._translations.signIn}</calcite-link></calcite-notice>`;
|
|
1077
1115
|
}
|
|
1078
1116
|
_renderNoPermission() {
|
|
1079
|
-
return
|
|
1117
|
+
return k`<calcite-notice open scale=m icon=effects kind=info><div slot=title>${this._translations.noPermissionTitle}</div><div slot=message class="padding-top-10">${ke(this._translations.noPermissionMessage.replace("{{orgUrl}}", Vt).replace("{{configAI}}", Qt))}</div></calcite-notice>`;
|
|
1080
1118
|
}
|
|
1081
1119
|
render() {
|
|
1082
1120
|
let e = this._suggestedPrompts.length > 0 ? this._suggestedPrompts : this._hasInteracted ? [] : Object.values(this._translations.defaultFollowUpQuestions);
|
|
1083
|
-
return this._suggestedPrompts.length > 0 ? e = this._suggestedPrompts : this._hasInteracted || (e = [...Object.values(this._translations.defaultFollowUpQuestions)]),
|
|
1121
|
+
return this._suggestedPrompts.length > 0 ? e = this._suggestedPrompts : this._hasInteracted || (e = [...Object.values(this._translations.defaultFollowUpQuestions)]), k`<calcite-panel class="chat-panel"><div class="header-content" slot=header-content><span class="header-title">${this._translations.solutionAssistantTitle}</span></div>${this._configContextConsumer.value?.userSession?.token ? this._configContextConsumer.value?.authentication?.CanUseAI ? k`${!this._isMobile && k`<calcite-action id=solutionBuilderAction icon=pencil-square .text=${this._translations.tooltips.solutionBuilder} .indicator=${this.hasActiveBuilderDesign} .disabled=${!this.hasActiveBuilderDesign} .active=${this.builderVisible} selection-appearance=highlight @click=${() => {
|
|
1084
1122
|
window.dispatchEvent(new CustomEvent("toggleSolutionBuilder"));
|
|
1085
1123
|
}} scale=m slot=header-actions-end></calcite-action>` || ""}<calcite-action id=newChatButton icon=speech-bubble-plus .text=${this._translations.tooltips.newConversation} @click=${() => {
|
|
1086
1124
|
this._conversationId = void 0, this._suggestedPrompts = [], this._hasInteracted = !1, this._assistantRef.value?.clearChatHistory();
|
|
1087
|
-
}} scale=m slot=header-actions-end></calcite-action><calcite-tooltip placement=bottom reference-element=newChatButton><span>${this._translations.tooltips.newConversation}</span></calcite-tooltip>${!this._isMobile &&
|
|
1125
|
+
}} scale=m slot=header-actions-end></calcite-action><calcite-tooltip placement=bottom reference-element=newChatButton><span>${this._translations.tooltips.newConversation}</span></calcite-tooltip>${!this._isMobile && k`<calcite-tooltip placement=bottom reference-element=solutionBuilderAction><span>${this._translations.tooltips.toggleSolutionBuilder}</span></calcite-tooltip>` || ""}<arcgis-assistant reference-element copy-enabled feedback-enabled heading description entry-message=${this._translations.defaultStartUpMessage ?? Z} .suggestedPrompts=${e} @arcgisSubmit=${(s) => {
|
|
1088
1126
|
console.log("arcgis submit: ", s.detail), this._suggestedPrompts = [], e = [], this._hasInteracted = !0;
|
|
1089
|
-
const
|
|
1127
|
+
const n = Date.now(), i = De(n), o = s.detail || "Unknown";
|
|
1090
1128
|
this._telemetry?.logEvent({
|
|
1091
|
-
category:
|
|
1129
|
+
category: Ae.ASSISTANT,
|
|
1092
1130
|
action: "Chat",
|
|
1093
1131
|
dimensions: [o],
|
|
1094
|
-
metrics: [
|
|
1132
|
+
metrics: [i]
|
|
1095
1133
|
}), this.assistantProcessing.emit(!0);
|
|
1096
1134
|
}} @arcgisFeedback=${(s) => {
|
|
1097
1135
|
s.detail;
|
|
1098
|
-
}} ${
|
|
1136
|
+
}} ${Me(this._assistantRef)}><arcgis-assistant-agent .agent=${Ht} .context=${{
|
|
1099
1137
|
token: this._configContextConsumer.value?.userSession?.token,
|
|
1100
1138
|
configContext: this._configContextConsumer.value,
|
|
1101
1139
|
convoId: this._conversationId,
|
|
1102
1140
|
portal: this._configContextConsumer.value?.authentication.Portal,
|
|
1103
1141
|
assistantRef: this._assistantRef,
|
|
1104
1142
|
translations: this._translations,
|
|
1143
|
+
solutionDesignJson: this._solutionDesignJson,
|
|
1105
1144
|
updateSuggestedPrompts: (s) => {
|
|
1106
1145
|
this._suggestedPrompts = s;
|
|
1107
1146
|
},
|
|
1108
1147
|
setConversationId: (s) => {
|
|
1109
1148
|
this._conversationId = s;
|
|
1110
|
-
}
|
|
1111
|
-
}}></arcgis-assistant-agent><arcgis-assistant-agent .agent=${Ge} .context=${{
|
|
1112
|
-
translations: this._translations,
|
|
1149
|
+
},
|
|
1113
1150
|
clearSuggestedPrompts: () => {
|
|
1114
1151
|
this._suggestedPrompts = [];
|
|
1115
1152
|
}
|
|
1116
|
-
}}></arcgis-assistant-agent><arcgis-assistant-agent .agent=${Pt} .context=${{
|
|
1117
|
-
solutionDesignJson: this._solutionDesignJson,
|
|
1118
|
-
translations: this._translations,
|
|
1119
|
-
token: this._configContextConsumer.value?.userSession?.token,
|
|
1120
|
-
configContext: this._configContextConsumer.value
|
|
1121
1153
|
}}></arcgis-assistant-agent></arcgis-assistant><div slot=footer class="disclaimer-div width-100"><calcite-chip class="beta-chip" appearance=outline kind=neutral .label=${this._translations.betaTag} scale=s>${this._translations.betaTag}</calcite-chip><span>${this._translations.disclaimerMessage} <a href=https://links.esri.com/solutions/security-concern rel="noopener noreferrer" target=_blank>${this._translations.reportConcern}</a></span></div>` : this._renderNoPermission() : this._renderNoSign()}<calcite-action icon=x id=closeAssistantButton .label=${this._translations.tooltips.close} @click=${() => {
|
|
1122
1154
|
this.closeAssistant.emit(!0);
|
|
1123
1155
|
}} slot=header-actions-end .text=${this._translations.tooltips.close}></calcite-action><calcite-tooltip placement=bottom reference-element=closeAssistantButton><span>${this._translations.tooltips.close}</span></calcite-tooltip></calcite-panel>`;
|
|
1124
1156
|
}
|
|
1125
|
-
_sendFeedback(e, s,
|
|
1126
|
-
const o = `https://survey123.arcgis.com/share/6e349a50b4504ca6b6107216d568db5f?field:_source=${encodeURIComponent("Solutions Assistant")}&field:user_evaluation=${encodeURIComponent(
|
|
1157
|
+
_sendFeedback(e, s, n, i) {
|
|
1158
|
+
const o = `https://survey123.arcgis.com/share/6e349a50b4504ca6b6107216d568db5f?field:_source=${encodeURIComponent("Solutions Assistant")}&field:user_evaluation=${encodeURIComponent(n)}&field:question=${encodeURIComponent(s)}&field:answer=${encodeURIComponent(e)}&field:context=${encodeURIComponent(JSON.stringify({ agent: i }))}&field:version=${encodeURIComponent("v2")}`;
|
|
1127
1159
|
window.open(o, "_blank");
|
|
1128
1160
|
}
|
|
1129
1161
|
async _loadUserFirstName() {
|
|
@@ -1137,14 +1169,14 @@ class Qt extends _e {
|
|
|
1137
1169
|
}
|
|
1138
1170
|
}
|
|
1139
1171
|
_parseAgentPickedAndTask(e) {
|
|
1140
|
-
const s = Array.from(this._assistantRef.value?.messages || []),
|
|
1172
|
+
const s = Array.from(this._assistantRef.value?.messages || []), n = e.log || [], a = [...s].sort((c, h) => h.id - c.id).find((c) => c.role === "user" && c.id <= e.id)?.content || null, l = n.find((c) => typeof c == "string" && c.includes("Agent picked:")) ?? null;
|
|
1141
1173
|
if (!l)
|
|
1142
|
-
return { agentPicked: null, taskAssigned: null, userMessage:
|
|
1174
|
+
return { agentPicked: null, taskAssigned: null, userMessage: a };
|
|
1143
1175
|
const d = /Agent picked:\s*(.*?)\s*(?:\\n|\r?\n)\s*Task Assigned:\s*([\s\S]*)$/i, u = l.match(d);
|
|
1144
1176
|
if (!u)
|
|
1145
|
-
return { agentPicked: null, taskAssigned: null, userMessage:
|
|
1146
|
-
const
|
|
1147
|
-
return { agentPicked:
|
|
1177
|
+
return { agentPicked: null, taskAssigned: null, userMessage: a };
|
|
1178
|
+
const g = u[1].trim(), p = u[2].trim();
|
|
1179
|
+
return { agentPicked: g, taskAssigned: p, userMessage: a };
|
|
1148
1180
|
}
|
|
1149
1181
|
_emitItemIdFromAI(e) {
|
|
1150
1182
|
const s = new CustomEvent("solutionIDFromAssistant", {
|
|
@@ -1155,7 +1187,7 @@ class Qt extends _e {
|
|
|
1155
1187
|
window.dispatchEvent(s);
|
|
1156
1188
|
}
|
|
1157
1189
|
}
|
|
1158
|
-
|
|
1190
|
+
Se("arcgis-solutions-assistant", Kt);
|
|
1159
1191
|
export {
|
|
1160
|
-
|
|
1192
|
+
Kt as ArcgisSolutionsAssistant
|
|
1161
1193
|
};
|