@arcgis/ai-components 5.2.0-next.5 → 5.2.0-next.50
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/agent-utils/FunctionAgent.d.ts +2 -2
- package/dist/agent-utils/LLMAgent.d.ts +2 -2
- package/dist/agent-utils/LLMAgent.js +1 -0
- package/dist/agent-utils/WorkflowAgent.d.ts +2 -2
- package/dist/agent-utils/index.d.ts +177 -0
- package/dist/agent-utils/index.js +167 -0
- package/dist/agent-utils/middlewares/trace.d.ts +2 -0
- package/dist/agent-utils/middlewares/trace.js +25 -33
- package/dist/agent-utils/tools/FunctionTool.d.ts +2 -2
- package/dist/agent-utils/types.d.ts +36 -7
- package/dist/agent-utils/workflows/ConditionalWorkflow.d.ts +2 -2
- package/dist/agent-utils/workflows/LoopWorkflow.d.ts +2 -2
- package/dist/agent-utils/workflows/ParallelWorkflow.d.ts +2 -2
- package/dist/agent-utils/workflows/RouterWorkflow.d.ts +2 -2
- package/dist/agent-utils/workflows/SequentialWorkflow.d.ts +2 -2
- package/dist/agent-utils/workflows/SwitchWorkflow.d.ts +2 -2
- package/dist/cdn/2ER3LN6U.js +2 -0
- package/dist/cdn/2W6XPTA6.js +9 -0
- package/dist/cdn/3DJDRAGV.js +2 -0
- package/dist/cdn/3LCF5HIE.js +3 -0
- package/dist/cdn/{AMP6IALT.js → 3UEKINYC.js} +1 -1
- package/dist/cdn/434TAA3J.js +2 -0
- package/dist/cdn/4CEMUECT.js +2 -0
- package/dist/cdn/4G5XCUE5.js +2 -0
- package/dist/cdn/57OMVTIU.js +2 -0
- package/dist/cdn/5I35MJXT.js +48 -0
- package/dist/cdn/6O6KMX3M.js +2 -0
- package/dist/cdn/6U7TEAAJ.js +2 -0
- package/dist/cdn/7FY4G4K2.js +2 -0
- package/dist/cdn/7YIRK2E3.js +2 -0
- package/dist/cdn/A4JLOAOH.js +2 -0
- package/dist/cdn/{ZS2TZ6BF.js → AOVJ34QE.js} +1 -1
- package/dist/cdn/APFZY4PI.js +2 -0
- package/dist/cdn/BE7ZN5FZ.js +2 -0
- package/dist/cdn/{FL4W4VYN.js → BL273EGZ.js} +17 -1
- package/dist/cdn/BMGQJYTE.js +2 -0
- package/dist/cdn/{5ZZGKP7N.js → CEKOEHB3.js} +1 -1
- package/dist/cdn/CMG2NY3K.js +2 -0
- package/dist/cdn/DMLRWHBA.js +2 -0
- package/dist/cdn/EQLRFZVU.js +18 -0
- package/dist/cdn/EW6AYEUX.js +36 -0
- package/dist/cdn/F5SUU35Z.js +2 -0
- package/dist/cdn/FYW633VX.js +2 -0
- package/dist/cdn/{ZLXN7NMF.js → FYZATVB3.js} +10 -8
- package/dist/cdn/{H7422XUG.js → GYVSHAUI.js} +1 -1
- package/dist/cdn/HBLRVXEB.js +2 -0
- package/dist/cdn/HJG7QM2R.js +9 -0
- package/dist/cdn/HQXPPYMD.js +2 -0
- package/dist/cdn/{FX7UOGHP.js → ICBIUFK7.js} +1 -1
- package/dist/cdn/ICYUPLZM.js +56 -0
- package/dist/cdn/IEHPNCTL.js +2 -0
- package/dist/cdn/IHP25JWI.js +99 -0
- package/dist/cdn/J6A4AS7E.js +22 -0
- package/dist/cdn/{NE7E52YR.js → JEBRN3EU.js} +9 -3
- package/dist/cdn/JEL5M7FA.js +2 -0
- package/dist/cdn/{CXWBEDXN.js → JSIGEUX7.js} +6 -4
- package/dist/cdn/JSJ4RMOE.js +2 -0
- package/dist/cdn/JVYPIWEU.js +2 -0
- package/dist/cdn/KJJAXCP4.js +2 -0
- package/dist/cdn/LHLO6PTD.js +2 -0
- package/dist/cdn/{7RCQFLPP.js → LK7ZIQW6.js} +1 -1
- package/dist/cdn/LUY6V4TP.js +181 -0
- package/dist/cdn/M3MRIGDZ.js +2 -0
- package/dist/cdn/MS5EA2KY.js +2 -0
- package/dist/cdn/MWYBF3F3.js +66 -0
- package/dist/cdn/NAKAZDJ7.js +4 -0
- package/dist/cdn/NEV6OZN3.js +71 -0
- package/dist/cdn/O5TONDCH.js +2 -0
- package/dist/cdn/OC5GA5ZQ.js +3 -0
- package/dist/cdn/OGMMYFHR.js +2 -0
- package/dist/cdn/{23EQTPO3.js → OKVLGJAG.js} +1 -1
- package/dist/cdn/OYNIFMCJ.js +2 -0
- package/dist/cdn/PNFBQ6JV.js +180 -0
- package/dist/cdn/{LQ6R5YRN.js → PQ2DPOFM.js} +1 -1
- package/dist/cdn/PVE7Q43N.js +2 -0
- package/dist/cdn/R74ZHFA6.js +2 -0
- package/dist/cdn/RLEHNAIA.js +2 -0
- package/dist/cdn/{X2ZDYHCG.js → SDWWUWAF.js} +10 -5
- package/dist/cdn/SJR4IR57.js +2 -0
- package/dist/cdn/SPVOBZAL.js +2 -0
- package/dist/cdn/SUA3YJTU.js +22 -0
- package/dist/cdn/T7DYMSJV.js +65 -0
- package/dist/cdn/TFT6HK3O.js +208 -0
- package/dist/cdn/THR22OXW.js +2 -0
- package/dist/cdn/TPULIO6I.js +34 -0
- package/dist/cdn/{6YMR4QSD.js → UHEYPSOR.js} +1 -1
- package/dist/cdn/UK7PR2FE.js +2 -0
- package/dist/cdn/UZLQALHY.js +2 -0
- package/dist/cdn/V6HOUZPZ.js +2 -0
- package/dist/cdn/VAXH6RUQ.js +134 -0
- package/dist/cdn/VPFIUEKT.js +14 -0
- package/dist/cdn/VXFQANGJ.js +2 -0
- package/dist/cdn/XCRR2EEG.js +6 -0
- package/dist/cdn/YHQJ66WJ.js +2 -0
- package/dist/cdn/YYSMCB4A.js +2 -0
- package/dist/cdn/Z6I6JACX.js +3 -0
- package/dist/cdn/ZB57WYHC.js +2 -0
- package/dist/cdn/ZS6SXJP2.js +2 -0
- package/dist/cdn/{ZTBA5PM7.js → ZU2FHVNK.js} +1 -1
- package/dist/cdn/agent-utils/index.js +2 -0
- package/dist/cdn/agent-utils/middlewares/humanInTheLoop.js +3 -0
- package/dist/cdn/agent-utils/middlewares/middleware.js +2 -0
- package/dist/cdn/agent-utils/middlewares/trace.js +2 -0
- package/dist/cdn/index.js +1 -1
- package/dist/cdn/main.css +1 -1
- package/dist/chunks/adapter.js +1794 -1597
- package/dist/chunks/arcgisKnowledgeGraph.js +126 -71
- package/dist/chunks/arcgis_knowledge_current_lc_context.js +19 -2
- package/dist/chunks/arcgis_knowledge_current_map_context.js +31 -2
- package/dist/chunks/arcgis_knowledge_cypher_query_prompt.js +102 -0
- package/dist/chunks/arcgis_knowledge_summarize_result_prompt.js +116 -27
- package/dist/chunks/converterUtils.js +39 -32
- package/dist/chunks/dataExplorationGraph.js +139 -113
- package/dist/chunks/data_explore_query_prompt.js +9 -4
- package/dist/chunks/generateLayerDescriptions.js +248 -228
- package/dist/chunks/helpGraph.js +17 -13
- package/dist/chunks/help_prompt.js +34 -17
- package/dist/chunks/index.js +11 -0
- package/dist/chunks/intent_prompt.js +16 -0
- package/dist/chunks/layerStylingGraph.js +24 -20
- package/dist/chunks/navigationGraph.js +33 -28
- package/dist/chunks/navigation_intent_prompt.js +8 -2
- package/dist/chunks/orchestrator.js +110 -108
- package/dist/chunks/slottableRequestUtils.js +3 -7
- package/dist/chunks/state.js +1 -1
- package/dist/chunks/summarize_query_response_prompt.js +9 -7
- package/dist/chunks/toolCallResponse.js +12 -9
- package/dist/chunks/utils2.js +8 -8
- package/dist/components/arcgis-assistant/customElement.d.ts +27 -0
- package/dist/components/arcgis-assistant/customElement.js +385 -152
- package/dist/components/arcgis-assistant/index.js +2 -3
- package/dist/components/arcgis-assistant/types.d.ts +14 -1
- package/dist/components/arcgis-assistant-agent/customElement.js +5 -1
- package/dist/components/arcgis-assistant-chat/customElement.d.ts +8 -2
- package/dist/components/arcgis-assistant-chat/customElement.js +23 -18
- package/dist/components/arcgis-assistant-chat-entry/customElement.d.ts +4 -1
- package/dist/components/arcgis-assistant-chat-entry/customElement.js +25 -18
- package/dist/components/arcgis-assistant-data-exploration-agent/customElement.js +11 -5
- package/dist/components/arcgis-assistant-help-agent/customElement.js +8 -2
- package/dist/components/arcgis-assistant-interrupt/customElement.d.ts +4 -1
- package/dist/components/arcgis-assistant-interrupt/customElement.js +12 -8
- package/dist/components/arcgis-assistant-interrupt-preview/customElement.js +20 -0
- package/dist/components/arcgis-assistant-interrupt-preview/index.js +2 -0
- package/dist/components/arcgis-assistant-knowledge-agent/customElement.d.ts +7 -7
- package/dist/components/arcgis-assistant-knowledge-agent/customElement.js +17 -11
- package/dist/components/arcgis-assistant-layer-styling-agent/customElement.js +10 -4
- package/dist/components/arcgis-assistant-message/customElement.d.ts +23 -0
- package/dist/components/arcgis-assistant-message/customElement.js +28 -26
- package/dist/components/arcgis-assistant-message/index.d.ts +1 -0
- package/dist/components/arcgis-assistant-message/index.js +2 -0
- package/dist/components/arcgis-assistant-message-block/customElement.d.ts +1 -1
- package/dist/components/arcgis-assistant-message-block/customElement.js +18 -11
- package/dist/components/arcgis-assistant-message-block/index.js +1 -0
- package/dist/components/arcgis-assistant-message-feedback/customElement.d.ts +4 -1
- package/dist/components/arcgis-assistant-message-footer/customElement.d.ts +4 -1
- package/dist/components/arcgis-assistant-message-loading/customElement.d.ts +8 -1
- package/dist/components/arcgis-assistant-message-loading/customElement.js +8 -8
- package/dist/components/arcgis-assistant-message-loading/index.js +1 -0
- package/dist/components/arcgis-assistant-message-log/customElement.d.ts +4 -1
- package/dist/components/arcgis-assistant-message-read-aloud/customElement.d.ts +4 -1
- package/dist/components/arcgis-assistant-message-text/customElement.d.ts +5 -1
- package/dist/components/arcgis-assistant-message-text/customElement.js +12 -12
- package/dist/components/arcgis-assistant-navigation-agent/customElement.js +11 -5
- package/dist/components/arcgis-assistant-speech-input/customElement.d.ts +6 -1
- package/dist/components/arcgis-assistant-suggested-prompts/customElement.d.ts +4 -1
- package/dist/components/arcgis-assistant-suggested-prompts/customElement.js +8 -8
- package/dist/components/arcgis-assistant-user-message/customElement.d.ts +4 -1
- package/dist/components/arcgis-assistant-user-message/customElement.js +10 -8
- 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/index.d.ts +4 -0
- package/dist/loader.js +7 -6
- package/dist/oauth-callback.html +1 -1
- package/dist/types/lumina.d.ts +11 -5
- package/dist/types/preact.d.ts +12 -5
- package/dist/types/react.d.ts +13 -5
- package/dist/types/stencil.d.ts +11 -5
- package/dist/utils/index.d.ts +85 -47
- package/dist/utils/index.js +48 -47
- package/package.json +13 -12
- package/dist/cdn/2AXF774U.js +0 -2
- package/dist/cdn/3BKUCFKS.js +0 -36
- package/dist/cdn/3PKJWIC3.js +0 -2
- package/dist/cdn/3WINIQWY.js +0 -2
- package/dist/cdn/462JBSEV.js +0 -422
- package/dist/cdn/5QAHYX7Y.js +0 -5
- package/dist/cdn/7BCR6TUO.js +0 -2
- package/dist/cdn/7GH7VSB2.js +0 -2
- package/dist/cdn/7PLV4QH6.js +0 -2
- package/dist/cdn/AO7BQHKC.js +0 -2
- package/dist/cdn/AXDZBBNL.js +0 -45
- package/dist/cdn/DDLZOMUY.js +0 -2
- package/dist/cdn/DHOVCT6R.js +0 -2
- package/dist/cdn/DO2P3PWF.js +0 -106
- package/dist/cdn/ERBQSEPQ.js +0 -22
- package/dist/cdn/F2AHA4GB.js +0 -54
- package/dist/cdn/FX5JFRDL.js +0 -2
- package/dist/cdn/GBNUMN4J.js +0 -16
- package/dist/cdn/GJUXVEOF.js +0 -166
- package/dist/cdn/HB5A5R2E.js +0 -2
- package/dist/cdn/J5CMRCPS.js +0 -3
- package/dist/cdn/KMQ3SP4I.js +0 -5
- package/dist/cdn/M6F4MXDK.js +0 -14
- package/dist/cdn/MH5RPXHM.js +0 -2
- package/dist/cdn/NAUXSHIE.js +0 -72
- package/dist/cdn/NVI3I46B.js +0 -2
- package/dist/cdn/OAVEHGB6.js +0 -2
- package/dist/cdn/OH64RMOR.js +0 -4
- package/dist/cdn/P6OPJQMC.js +0 -3
- package/dist/cdn/QR54T33D.js +0 -2
- package/dist/cdn/RVOAPUBN.js +0 -2
- package/dist/cdn/SXDLXCIM.js +0 -2
- package/dist/cdn/USMDJUFS.js +0 -2
- package/dist/cdn/V2P4AIGG.js +0 -2
- package/dist/cdn/Y333DGV6.js +0 -2
- package/dist/cdn/YIMNOUTF.js +0 -2
|
@@ -1,46 +1,48 @@
|
|
|
1
1
|
/* COPYRIGHT Esri - https://js.arcgis.com/5.2/LICENSE.txt */
|
|
2
|
-
import { Annotation as
|
|
3
|
-
import
|
|
4
|
-
import { ChatPromptTemplate as
|
|
5
|
-
import {
|
|
6
|
-
import { AIMessage as
|
|
7
|
-
import { createAgent as
|
|
8
|
-
import { ChatOpenAI as
|
|
9
|
-
import
|
|
10
|
-
import
|
|
11
|
-
|
|
2
|
+
import { Annotation as m } from "@langchain/langgraph/web";
|
|
3
|
+
import u, { z as r } from "zod";
|
|
4
|
+
import { ChatPromptTemplate as D, SystemMessagePromptTemplate as K } from "@langchain/core/prompts";
|
|
5
|
+
import { s as f } from "./index.js";
|
|
6
|
+
import { AIMessage as B, isAIMessage as W, isToolMessage as X } from "@langchain/core/messages";
|
|
7
|
+
import { createAgent as G, summarizationMiddleware as H, modelCallLimitMiddleware as J } from "langchain";
|
|
8
|
+
import { ChatOpenAI as Q, OpenAIEmbeddings as Y } from "@langchain/openai";
|
|
9
|
+
import q from "@arcgis/core/portal/Portal.js";
|
|
10
|
+
import Z from "@arcgis/core/identity/IdentityManager.js";
|
|
11
|
+
import { generateGuid as ee } from "@arcgis/toolkit/string";
|
|
12
|
+
import te from "@arcgis/core/config.js";
|
|
13
|
+
const F = {
|
|
12
14
|
advanced: "gpt-5.2",
|
|
13
15
|
default: "gpt-5-mini",
|
|
14
16
|
fast: "gpt-5.4-nano"
|
|
15
|
-
},
|
|
17
|
+
}, I = {
|
|
16
18
|
default: "text-embedding-ada-002"
|
|
17
|
-
},
|
|
18
|
-
let
|
|
19
|
-
const
|
|
20
|
-
const t =
|
|
19
|
+
}, T = /* @__PURE__ */ new Map();
|
|
20
|
+
let M = null;
|
|
21
|
+
const ne = () => {
|
|
22
|
+
const t = q.getDefault().helperServices;
|
|
21
23
|
if (!t?.aiModels?.url)
|
|
22
24
|
throw new Error("AI Models Service URL is not defined in the portal's helper services.");
|
|
23
25
|
return t.aiModels.url;
|
|
24
|
-
},
|
|
25
|
-
const t =
|
|
26
|
-
|
|
26
|
+
}, U = async (e) => {
|
|
27
|
+
const t = ne();
|
|
28
|
+
T.size === 0 && (M || (M = (async () => {
|
|
27
29
|
try {
|
|
28
30
|
const n = await fetch(`${t}/models`);
|
|
29
31
|
if (!n.ok)
|
|
30
32
|
throw new Error("Failed to fetch AI service discovery data.");
|
|
31
|
-
(await n.json()).models.forEach((
|
|
33
|
+
(await n.json()).models.forEach((o) => T.set(o.name, o));
|
|
32
34
|
} catch (n) {
|
|
33
|
-
throw
|
|
35
|
+
throw M = null, n;
|
|
34
36
|
}
|
|
35
|
-
})()), await
|
|
36
|
-
const s =
|
|
37
|
+
})()), await M);
|
|
38
|
+
const s = T.get(e);
|
|
37
39
|
if (!s)
|
|
38
40
|
throw new Error(`Model '${e}' is not available in the discovery service.`);
|
|
39
41
|
return s.endpoint;
|
|
40
|
-
},
|
|
42
|
+
}, se = async (e = "default") => await U(F[e]), ie = async (e = "default") => await U(I[e]), h = (e, t) => t, P = (e, t) => ({
|
|
41
43
|
...e,
|
|
42
44
|
...t
|
|
43
|
-
}),
|
|
45
|
+
}), _ = (e = "", t) => {
|
|
44
46
|
const s = typeof t == "string" ? t.trim() : "";
|
|
45
47
|
if (!s)
|
|
46
48
|
return e;
|
|
@@ -55,76 +57,72 @@ const ee = () => {
|
|
|
55
57
|
return i[i.length - 1]?.trim() === s ? e : `${e}
|
|
56
58
|
|
|
57
59
|
${s}`;
|
|
58
|
-
},
|
|
60
|
+
}, j = () => ({
|
|
59
61
|
userRequest: "",
|
|
60
62
|
assignedTask: "",
|
|
61
63
|
messages: [],
|
|
62
64
|
priorSteps: [],
|
|
63
65
|
sharedState: {}
|
|
64
|
-
}),
|
|
65
|
-
agentExecutionContext:
|
|
66
|
-
reducer:
|
|
67
|
-
default:
|
|
66
|
+
}), oe = () => ({
|
|
67
|
+
agentExecutionContext: m({
|
|
68
|
+
reducer: P,
|
|
69
|
+
default: j
|
|
68
70
|
}),
|
|
69
|
-
outputMessage:
|
|
70
|
-
reducer:
|
|
71
|
+
outputMessage: m({
|
|
72
|
+
reducer: _,
|
|
71
73
|
default: () => ""
|
|
72
74
|
}),
|
|
73
|
-
summary:
|
|
74
|
-
reducer:
|
|
75
|
+
summary: m({
|
|
76
|
+
reducer: h,
|
|
75
77
|
default: () => ""
|
|
76
78
|
}),
|
|
77
|
-
status:
|
|
78
|
-
reducer:
|
|
79
|
+
status: m({
|
|
80
|
+
reducer: h
|
|
79
81
|
})
|
|
80
|
-
}),
|
|
81
|
-
...
|
|
82
|
-
sharedStatePatch:
|
|
83
|
-
reducer:
|
|
82
|
+
}), $e = () => ({
|
|
83
|
+
...oe(),
|
|
84
|
+
sharedStatePatch: m({
|
|
85
|
+
reducer: h
|
|
84
86
|
})
|
|
85
|
-
}),
|
|
86
|
-
agentExecutionContext:
|
|
87
|
-
default:
|
|
88
|
-
reducer:
|
|
87
|
+
}), Ne = m.Root({
|
|
88
|
+
agentExecutionContext: m({
|
|
89
|
+
default: j,
|
|
90
|
+
reducer: P
|
|
89
91
|
}),
|
|
90
|
-
currentIntent:
|
|
92
|
+
currentIntent: m({
|
|
91
93
|
default: () => "none",
|
|
92
|
-
reducer:
|
|
94
|
+
reducer: h
|
|
93
95
|
}),
|
|
94
|
-
lastExecutedAgent:
|
|
96
|
+
lastExecutedAgent: m({
|
|
95
97
|
default: () => "",
|
|
96
|
-
reducer:
|
|
98
|
+
reducer: h
|
|
97
99
|
}),
|
|
98
|
-
requiresFollowUp:
|
|
100
|
+
requiresFollowUp: m({
|
|
99
101
|
default: () => !0,
|
|
100
|
-
reducer:
|
|
102
|
+
reducer: h
|
|
101
103
|
}),
|
|
102
|
-
stepCount:
|
|
104
|
+
stepCount: m({
|
|
103
105
|
default: () => 0,
|
|
104
106
|
reducer: (e, t) => t ?? e + 1
|
|
105
107
|
}),
|
|
106
|
-
finalOutputMessage:
|
|
108
|
+
finalOutputMessage: m({
|
|
107
109
|
default: () => "",
|
|
108
|
-
reducer:
|
|
110
|
+
reducer: _
|
|
109
111
|
})
|
|
110
|
-
}),
|
|
111
|
-
await U("trace_message", e, t);
|
|
112
|
-
}, Fe = async (e, t) => {
|
|
113
|
-
await U("graph_ux_suggestion", e, t);
|
|
114
|
-
}, ie = (e) => {
|
|
112
|
+
}), re = (e) => {
|
|
115
113
|
if (!e || typeof e != "object" || !("services" in e))
|
|
116
114
|
return !1;
|
|
117
115
|
const t = e.services;
|
|
118
116
|
return !!t && typeof t == "object" && "agentRegistry" in t;
|
|
119
|
-
},
|
|
117
|
+
}, ae = (e) => {
|
|
120
118
|
const t = e?.configurable;
|
|
121
|
-
return
|
|
122
|
-
},
|
|
119
|
+
return re(t) ? t : void 0;
|
|
120
|
+
}, ce = (e, t, s) => {
|
|
123
121
|
const n = e[t];
|
|
124
|
-
return n ? typeof n == "function" ? n() : Promise.resolve(n) : new Promise((i,
|
|
125
|
-
(typeof queueMicrotask == "function" ? queueMicrotask : setTimeout)(
|
|
122
|
+
return n ? typeof n == "function" ? n() : Promise.resolve(n) : new Promise((i, o) => {
|
|
123
|
+
(typeof queueMicrotask == "function" ? queueMicrotask : setTimeout)(o.bind(null, /* @__PURE__ */ new Error("Unknown variable dynamic import: " + t + (t.split("/").length !== s ? ". Note that variables only represent file names one level deep." : ""))));
|
|
126
124
|
});
|
|
127
|
-
},
|
|
125
|
+
}, k = async (e) => (await ce(/* @__PURE__ */ Object.assign({ "./field_descriptions_prompt.md": () => import("./field_descriptions_prompt.js"), "./intent_prompt.md": () => import("./intent_prompt.js"), "./layer_descriptions_prompt.md": () => import("./layer_descriptions_prompt.js") }), `./${e}.md`, 2)).default, le = async (e) => {
|
|
128
126
|
const { agent: t, messages: s, config: n } = e;
|
|
129
127
|
return { structuredResponse: (await t.invoke(
|
|
130
128
|
{
|
|
@@ -132,117 +130,141 @@ ${s}`;
|
|
|
132
130
|
},
|
|
133
131
|
n
|
|
134
132
|
)).structuredResponse };
|
|
135
|
-
},
|
|
136
|
-
const
|
|
137
|
-
|
|
138
|
-
|
|
139
|
-
|
|
140
|
-
|
|
141
|
-
|
|
142
|
-
|
|
143
|
-
|
|
144
|
-
|
|
145
|
-
|
|
146
|
-
|
|
147
|
-
|
|
133
|
+
}, de = (e) => typeof e == "string" && e.length > 0 ? e : void 0, pe = () => ee(), me = (e) => typeof e != "string" || e.trim().length === 0 ? "MapsSDK" : `MapsSDK - ${e.trim()}`, ue = (e) => {
|
|
134
|
+
const t = e?.configurable;
|
|
135
|
+
return {
|
|
136
|
+
conversationId: de(t?.thread_id),
|
|
137
|
+
abortSignal: e?.signal,
|
|
138
|
+
requestId: pe(),
|
|
139
|
+
requestSource: me(te.applicationName)
|
|
140
|
+
};
|
|
141
|
+
}, $ = async ({ config: e }) => {
|
|
142
|
+
const t = q.getDefault(), n = (await Z.getCredential(`${t.url}/sharing`))?.token;
|
|
143
|
+
return async (i, o) => {
|
|
144
|
+
const { conversationId: a, abortSignal: c, requestId: l, requestSource: p } = ue(e), d = new Headers(o?.headers);
|
|
145
|
+
d.delete("Authorization"), d.delete("api-key"), n && n.length > 0 && (d.set("X-Esri-Authorization", `Bearer ${n}`), d.set("X-Esri-Request-Source", p)), a && a.length > 0 && d.set("X-Esri-Conversation-Id", a), l.length > 0 && d.set("X-Esri-Request-Id", l);
|
|
146
|
+
const y = c && o?.signal ? AbortSignal.any([c, o.signal]) : o?.signal ?? c;
|
|
147
|
+
return await fetch(i, {
|
|
148
|
+
...o,
|
|
149
|
+
headers: d,
|
|
150
|
+
signal: y
|
|
151
|
+
});
|
|
152
|
+
};
|
|
153
|
+
}, v = async (e = {}) => {
|
|
154
|
+
const { modelTier: t = "default", temperature: s = 0, config: n } = e, i = F[t], o = await se(t);
|
|
155
|
+
return new Q({
|
|
156
|
+
modelName: i,
|
|
148
157
|
apiKey: "dummy-key",
|
|
149
158
|
// 5-mini does not support temperature parameter
|
|
150
159
|
...t !== "default" && { temperature: s },
|
|
151
160
|
configuration: {
|
|
152
|
-
baseURL:
|
|
153
|
-
fetch:
|
|
161
|
+
baseURL: o,
|
|
162
|
+
fetch: await $({ config: n })
|
|
154
163
|
}
|
|
155
164
|
});
|
|
156
|
-
},
|
|
157
|
-
const
|
|
158
|
-
return new
|
|
159
|
-
modelName:
|
|
165
|
+
}, Oe = async (e = {}) => {
|
|
166
|
+
const { tier: t = "default", config: s } = e, n = I[t], i = await ie(t);
|
|
167
|
+
return new Y({
|
|
168
|
+
modelName: n,
|
|
160
169
|
apiKey: "dummy-key",
|
|
161
170
|
configuration: {
|
|
162
|
-
baseURL:
|
|
163
|
-
fetch:
|
|
171
|
+
baseURL: i,
|
|
172
|
+
fetch: await $({ config: s })
|
|
164
173
|
},
|
|
165
174
|
batchSize: 2048,
|
|
166
175
|
maxConcurrency: 10
|
|
167
176
|
});
|
|
168
|
-
},
|
|
169
|
-
id:
|
|
170
|
-
name:
|
|
171
|
-
description:
|
|
177
|
+
}, ge = r.object({
|
|
178
|
+
id: r.string().min(1),
|
|
179
|
+
name: r.string().min(1),
|
|
180
|
+
description: r.string().min(1)
|
|
172
181
|
});
|
|
173
|
-
|
|
174
|
-
const R = (e) => JSON.stringify(e, null, 2),
|
|
175
|
-
const t = e.map((n) => n.id), s =
|
|
176
|
-
return
|
|
182
|
+
r.array(ge);
|
|
183
|
+
const R = (e) => JSON.stringify(e, null, 2), fe = (e) => {
|
|
184
|
+
const t = e.map((n) => n.id), s = r.enum(t);
|
|
185
|
+
return r.object({
|
|
177
186
|
intent: s.nullable(),
|
|
178
|
-
assignedTask:
|
|
179
|
-
requiresFollowUp:
|
|
187
|
+
assignedTask: r.string().nullable(),
|
|
188
|
+
requiresFollowUp: r.boolean()
|
|
180
189
|
});
|
|
181
|
-
},
|
|
182
|
-
const s =
|
|
183
|
-
if (
|
|
184
|
-
return await
|
|
190
|
+
}, Ve = async (e, t) => {
|
|
191
|
+
const s = ae(t);
|
|
192
|
+
if (t?.signal?.aborted)
|
|
193
|
+
return await f({ text: "Run cancelled; skipping intent routing" }, t), {
|
|
185
194
|
...e,
|
|
186
195
|
currentIntent: "none",
|
|
196
|
+
finalOutputMessage: "Operation cancelled.",
|
|
187
197
|
requiresFollowUp: !1
|
|
188
198
|
};
|
|
189
199
|
try {
|
|
190
|
-
await
|
|
191
|
-
const
|
|
192
|
-
id:
|
|
193
|
-
name:
|
|
194
|
-
description:
|
|
200
|
+
await f({ text: "Asking LLM to route to an agent" }, t);
|
|
201
|
+
const i = s.services.agentRegistry?.list() ?? [], o = i.map(({ agent: g }) => ({
|
|
202
|
+
id: g.id,
|
|
203
|
+
name: g.name,
|
|
204
|
+
description: g.description
|
|
195
205
|
}));
|
|
196
|
-
if (!
|
|
197
|
-
return await
|
|
198
|
-
|
|
206
|
+
if (!o.length)
|
|
207
|
+
return await f({ text: "No agents registered; skipping intent detection" }, t), {
|
|
208
|
+
...e,
|
|
209
|
+
currentIntent: "none",
|
|
210
|
+
finalOutputMessage: "No agents registered; skipping intent detection."
|
|
211
|
+
};
|
|
212
|
+
const a = await k("intent_prompt"), c = R(o), l = fe(o), p = {
|
|
199
213
|
registeredAgents: c,
|
|
200
214
|
priorSteps: R(e.agentExecutionContext.priorSteps),
|
|
201
215
|
userRequest: e.agentExecutionContext.userRequest
|
|
202
|
-
},
|
|
203
|
-
model: await
|
|
216
|
+
}, y = await D.fromTemplate(a).format(p), E = G({
|
|
217
|
+
model: await v({
|
|
218
|
+
modelTier: "fast",
|
|
219
|
+
config: t
|
|
220
|
+
}),
|
|
204
221
|
tools: [],
|
|
205
|
-
systemPrompt:
|
|
206
|
-
checkpointer: !0,
|
|
222
|
+
systemPrompt: y,
|
|
207
223
|
responseFormat: l,
|
|
208
224
|
middleware: [
|
|
209
225
|
// Preserve recent conversation context while summarizing older messages
|
|
210
226
|
// to control token usage without losing important intent signals.
|
|
211
227
|
// The trigger and keep parameters can be tuned based on token limits and behavior.
|
|
212
|
-
|
|
213
|
-
model: await
|
|
228
|
+
H({
|
|
229
|
+
model: await v({
|
|
230
|
+
modelTier: "fast",
|
|
231
|
+
config: t
|
|
232
|
+
}),
|
|
214
233
|
trigger: { tokens: 4e3 },
|
|
215
234
|
keep: { messages: 6 }
|
|
216
235
|
}),
|
|
217
236
|
// Enforce no loop/retry.
|
|
218
237
|
// 1 usual LLM call and 1 optional summarization call.
|
|
219
|
-
|
|
238
|
+
J({ runLimit: 2 })
|
|
220
239
|
]
|
|
221
|
-
}), { structuredResponse:
|
|
222
|
-
agent:
|
|
240
|
+
}), { structuredResponse: V } = await le({
|
|
241
|
+
agent: E,
|
|
223
242
|
messages: e.agentExecutionContext.messages,
|
|
224
243
|
config: t
|
|
225
|
-
}),
|
|
226
|
-
|
|
227
|
-
), x =
|
|
244
|
+
}), w = l.parse(
|
|
245
|
+
V ?? { intent: null, assignedTask: null, requiresFollowUp: !1 }
|
|
246
|
+
), x = w.intent ?? "none", z = {
|
|
228
247
|
...e,
|
|
229
248
|
currentIntent: x,
|
|
230
|
-
requiresFollowUp:
|
|
249
|
+
requiresFollowUp: w.requiresFollowUp,
|
|
231
250
|
agentExecutionContext: {
|
|
232
251
|
...e.agentExecutionContext,
|
|
233
|
-
assignedTask:
|
|
252
|
+
assignedTask: w.assignedTask ?? ""
|
|
234
253
|
}
|
|
235
254
|
};
|
|
236
255
|
if (x === "none") {
|
|
237
|
-
const
|
|
238
|
-
|
|
256
|
+
const g = `I could not find an agent that can handle that request. I have access to the following agents: ${i.map(({ agent: L }) => L.name).join(", ")}.
|
|
257
|
+
|
|
258
|
+
Please ask a question that can be answered by one of these agents.`;
|
|
259
|
+
return await f({ text: "LLM did not identify a clear intent." }, t), {
|
|
239
260
|
...e,
|
|
240
261
|
currentIntent: x,
|
|
241
262
|
requiresFollowUp: !1,
|
|
263
|
+
finalOutputMessage: g,
|
|
242
264
|
agentExecutionContext: {
|
|
243
265
|
...e.agentExecutionContext,
|
|
244
266
|
assignedTask: "",
|
|
245
|
-
messages: [...e.agentExecutionContext.messages, new
|
|
267
|
+
messages: [...e.agentExecutionContext.messages, new B(g)],
|
|
246
268
|
priorSteps: [
|
|
247
269
|
...e.agentExecutionContext.priorSteps ?? [],
|
|
248
270
|
{
|
|
@@ -255,112 +277,112 @@ const R = (e) => JSON.stringify(e, null, 2), le = (e) => {
|
|
|
255
277
|
}
|
|
256
278
|
};
|
|
257
279
|
}
|
|
258
|
-
return await
|
|
280
|
+
return await f(
|
|
259
281
|
{
|
|
260
282
|
text: `Agent picked: ${x}
|
|
261
|
-
Task Assigned: ${
|
|
262
|
-
Requires Follow-Up: ${
|
|
283
|
+
Task Assigned: ${w.assignedTask ?? ""}
|
|
284
|
+
Requires Follow-Up: ${w.requiresFollowUp}`
|
|
263
285
|
},
|
|
264
286
|
t
|
|
265
|
-
),
|
|
287
|
+
), z;
|
|
266
288
|
} catch (n) {
|
|
267
|
-
throw await
|
|
289
|
+
throw await f({ text: "Error during intent detection" }, t), new Error(`Error during intent detection: ${n instanceof Error ? n.message : String(n)}`);
|
|
268
290
|
}
|
|
269
|
-
},
|
|
291
|
+
}, he = "0.1", b = 1536, ye = "openai", we = I.default, be = `Name: {name}
|
|
270
292
|
Title: {title}
|
|
271
|
-
Description: {description}`,
|
|
293
|
+
Description: {description}`, ve = `Name: {name}
|
|
272
294
|
Alias: {alias}
|
|
273
|
-
Description: {description}`,
|
|
274
|
-
schemaVersion:
|
|
275
|
-
modified:
|
|
276
|
-
embeddings:
|
|
277
|
-
modelProvider:
|
|
278
|
-
model:
|
|
279
|
-
dimensions:
|
|
280
|
-
templates:
|
|
281
|
-
layer:
|
|
282
|
-
field:
|
|
295
|
+
Description: {description}`, ze = r.object({
|
|
296
|
+
schemaVersion: r.literal(he),
|
|
297
|
+
modified: r.number().int().nonnegative(),
|
|
298
|
+
embeddings: r.object({
|
|
299
|
+
modelProvider: r.literal(ye),
|
|
300
|
+
model: r.literal(we),
|
|
301
|
+
dimensions: r.literal(b),
|
|
302
|
+
templates: r.object({
|
|
303
|
+
layer: r.string().default(be),
|
|
304
|
+
field: r.string().default(ve)
|
|
283
305
|
})
|
|
284
306
|
}),
|
|
285
|
-
layers:
|
|
286
|
-
|
|
287
|
-
id:
|
|
288
|
-
name:
|
|
289
|
-
title:
|
|
290
|
-
description:
|
|
291
|
-
vector:
|
|
292
|
-
message: `Layer vector must be exactly ${
|
|
307
|
+
layers: r.array(
|
|
308
|
+
r.object({
|
|
309
|
+
id: r.string().min(1),
|
|
310
|
+
name: r.string().min(1),
|
|
311
|
+
title: r.string().catch(""),
|
|
312
|
+
description: r.string().catch(""),
|
|
313
|
+
vector: r.array(r.number()).length(b, {
|
|
314
|
+
message: `Layer vector must be exactly ${b} dimensions`
|
|
293
315
|
}),
|
|
294
|
-
fields:
|
|
295
|
-
|
|
296
|
-
name:
|
|
297
|
-
alias:
|
|
298
|
-
description:
|
|
299
|
-
vector:
|
|
300
|
-
message: `Field vector must be exactly ${
|
|
316
|
+
fields: r.array(
|
|
317
|
+
r.object({
|
|
318
|
+
name: r.string().min(1),
|
|
319
|
+
alias: r.string().catch(""),
|
|
320
|
+
description: r.string().catch(""),
|
|
321
|
+
vector: r.array(r.number()).length(b, {
|
|
322
|
+
message: `Field vector must be exactly ${b} dimensions`
|
|
301
323
|
})
|
|
302
324
|
})
|
|
303
325
|
)
|
|
304
326
|
})
|
|
305
327
|
).default([])
|
|
306
|
-
}),
|
|
328
|
+
}), xe = (e) => {
|
|
307
329
|
const t = /* @__PURE__ */ new Set();
|
|
308
330
|
for (const n of e)
|
|
309
|
-
if (
|
|
331
|
+
if (W(n)) {
|
|
310
332
|
const i = n;
|
|
311
|
-
i.tool_calls && i.tool_calls.length > 0 && i.tool_calls.forEach((
|
|
312
|
-
|
|
333
|
+
i.tool_calls && i.tool_calls.length > 0 && i.tool_calls.forEach((o) => {
|
|
334
|
+
o.id && t.add(o.id);
|
|
313
335
|
});
|
|
314
336
|
}
|
|
315
337
|
return e.filter((n) => {
|
|
316
|
-
if (
|
|
338
|
+
if (X(n)) {
|
|
317
339
|
const i = n;
|
|
318
340
|
return t.has(i.tool_call_id);
|
|
319
341
|
}
|
|
320
342
|
return !0;
|
|
321
343
|
});
|
|
322
|
-
},
|
|
323
|
-
const s =
|
|
324
|
-
return
|
|
325
|
-
},
|
|
326
|
-
const { promptText: t, modelTier: s, temperature: n, messages: i,
|
|
344
|
+
}, A = (e, t) => {
|
|
345
|
+
const s = K.fromTemplate(e);
|
|
346
|
+
return D.fromMessages([s, ...t]);
|
|
347
|
+
}, Me = async (e) => {
|
|
348
|
+
const { promptText: t, modelTier: s, temperature: n, messages: i, config: o } = e, a = A(t, i ?? []), c = await v({ modelTier: s, temperature: n, config: o });
|
|
327
349
|
return a.pipe(c);
|
|
328
|
-
},
|
|
329
|
-
const { promptText: t, modelTier: s = "default", temperature: n = 0, messages: i, inputVariables:
|
|
350
|
+
}, Le = async (e) => {
|
|
351
|
+
const { promptText: t, modelTier: s = "default", temperature: n = 0, messages: i, inputVariables: o, config: a } = e, l = await (await Me({
|
|
330
352
|
promptText: t,
|
|
331
353
|
modelTier: s,
|
|
332
354
|
temperature: n,
|
|
333
355
|
messages: i,
|
|
334
|
-
|
|
335
|
-
})).invoke(
|
|
356
|
+
config: a
|
|
357
|
+
})).invoke(o ?? {}, a);
|
|
336
358
|
if (typeof l == "string")
|
|
337
359
|
return l;
|
|
338
|
-
const
|
|
339
|
-
return typeof
|
|
340
|
-
},
|
|
341
|
-
const { promptText: t, modelTier: s = "default", temperature: n = 0, messages: i, inputVariables:
|
|
342
|
-
return await l.pipe(
|
|
343
|
-
},
|
|
344
|
-
const { promptText: t, modelTier: s = "default", temperature: n = 0, messages: i, inputVariables:
|
|
345
|
-
return await
|
|
346
|
-
},
|
|
347
|
-
name:
|
|
348
|
-
description:
|
|
349
|
-
valueType:
|
|
350
|
-
alias:
|
|
351
|
-
}),
|
|
352
|
-
fields:
|
|
353
|
-
}),
|
|
354
|
-
const s =
|
|
360
|
+
const p = l.content;
|
|
361
|
+
return typeof p == "string" ? p : JSON.stringify(p);
|
|
362
|
+
}, N = async (e) => {
|
|
363
|
+
const { promptText: t, modelTier: s = "default", temperature: n = 0, messages: i, inputVariables: o, schema: a, config: c } = e, l = A(t, i ?? []), d = (await v({ modelTier: s, temperature: n, config: c })).withStructuredOutput(a);
|
|
364
|
+
return await l.pipe(d).invoke(o ?? {}, c);
|
|
365
|
+
}, Ke = async (e) => {
|
|
366
|
+
const { promptText: t, modelTier: s = "default", temperature: n = 0, messages: i, inputVariables: o, tools: a, config: c } = e, l = a.length > 0 ? xe(i ?? []) : i ?? [], p = A(t, l), d = await v({ modelTier: s, temperature: n, config: c });
|
|
367
|
+
return await p.pipe(d.bindTools(a)).invoke(o ?? {}, c);
|
|
368
|
+
}, Te = u.object({
|
|
369
|
+
name: u.string(),
|
|
370
|
+
description: u.string(),
|
|
371
|
+
valueType: u.string(),
|
|
372
|
+
alias: u.string()
|
|
373
|
+
}), Se = u.object({
|
|
374
|
+
fields: u.array(Te)
|
|
375
|
+
}), O = (e, t) => e.getFieldAlias(t) ?? void 0, S = (e, t) => O(e, t.name) ?? t.alias ?? "", Ie = (e, t) => {
|
|
376
|
+
const s = O(e, t.name);
|
|
355
377
|
return !!(s && s !== (t.alias ?? ""));
|
|
356
378
|
};
|
|
357
|
-
function
|
|
379
|
+
function C(e, t) {
|
|
358
380
|
const s = /* @__PURE__ */ new Map();
|
|
359
381
|
for (const n of e.fields) {
|
|
360
|
-
const i = t.fields.find((l) => l.name === n.name),
|
|
382
|
+
const i = t.fields.find((l) => l.name === n.name), o = S(e, n), a = Ie(e, n), c = {
|
|
361
383
|
name: n.name,
|
|
362
384
|
type: n.type,
|
|
363
|
-
alias: a ?
|
|
385
|
+
alias: a ? o : i?.alias ?? o,
|
|
364
386
|
description: i?.description ?? n.description ?? "",
|
|
365
387
|
valueType: i?.valueType ?? n.valueType ?? "",
|
|
366
388
|
domain: e.getFieldDomain(n.name) ?? void 0
|
|
@@ -369,65 +391,63 @@ function D(e, t) {
|
|
|
369
391
|
}
|
|
370
392
|
return s;
|
|
371
393
|
}
|
|
372
|
-
const
|
|
373
|
-
const s = await
|
|
374
|
-
const { name: c, type: l, description:
|
|
375
|
-
return [`Name: ${c}`, `Type: ${l}`, `Alias: ${
|
|
394
|
+
const Be = async (e) => {
|
|
395
|
+
const s = await k("field_descriptions_prompt"), n = e.fields.filter((a) => !(S(e, a) && a.description)).map((a) => {
|
|
396
|
+
const { name: c, type: l, description: p } = a, d = S(e, a);
|
|
397
|
+
return [`Name: ${c}`, `Type: ${l}`, `Alias: ${d}`, `Description: ${p ?? "N/A"}`].join(", ");
|
|
376
398
|
}).join(`
|
|
377
399
|
`);
|
|
378
400
|
if (n.length === 0)
|
|
379
|
-
return
|
|
401
|
+
return C(e, { fields: [] });
|
|
380
402
|
const i = {
|
|
381
403
|
existingItemTitle: e.portalItem?.title,
|
|
382
404
|
existingItemDescription: e.portalItem?.description,
|
|
383
405
|
existingLayerTitle: e.title,
|
|
384
406
|
existingLayerDescription: e.portalItem?.description,
|
|
385
407
|
fieldInformation: n
|
|
386
|
-
},
|
|
408
|
+
}, o = await N({
|
|
387
409
|
promptText: s,
|
|
388
|
-
schema:
|
|
410
|
+
schema: Se,
|
|
389
411
|
inputVariables: i
|
|
390
412
|
});
|
|
391
|
-
return
|
|
392
|
-
},
|
|
393
|
-
title:
|
|
394
|
-
description:
|
|
395
|
-
name:
|
|
396
|
-
}),
|
|
397
|
-
const n = await
|
|
413
|
+
return C(e, o);
|
|
414
|
+
}, ke = u.object({
|
|
415
|
+
title: u.string(),
|
|
416
|
+
description: u.string(),
|
|
417
|
+
name: u.string().nullable()
|
|
418
|
+
}), We = async (e, t) => {
|
|
419
|
+
const n = await k("layer_descriptions_prompt"), i = Array.from(t.values()), o = {
|
|
398
420
|
fieldInformation: JSON.stringify(i, null, 2),
|
|
399
421
|
existingLayerTitle: e.title,
|
|
400
422
|
existingLayerDescription: e.portalItem?.description,
|
|
401
423
|
existingLayerSnippet: e.portalItem?.snippet,
|
|
402
424
|
layerGeometryType: e.geometryType
|
|
403
425
|
};
|
|
404
|
-
return { ...await
|
|
426
|
+
return { ...await N({
|
|
405
427
|
promptText: n,
|
|
406
|
-
schema:
|
|
407
|
-
inputVariables:
|
|
428
|
+
schema: ke,
|
|
429
|
+
inputVariables: o
|
|
408
430
|
}), name: e.title ?? null };
|
|
409
431
|
};
|
|
410
432
|
export {
|
|
411
|
-
|
|
412
|
-
|
|
413
|
-
|
|
414
|
-
|
|
415
|
-
|
|
416
|
-
|
|
417
|
-
|
|
418
|
-
|
|
419
|
-
|
|
420
|
-
|
|
421
|
-
|
|
422
|
-
|
|
423
|
-
|
|
424
|
-
|
|
425
|
-
|
|
426
|
-
|
|
427
|
-
|
|
428
|
-
|
|
429
|
-
|
|
430
|
-
|
|
431
|
-
g as s,
|
|
432
|
-
Ue as t
|
|
433
|
+
Ne as D,
|
|
434
|
+
ze as W,
|
|
435
|
+
We as a,
|
|
436
|
+
ye as b,
|
|
437
|
+
v as c,
|
|
438
|
+
b as d,
|
|
439
|
+
Le as e,
|
|
440
|
+
ve as f,
|
|
441
|
+
Be as g,
|
|
442
|
+
Ke as h,
|
|
443
|
+
N as i,
|
|
444
|
+
oe as j,
|
|
445
|
+
$e as k,
|
|
446
|
+
be as l,
|
|
447
|
+
we as m,
|
|
448
|
+
ie as n,
|
|
449
|
+
ae as o,
|
|
450
|
+
Ve as p,
|
|
451
|
+
Oe as q,
|
|
452
|
+
he as s
|
|
433
453
|
};
|