@arcgis/ai-components 5.2.0-next.7 → 5.2.0-next.70
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/README.md +2 -2
- package/dist/agent-utils/FunctionAgent.d.ts +2 -2
- package/dist/agent-utils/LLMAgent.d.ts +2 -2
- package/dist/agent-utils/LLMAgent.js +2 -1
- 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/{H7422XUG.js → 2GH3K5JP.js} +1 -1
- package/dist/cdn/2Y4DTOGT.js +2 -0
- package/dist/cdn/3DJDRAGV.js +2 -0
- package/dist/cdn/3S5G5SIX.js +2 -0
- package/dist/cdn/{AMP6IALT.js → 3UEKINYC.js} +1 -1
- package/dist/cdn/3ZPPYCNL.js +2 -0
- package/dist/cdn/434TAA3J.js +2 -0
- package/dist/cdn/4CEMUECT.js +2 -0
- package/dist/cdn/4PCAK3ET.js +2 -0
- package/dist/cdn/57OMVTIU.js +2 -0
- package/dist/cdn/5TI2F5XX.js +2 -0
- package/dist/cdn/6TA5KFAQ.js +4 -0
- package/dist/cdn/6U7TEAAJ.js +2 -0
- package/dist/cdn/{ZS2TZ6BF.js → AOVJ34QE.js} +1 -1
- package/dist/cdn/APFZY4PI.js +2 -0
- package/dist/cdn/B6CJG5UH.js +66 -0
- package/dist/cdn/BE7ZN5FZ.js +2 -0
- package/dist/cdn/{FL4W4VYN.js → BL273EGZ.js} +17 -1
- package/dist/cdn/BNSJO6X2.js +2 -0
- package/dist/cdn/{5ZZGKP7N.js → CEKOEHB3.js} +1 -1
- package/dist/cdn/CMDRED5H.js +2 -0
- package/dist/cdn/CXW5URTF.js +14 -0
- package/dist/cdn/DCSZPL7R.js +2 -0
- package/dist/cdn/DTIVDIDY.js +2 -0
- package/dist/cdn/DUSILSNJ.js +9 -0
- package/dist/cdn/E5ZKBC24.js +36 -0
- package/dist/cdn/FSGIG7UN.js +2 -0
- package/dist/cdn/{ZLXN7NMF.js → FYZATVB3.js} +10 -8
- package/dist/cdn/GLBE7OW2.js +2 -0
- package/dist/cdn/GP6NDTUE.js +18 -0
- 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/KKLAQF3Z.js +2 -0
- package/dist/cdn/KLYNL2ZT.js +2 -0
- package/dist/cdn/KQHLOYKL.js +3 -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/{VOQX4AVB.js → MW5S2XCB.js} +6 -4
- package/dist/cdn/MWYBF3F3.js +66 -0
- package/dist/cdn/NEV6OZN3.js +71 -0
- package/dist/cdn/OKMZQXBQ.js +2 -0
- package/dist/cdn/OKTBWKNG.js +2 -0
- package/dist/cdn/{23EQTPO3.js → OKVLGJAG.js} +1 -1
- package/dist/cdn/OWXCOUIQ.js +2 -0
- package/dist/cdn/OYNIFMCJ.js +2 -0
- package/dist/cdn/{LQ6R5YRN.js → PQ2DPOFM.js} +1 -1
- package/dist/cdn/PUFTYLJ2.js +22 -0
- 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/ST5FQYT7.js +180 -0
- package/dist/cdn/SXHH575T.js +48 -0
- package/dist/cdn/T4ECSHM7.js +2 -0
- package/dist/cdn/TFT6HK3O.js +208 -0
- package/dist/cdn/TPULIO6I.js +34 -0
- package/dist/cdn/U3XIDLHO.js +3 -0
- package/dist/cdn/{6YMR4QSD.js → UHEYPSOR.js} +1 -1
- package/dist/cdn/UZLQALHY.js +2 -0
- package/dist/cdn/V6HOUZPZ.js +2 -0
- package/dist/cdn/VAXH6RUQ.js +134 -0
- package/dist/cdn/VXFQANGJ.js +2 -0
- package/dist/cdn/WQGJATNJ.js +2 -0
- package/dist/cdn/WSHWQDO2.js +2 -0
- package/dist/cdn/WUNCZOGU.js +2 -0
- package/dist/cdn/WVPU4QOO.js +2 -0
- package/dist/cdn/WXWO5D3W.js +2 -0
- package/dist/cdn/XCRR2EEG.js +6 -0
- package/dist/cdn/XETNZW4D.js +3 -0
- package/dist/cdn/XRE5USHA.js +2 -0
- package/dist/cdn/YHQJ66WJ.js +2 -0
- package/dist/cdn/ZCEMEUP7.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/chunks/adapter.js +1795 -1598
- package/dist/chunks/arcgisKnowledgeGraph.js +127 -72
- 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 +140 -114
- package/dist/chunks/data_explore_query_prompt.js +9 -4
- package/dist/chunks/generateLayerDescriptions.js +265 -240
- package/dist/chunks/helpGraph.js +30 -23
- 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 +25 -21
- package/dist/chunks/navigationGraph.js +79 -70
- package/dist/chunks/navigation_intent_prompt.js +8 -2
- package/dist/chunks/orchestrator.js +205 -175
- 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 +13 -10
- package/dist/chunks/utils2.js +8 -8
- package/dist/components/arcgis-assistant/customElement.d.ts +27 -0
- package/dist/components/arcgis-assistant/customElement.js +386 -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 +2 -1
- package/dist/components/arcgis-assistant-chat/customElement.js +23 -18
- package/dist/components/arcgis-assistant-chat-entry/customElement.d.ts +2 -0
- package/dist/components/arcgis-assistant-chat-entry/customElement.js +25 -18
- package/dist/components/arcgis-assistant-data-exploration-agent/customElement.js +12 -6
- package/dist/components/arcgis-assistant-help-agent/customElement.js +9 -3
- 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 +18 -12
- package/dist/components/arcgis-assistant-layer-styling-agent/customElement.js +11 -5
- package/dist/components/arcgis-assistant-message/customElement.d.ts +2 -0
- package/dist/components/arcgis-assistant-message/customElement.js +28 -26
- package/dist/components/arcgis-assistant-message/index.js +2 -0
- 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-loading/customElement.d.ts +4 -0
- package/dist/components/arcgis-assistant-message-loading/customElement.js +10 -10
- package/dist/components/arcgis-assistant-message-loading/index.js +1 -0
- package/dist/components/arcgis-assistant-message-text/customElement.d.ts +1 -0
- package/dist/components/arcgis-assistant-message-text/customElement.js +12 -12
- package/dist/components/arcgis-assistant-navigation-agent/customElement.js +12 -6
- package/dist/components/arcgis-assistant-speech-input/customElement.js +29 -46
- package/dist/components/arcgis-assistant-suggested-prompts/customElement.js +8 -8
- 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/loader.js +7 -6
- package/dist/oauth-callback.html +1 -1
- package/dist/types/lumina.d.ts +7 -6
- package/dist/types/preact.d.ts +7 -6
- package/dist/types/react.d.ts +7 -6
- package/dist/types/stencil.d.ts +7 -6
- package/dist/utils/index.d.ts +95 -47
- package/dist/utils/index.js +80 -65
- package/package.json +12 -11
- package/dist/cdn/2AXF774U.js +0 -2
- package/dist/cdn/3NI46YCE.js +0 -2
- package/dist/cdn/3PKJWIC3.js +0 -2
- package/dist/cdn/462JBSEV.js +0 -422
- package/dist/cdn/47FWPQ2A.js +0 -16
- 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/AEJHYRGT.js +0 -166
- package/dist/cdn/AO7BQHKC.js +0 -2
- package/dist/cdn/AXDZBBNL.js +0 -45
- package/dist/cdn/BFZJNJL6.js +0 -22
- package/dist/cdn/DDLZOMUY.js +0 -2
- package/dist/cdn/DHOVCT6R.js +0 -2
- package/dist/cdn/F2AHA4GB.js +0 -54
- package/dist/cdn/FX5JFRDL.js +0 -2
- package/dist/cdn/GCQLVNNC.js +0 -14
- package/dist/cdn/HB5A5R2E.js +0 -2
- package/dist/cdn/JV4SI65E.js +0 -108
- package/dist/cdn/KMQ3SP4I.js +0 -5
- 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/R6HV42YW.js +0 -3
- 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/V7OJRG26.js +0 -36
- package/dist/cdn/Y333DGV6.js +0 -2
- package/dist/cdn/YIMNOUTF.js +0 -2
|
@@ -1,43 +1,43 @@
|
|
|
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 G, summarizationMiddleware as
|
|
8
|
-
import { ChatOpenAI as
|
|
9
|
-
import
|
|
10
|
-
import
|
|
2
|
+
import { Annotation as m } from "@langchain/langgraph/web";
|
|
3
|
+
import u, { z as i } from "zod";
|
|
4
|
+
import { ChatPromptTemplate as D, SystemMessagePromptTemplate as B } from "@langchain/core/prompts";
|
|
5
|
+
import { s as y } from "./index.js";
|
|
6
|
+
import { AIMessage as W, isAIMessage as H, isToolMessage as X } from "@langchain/core/messages";
|
|
7
|
+
import { createAgent as G, summarizationMiddleware as J, modelCallLimitMiddleware as Q } from "langchain";
|
|
8
|
+
import { ChatOpenAI as Y, OpenAIEmbeddings as Z } from "@langchain/openai";
|
|
9
|
+
import F from "@arcgis/core/portal/Portal.js";
|
|
10
|
+
import U from "@arcgis/core/request.js";
|
|
11
|
+
import ee from "@arcgis/core/identity/IdentityManager.js";
|
|
12
|
+
import { generateGuid as te } from "@arcgis/toolkit/string";
|
|
13
|
+
import ne from "@arcgis/core/config.js";
|
|
11
14
|
const P = {
|
|
12
15
|
advanced: "gpt-5.2",
|
|
13
16
|
default: "gpt-5-mini",
|
|
14
17
|
fast: "gpt-5.4-nano"
|
|
15
|
-
},
|
|
18
|
+
}, E = {
|
|
16
19
|
default: "text-embedding-ada-002"
|
|
17
|
-
},
|
|
18
|
-
let
|
|
19
|
-
const
|
|
20
|
-
const t =
|
|
20
|
+
}, k = /* @__PURE__ */ new Map();
|
|
21
|
+
let M = null;
|
|
22
|
+
const se = () => {
|
|
23
|
+
const t = F.getDefault().helperServices;
|
|
21
24
|
if (!t?.aiModels?.url)
|
|
22
25
|
throw new Error("AI Models Service URL is not defined in the portal's helper services.");
|
|
23
26
|
return t.aiModels.url;
|
|
24
|
-
},
|
|
25
|
-
const t =
|
|
26
|
-
|
|
27
|
+
}, _ = async (e) => {
|
|
28
|
+
const t = se();
|
|
29
|
+
k.size === 0 && (M || (M = (async () => {
|
|
27
30
|
try {
|
|
28
|
-
|
|
29
|
-
if (!n.ok)
|
|
30
|
-
throw new Error("Failed to fetch AI service discovery data.");
|
|
31
|
-
(await n.json()).models.forEach((i) => M.set(i.name, i));
|
|
31
|
+
(await U(`${t}/models`)).data.models.forEach((o) => k.set(o.name, o));
|
|
32
32
|
} catch (n) {
|
|
33
|
-
throw
|
|
33
|
+
throw M = null, n;
|
|
34
34
|
}
|
|
35
|
-
})()), await
|
|
36
|
-
const s =
|
|
35
|
+
})()), await M);
|
|
36
|
+
const s = k.get(e);
|
|
37
37
|
if (!s)
|
|
38
38
|
throw new Error(`Model '${e}' is not available in the discovery service.`);
|
|
39
39
|
return s.endpoint;
|
|
40
|
-
},
|
|
40
|
+
}, re = async (e = "default") => await _(P[e]), oe = async (e = "default") => await _(E[e]), f = (e, t) => t, j = (e, t) => ({
|
|
41
41
|
...e,
|
|
42
42
|
...t
|
|
43
43
|
}), $ = (e = "", t) => {
|
|
@@ -49,82 +49,82 @@ const te = () => {
|
|
|
49
49
|
return s;
|
|
50
50
|
if (n === s)
|
|
51
51
|
return e;
|
|
52
|
-
const
|
|
52
|
+
const r = n.split(`
|
|
53
53
|
|
|
54
54
|
`);
|
|
55
|
-
return
|
|
55
|
+
return r[r.length - 1]?.trim() === s ? e : `${e}
|
|
56
56
|
|
|
57
57
|
${s}`;
|
|
58
|
-
},
|
|
58
|
+
}, O = () => ({
|
|
59
59
|
userRequest: "",
|
|
60
60
|
assignedTask: "",
|
|
61
61
|
messages: [],
|
|
62
62
|
priorSteps: [],
|
|
63
63
|
sharedState: {}
|
|
64
|
-
}),
|
|
65
|
-
agentExecutionContext:
|
|
64
|
+
}), ie = () => ({
|
|
65
|
+
agentExecutionContext: m({
|
|
66
66
|
reducer: j,
|
|
67
|
-
default:
|
|
67
|
+
default: O
|
|
68
68
|
}),
|
|
69
|
-
outputMessage:
|
|
69
|
+
outputMessage: m({
|
|
70
70
|
reducer: $,
|
|
71
71
|
default: () => ""
|
|
72
72
|
}),
|
|
73
|
-
summary:
|
|
74
|
-
reducer:
|
|
73
|
+
summary: m({
|
|
74
|
+
reducer: f,
|
|
75
75
|
default: () => ""
|
|
76
76
|
}),
|
|
77
|
-
status:
|
|
78
|
-
reducer:
|
|
77
|
+
status: m({
|
|
78
|
+
reducer: f
|
|
79
79
|
})
|
|
80
|
-
}),
|
|
81
|
-
...
|
|
82
|
-
sharedStatePatch:
|
|
83
|
-
reducer:
|
|
80
|
+
}), Le = () => ({
|
|
81
|
+
...ie(),
|
|
82
|
+
sharedStatePatch: m({
|
|
83
|
+
reducer: f
|
|
84
84
|
})
|
|
85
|
-
}),
|
|
86
|
-
agentExecutionContext:
|
|
87
|
-
default:
|
|
85
|
+
}), ze = m.Root({
|
|
86
|
+
agentExecutionContext: m({
|
|
87
|
+
default: O,
|
|
88
88
|
reducer: j
|
|
89
89
|
}),
|
|
90
|
-
currentIntent:
|
|
90
|
+
currentIntent: m({
|
|
91
91
|
default: () => "none",
|
|
92
|
-
reducer:
|
|
92
|
+
reducer: f
|
|
93
93
|
}),
|
|
94
|
-
|
|
94
|
+
routing: m({
|
|
95
|
+
default: () => ({ mode: "auto" }),
|
|
96
|
+
reducer: f
|
|
97
|
+
}),
|
|
98
|
+
lastExecutedAgent: m({
|
|
95
99
|
default: () => "",
|
|
96
|
-
reducer:
|
|
100
|
+
reducer: f
|
|
97
101
|
}),
|
|
98
|
-
requiresFollowUp:
|
|
102
|
+
requiresFollowUp: m({
|
|
99
103
|
default: () => !0,
|
|
100
|
-
reducer:
|
|
104
|
+
reducer: f
|
|
101
105
|
}),
|
|
102
|
-
stepCount:
|
|
106
|
+
stepCount: m({
|
|
103
107
|
default: () => 0,
|
|
104
108
|
reducer: (e, t) => t ?? e + 1
|
|
105
109
|
}),
|
|
106
|
-
finalOutputMessage:
|
|
110
|
+
finalOutputMessage: m({
|
|
107
111
|
default: () => "",
|
|
108
112
|
reducer: $
|
|
109
113
|
})
|
|
110
|
-
}),
|
|
111
|
-
await U("trace_message", e, t);
|
|
112
|
-
}, Ue = async (e, t) => {
|
|
113
|
-
await U("graph_ux_suggestion", e, t);
|
|
114
|
-
}, ie = (e) => {
|
|
114
|
+
}), ae = (e) => {
|
|
115
115
|
if (!e || typeof e != "object" || !("services" in e))
|
|
116
116
|
return !1;
|
|
117
117
|
const t = e.services;
|
|
118
118
|
return !!t && typeof t == "object" && "agentRegistry" in t;
|
|
119
|
-
},
|
|
119
|
+
}, ce = (e) => {
|
|
120
120
|
const t = e?.configurable;
|
|
121
|
-
return
|
|
122
|
-
},
|
|
121
|
+
return ae(t) ? t : void 0;
|
|
122
|
+
}, le = (e, t, s) => {
|
|
123
123
|
const n = e[t];
|
|
124
|
-
return n ? typeof n == "function" ? n() : Promise.resolve(n) : new Promise((
|
|
125
|
-
(typeof queueMicrotask == "function" ? queueMicrotask : setTimeout)(
|
|
124
|
+
return n ? typeof n == "function" ? n() : Promise.resolve(n) : new Promise((r, o) => {
|
|
125
|
+
(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
126
|
});
|
|
127
|
-
},
|
|
127
|
+
}, R = async (e) => (await le(/* @__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, de = async (e) => {
|
|
128
128
|
const { agent: t, messages: s, config: n } = e;
|
|
129
129
|
return { structuredResponse: (await t.invoke(
|
|
130
130
|
{
|
|
@@ -132,125 +132,152 @@ ${s}`;
|
|
|
132
132
|
},
|
|
133
133
|
n
|
|
134
134
|
)).structuredResponse };
|
|
135
|
-
},
|
|
136
|
-
const
|
|
137
|
-
|
|
138
|
-
|
|
139
|
-
|
|
140
|
-
|
|
141
|
-
|
|
142
|
-
|
|
143
|
-
|
|
144
|
-
|
|
145
|
-
|
|
146
|
-
|
|
135
|
+
}, pe = (e) => typeof e == "string" && e.length > 0 ? e : void 0, me = () => te(), ue = (e) => typeof e != "string" || e.trim().length === 0 ? "MapsSDK" : `MapsSDK - ${e.trim()}`, ge = (e) => {
|
|
136
|
+
const t = e?.configurable;
|
|
137
|
+
return {
|
|
138
|
+
conversationId: pe(t?.thread_id),
|
|
139
|
+
abortSignal: e?.signal,
|
|
140
|
+
requestId: me(),
|
|
141
|
+
requestSource: ue(ne.applicationName)
|
|
142
|
+
};
|
|
143
|
+
}, fe = (e) => {
|
|
144
|
+
if (e == null || typeof e == "string" || e instanceof FormData || e instanceof HTMLFormElement)
|
|
145
|
+
return e;
|
|
146
|
+
if (e instanceof URLSearchParams)
|
|
147
|
+
return e.toString();
|
|
148
|
+
throw new TypeError(`Unsupported request body type: ${Object.prototype.toString.call(e)}`);
|
|
149
|
+
}, N = async ({ config: e }) => {
|
|
150
|
+
const t = F.getDefault(), n = (await ee.getCredential(`${t.url}/sharing`))?.token;
|
|
151
|
+
return async (r, o) => {
|
|
152
|
+
const { conversationId: a, abortSignal: c, requestId: l, requestSource: d } = ge(e), p = new Headers(o?.headers);
|
|
153
|
+
for (const x of [...p.keys()]) {
|
|
154
|
+
const g = x.toLowerCase();
|
|
155
|
+
(g === "authorization" || g === "api-key" || g.startsWith("x-stainless-")) && p.delete(x);
|
|
156
|
+
}
|
|
157
|
+
n && n.length > 0 && p.set("X-Esri-Authorization", `Bearer ${n}`), t.isPortal || (d && d.length > 0 && p.set("X-Esri-Request-Source", d), a && a.length > 0 && p.set("X-Esri-Conversation-Id", a), l.length > 0 && p.set("X-Esri-Request-Id", l));
|
|
158
|
+
const w = c && o?.signal ? AbortSignal.any([c, o.signal]) : o?.signal ?? c;
|
|
159
|
+
return (await U(r instanceof Request ? r.url : r.toString(), {
|
|
160
|
+
body: fe(o?.body),
|
|
161
|
+
headers: Object.fromEntries(p),
|
|
162
|
+
responseType: "native",
|
|
163
|
+
signal: w
|
|
164
|
+
})).data;
|
|
165
|
+
};
|
|
166
|
+
}, v = async (e = {}) => {
|
|
167
|
+
const { modelTier: t = "default", temperature: s = 0, config: n } = e, r = P[t], o = await re(t);
|
|
168
|
+
return new Y({
|
|
147
169
|
modelName: r,
|
|
148
170
|
apiKey: "dummy-key",
|
|
149
171
|
// 5-mini does not support temperature parameter
|
|
150
172
|
...t !== "default" && { temperature: s },
|
|
151
173
|
configuration: {
|
|
152
|
-
baseURL:
|
|
153
|
-
fetch:
|
|
174
|
+
baseURL: o,
|
|
175
|
+
fetch: await N({ config: n })
|
|
154
176
|
}
|
|
155
177
|
});
|
|
156
|
-
},
|
|
157
|
-
const
|
|
158
|
-
return new
|
|
159
|
-
modelName:
|
|
178
|
+
}, Ve = async (e = {}) => {
|
|
179
|
+
const { tier: t = "default", config: s } = e, n = E[t], r = await oe(t);
|
|
180
|
+
return new Z({
|
|
181
|
+
modelName: n,
|
|
160
182
|
apiKey: "dummy-key",
|
|
161
183
|
configuration: {
|
|
162
|
-
baseURL:
|
|
163
|
-
fetch:
|
|
184
|
+
baseURL: r,
|
|
185
|
+
fetch: await N({ config: s })
|
|
164
186
|
},
|
|
165
187
|
batchSize: 2048,
|
|
166
188
|
maxConcurrency: 10
|
|
167
189
|
});
|
|
168
|
-
},
|
|
169
|
-
id:
|
|
170
|
-
name:
|
|
171
|
-
description:
|
|
190
|
+
}, he = i.object({
|
|
191
|
+
id: i.string().min(1),
|
|
192
|
+
name: i.string().min(1),
|
|
193
|
+
description: i.string().min(1)
|
|
172
194
|
});
|
|
173
|
-
|
|
174
|
-
const
|
|
175
|
-
const t = e.map((n) => n.id), s =
|
|
176
|
-
return
|
|
195
|
+
i.array(he);
|
|
196
|
+
const C = (e) => JSON.stringify(e, null, 2), ye = (e) => {
|
|
197
|
+
const t = e.map((n) => n.id), s = i.enum(t);
|
|
198
|
+
return i.object({
|
|
177
199
|
intent: s.nullable(),
|
|
178
|
-
assignedTask:
|
|
179
|
-
requiresFollowUp:
|
|
200
|
+
assignedTask: i.string().nullable(),
|
|
201
|
+
requiresFollowUp: i.boolean()
|
|
180
202
|
});
|
|
181
|
-
},
|
|
182
|
-
const s =
|
|
183
|
-
if (
|
|
184
|
-
return await
|
|
203
|
+
}, Ke = async (e, t) => {
|
|
204
|
+
const s = ce(t);
|
|
205
|
+
if (t?.signal?.aborted)
|
|
206
|
+
return await y({ text: "Run cancelled; skipping intent routing" }, t), {
|
|
185
207
|
...e,
|
|
186
208
|
currentIntent: "none",
|
|
187
209
|
finalOutputMessage: "Operation cancelled.",
|
|
188
210
|
requiresFollowUp: !1
|
|
189
211
|
};
|
|
190
212
|
try {
|
|
191
|
-
await
|
|
192
|
-
const
|
|
193
|
-
id:
|
|
194
|
-
name:
|
|
195
|
-
description:
|
|
213
|
+
await y({ text: "Asking LLM to route to an agent" }, t);
|
|
214
|
+
const r = s.services.agentRegistry?.list() ?? [], o = r.map(({ agent: h }) => ({
|
|
215
|
+
id: h.id,
|
|
216
|
+
name: h.name,
|
|
217
|
+
description: h.description
|
|
196
218
|
}));
|
|
197
|
-
if (!
|
|
198
|
-
return await
|
|
219
|
+
if (!o.length)
|
|
220
|
+
return await y({ text: "No agents registered; skipping intent detection" }, t), {
|
|
199
221
|
...e,
|
|
200
222
|
currentIntent: "none",
|
|
201
223
|
finalOutputMessage: "No agents registered; skipping intent detection."
|
|
202
224
|
};
|
|
203
|
-
const
|
|
225
|
+
const a = await R("intent_prompt"), c = C(o), l = ye(o), d = {
|
|
204
226
|
registeredAgents: c,
|
|
205
|
-
priorSteps:
|
|
227
|
+
priorSteps: C(e.agentExecutionContext.priorSteps),
|
|
206
228
|
userRequest: e.agentExecutionContext.userRequest
|
|
207
|
-
},
|
|
208
|
-
model: await
|
|
229
|
+
}, w = await D.fromTemplate(a).format(d), S = G({
|
|
230
|
+
model: await v({
|
|
231
|
+
modelTier: "fast",
|
|
232
|
+
config: t
|
|
233
|
+
}),
|
|
209
234
|
tools: [],
|
|
210
|
-
systemPrompt:
|
|
211
|
-
checkpointer: !0,
|
|
235
|
+
systemPrompt: w,
|
|
212
236
|
responseFormat: l,
|
|
213
237
|
middleware: [
|
|
214
238
|
// Preserve recent conversation context while summarizing older messages
|
|
215
239
|
// to control token usage without losing important intent signals.
|
|
216
240
|
// The trigger and keep parameters can be tuned based on token limits and behavior.
|
|
217
|
-
|
|
218
|
-
model: await
|
|
241
|
+
J({
|
|
242
|
+
model: await v({
|
|
243
|
+
modelTier: "fast",
|
|
244
|
+
config: t
|
|
245
|
+
}),
|
|
219
246
|
trigger: { tokens: 4e3 },
|
|
220
247
|
keep: { messages: 6 }
|
|
221
248
|
}),
|
|
222
249
|
// Enforce no loop/retry.
|
|
223
250
|
// 1 usual LLM call and 1 optional summarization call.
|
|
224
|
-
|
|
251
|
+
Q({ runLimit: 2 })
|
|
225
252
|
]
|
|
226
|
-
}), { structuredResponse:
|
|
227
|
-
agent:
|
|
253
|
+
}), { structuredResponse: x } = await de({
|
|
254
|
+
agent: S,
|
|
228
255
|
messages: e.agentExecutionContext.messages,
|
|
229
256
|
config: t
|
|
230
|
-
}),
|
|
231
|
-
|
|
232
|
-
),
|
|
257
|
+
}), g = l.parse(
|
|
258
|
+
x ?? { intent: null, assignedTask: null, requiresFollowUp: !1 }
|
|
259
|
+
), T = g.intent ?? "none", V = {
|
|
233
260
|
...e,
|
|
234
|
-
currentIntent:
|
|
235
|
-
requiresFollowUp:
|
|
261
|
+
currentIntent: T,
|
|
262
|
+
requiresFollowUp: g.requiresFollowUp,
|
|
236
263
|
agentExecutionContext: {
|
|
237
264
|
...e.agentExecutionContext,
|
|
238
|
-
assignedTask:
|
|
265
|
+
assignedTask: g.assignedTask ?? ""
|
|
239
266
|
}
|
|
240
267
|
};
|
|
241
|
-
if (
|
|
242
|
-
const
|
|
268
|
+
if (T === "none") {
|
|
269
|
+
const h = `I could not find an agent that can handle that request. I have access to the following agents: ${r.map(({ agent: K }) => K.name).join(", ")}.
|
|
243
270
|
|
|
244
271
|
Please ask a question that can be answered by one of these agents.`;
|
|
245
|
-
return await
|
|
272
|
+
return await y({ text: "LLM did not identify a clear intent." }, t), {
|
|
246
273
|
...e,
|
|
247
|
-
currentIntent:
|
|
274
|
+
currentIntent: T,
|
|
248
275
|
requiresFollowUp: !1,
|
|
249
|
-
finalOutputMessage:
|
|
276
|
+
finalOutputMessage: h,
|
|
250
277
|
agentExecutionContext: {
|
|
251
278
|
...e.agentExecutionContext,
|
|
252
279
|
assignedTask: "",
|
|
253
|
-
messages: [...e.agentExecutionContext.messages, new
|
|
280
|
+
messages: [...e.agentExecutionContext.messages, new W(h)],
|
|
254
281
|
priorSteps: [
|
|
255
282
|
...e.agentExecutionContext.priorSteps ?? [],
|
|
256
283
|
{
|
|
@@ -263,179 +290,177 @@ Please ask a question that can be answered by one of these agents.`;
|
|
|
263
290
|
}
|
|
264
291
|
};
|
|
265
292
|
}
|
|
266
|
-
return await
|
|
293
|
+
return await y(
|
|
267
294
|
{
|
|
268
|
-
text: `Agent picked: ${
|
|
269
|
-
Task Assigned: ${
|
|
270
|
-
Requires Follow-Up: ${
|
|
295
|
+
text: `Agent picked: ${T}
|
|
296
|
+
Task Assigned: ${g.assignedTask ?? ""}
|
|
297
|
+
Requires Follow-Up: ${g.requiresFollowUp}`
|
|
271
298
|
},
|
|
272
299
|
t
|
|
273
|
-
),
|
|
300
|
+
), V;
|
|
274
301
|
} catch (n) {
|
|
275
|
-
throw await
|
|
302
|
+
throw await y({ text: "Error during intent detection" }, t), new Error(`Error during intent detection: ${n instanceof Error ? n.message : String(n)}`);
|
|
276
303
|
}
|
|
277
|
-
},
|
|
304
|
+
}, we = "0.1", b = 1536, be = "openai", ve = E.default, xe = `Name: {name}
|
|
278
305
|
Title: {title}
|
|
279
|
-
Description: {description}`,
|
|
306
|
+
Description: {description}`, Te = `Name: {name}
|
|
280
307
|
Alias: {alias}
|
|
281
|
-
Description: {description}`,
|
|
282
|
-
schemaVersion:
|
|
283
|
-
modified:
|
|
284
|
-
embeddings:
|
|
285
|
-
modelProvider:
|
|
286
|
-
model:
|
|
287
|
-
dimensions:
|
|
288
|
-
templates:
|
|
289
|
-
layer:
|
|
290
|
-
field:
|
|
308
|
+
Description: {description}`, Be = i.object({
|
|
309
|
+
schemaVersion: i.literal(we),
|
|
310
|
+
modified: i.number().int().nonnegative(),
|
|
311
|
+
embeddings: i.object({
|
|
312
|
+
modelProvider: i.literal(be),
|
|
313
|
+
model: i.literal(ve),
|
|
314
|
+
dimensions: i.literal(b),
|
|
315
|
+
templates: i.object({
|
|
316
|
+
layer: i.string().default(xe),
|
|
317
|
+
field: i.string().default(Te)
|
|
291
318
|
})
|
|
292
319
|
}),
|
|
293
|
-
layers:
|
|
294
|
-
|
|
295
|
-
id:
|
|
296
|
-
name:
|
|
297
|
-
title:
|
|
298
|
-
description:
|
|
299
|
-
vector:
|
|
300
|
-
message: `Layer vector must be exactly ${
|
|
320
|
+
layers: i.array(
|
|
321
|
+
i.object({
|
|
322
|
+
id: i.string().min(1),
|
|
323
|
+
name: i.string().min(1),
|
|
324
|
+
title: i.string().catch(""),
|
|
325
|
+
description: i.string().catch(""),
|
|
326
|
+
vector: i.array(i.number()).length(b, {
|
|
327
|
+
message: `Layer vector must be exactly ${b} dimensions`
|
|
301
328
|
}),
|
|
302
|
-
fields:
|
|
303
|
-
|
|
304
|
-
name:
|
|
305
|
-
alias:
|
|
306
|
-
description:
|
|
307
|
-
vector:
|
|
308
|
-
message: `Field vector must be exactly ${
|
|
329
|
+
fields: i.array(
|
|
330
|
+
i.object({
|
|
331
|
+
name: i.string().min(1),
|
|
332
|
+
alias: i.string().catch(""),
|
|
333
|
+
description: i.string().catch(""),
|
|
334
|
+
vector: i.array(i.number()).length(b, {
|
|
335
|
+
message: `Field vector must be exactly ${b} dimensions`
|
|
309
336
|
})
|
|
310
337
|
})
|
|
311
338
|
)
|
|
312
339
|
})
|
|
313
340
|
).default([])
|
|
314
|
-
}),
|
|
341
|
+
}), Me = (e) => {
|
|
315
342
|
const t = /* @__PURE__ */ new Set();
|
|
316
343
|
for (const n of e)
|
|
317
|
-
if (
|
|
318
|
-
const
|
|
319
|
-
|
|
320
|
-
|
|
344
|
+
if (H(n)) {
|
|
345
|
+
const r = n;
|
|
346
|
+
r.tool_calls && r.tool_calls.length > 0 && r.tool_calls.forEach((o) => {
|
|
347
|
+
o.id && t.add(o.id);
|
|
321
348
|
});
|
|
322
349
|
}
|
|
323
350
|
return e.filter((n) => {
|
|
324
351
|
if (X(n)) {
|
|
325
|
-
const
|
|
326
|
-
return t.has(
|
|
352
|
+
const r = n;
|
|
353
|
+
return t.has(r.tool_call_id);
|
|
327
354
|
}
|
|
328
355
|
return !0;
|
|
329
356
|
});
|
|
330
|
-
},
|
|
331
|
-
const s =
|
|
332
|
-
return
|
|
333
|
-
},
|
|
334
|
-
const { promptText: t, modelTier: s, temperature: n, messages:
|
|
335
|
-
return
|
|
336
|
-
},
|
|
337
|
-
const { promptText: t, modelTier: s = "default", temperature: n = 0, messages:
|
|
357
|
+
}, A = (e, t) => {
|
|
358
|
+
const s = B.fromTemplate(e);
|
|
359
|
+
return D.fromMessages([s, ...t]);
|
|
360
|
+
}, Se = async (e) => {
|
|
361
|
+
const { promptText: t, modelTier: s, temperature: n, messages: r, config: o } = e, a = A(t, r ?? []), c = await v({ modelTier: s, temperature: n, config: o });
|
|
362
|
+
return a.pipe(c);
|
|
363
|
+
}, We = async (e) => {
|
|
364
|
+
const { promptText: t, modelTier: s = "default", temperature: n = 0, messages: r, inputVariables: o, config: a } = e, l = await (await Se({
|
|
338
365
|
promptText: t,
|
|
339
366
|
modelTier: s,
|
|
340
367
|
temperature: n,
|
|
341
|
-
messages:
|
|
342
|
-
|
|
343
|
-
})).invoke(
|
|
368
|
+
messages: r,
|
|
369
|
+
config: a
|
|
370
|
+
})).invoke(o ?? {}, a);
|
|
344
371
|
if (typeof l == "string")
|
|
345
372
|
return l;
|
|
346
|
-
const
|
|
347
|
-
return typeof
|
|
348
|
-
},
|
|
349
|
-
const { promptText: t, modelTier: s = "default", temperature: n = 0, messages:
|
|
350
|
-
return await l.pipe(
|
|
351
|
-
},
|
|
352
|
-
const { promptText: t, modelTier: s = "default", temperature: n = 0, messages:
|
|
353
|
-
return await
|
|
354
|
-
},
|
|
355
|
-
name:
|
|
356
|
-
description:
|
|
357
|
-
valueType:
|
|
358
|
-
alias:
|
|
359
|
-
}),
|
|
360
|
-
fields:
|
|
361
|
-
}), z = (e, t) => e.getFieldAlias(t) ?? void 0,
|
|
373
|
+
const d = l.content;
|
|
374
|
+
return typeof d == "string" ? d : JSON.stringify(d);
|
|
375
|
+
}, L = async (e) => {
|
|
376
|
+
const { promptText: t, modelTier: s = "default", temperature: n = 0, messages: r, inputVariables: o, schema: a, config: c } = e, l = A(t, r ?? []), p = (await v({ modelTier: s, temperature: n, config: c })).withStructuredOutput(a);
|
|
377
|
+
return await l.pipe(p).invoke(o ?? {}, c);
|
|
378
|
+
}, He = async (e) => {
|
|
379
|
+
const { promptText: t, modelTier: s = "default", temperature: n = 0, messages: r, inputVariables: o, tools: a, config: c } = e, l = a.length > 0 ? Me(r ?? []) : r ?? [], d = A(t, l), p = await v({ modelTier: s, temperature: n, config: c });
|
|
380
|
+
return await d.pipe(p.bindTools(a)).invoke(o ?? {}, c);
|
|
381
|
+
}, ke = u.object({
|
|
382
|
+
name: u.string(),
|
|
383
|
+
description: u.string(),
|
|
384
|
+
valueType: u.string(),
|
|
385
|
+
alias: u.string()
|
|
386
|
+
}), Ie = u.object({
|
|
387
|
+
fields: u.array(ke)
|
|
388
|
+
}), z = (e, t) => e.getFieldAlias(t) ?? void 0, I = (e, t) => z(e, t.name) ?? t.alias ?? "", Ee = (e, t) => {
|
|
362
389
|
const s = z(e, t.name);
|
|
363
390
|
return !!(s && s !== (t.alias ?? ""));
|
|
364
391
|
};
|
|
365
|
-
function
|
|
392
|
+
function q(e, t) {
|
|
366
393
|
const s = /* @__PURE__ */ new Map();
|
|
367
394
|
for (const n of e.fields) {
|
|
368
|
-
const
|
|
395
|
+
const r = t.fields.find((l) => l.name === n.name), o = I(e, n), a = Ee(e, n), c = {
|
|
369
396
|
name: n.name,
|
|
370
397
|
type: n.type,
|
|
371
|
-
alias:
|
|
372
|
-
description:
|
|
373
|
-
valueType:
|
|
398
|
+
alias: a ? o : r?.alias ?? o,
|
|
399
|
+
description: r?.description ?? n.description ?? "",
|
|
400
|
+
valueType: r?.valueType ?? n.valueType ?? "",
|
|
374
401
|
domain: e.getFieldDomain(n.name) ?? void 0
|
|
375
402
|
};
|
|
376
403
|
s.set(n.name, c);
|
|
377
404
|
}
|
|
378
405
|
return s;
|
|
379
406
|
}
|
|
380
|
-
const
|
|
381
|
-
const s = await
|
|
382
|
-
const { name: c, type: l, description:
|
|
383
|
-
return [`Name: ${c}`, `Type: ${l}`, `Alias: ${
|
|
407
|
+
const Xe = async (e) => {
|
|
408
|
+
const s = await R("field_descriptions_prompt"), n = e.fields.filter((a) => !(I(e, a) && a.description)).map((a) => {
|
|
409
|
+
const { name: c, type: l, description: d } = a, p = I(e, a);
|
|
410
|
+
return [`Name: ${c}`, `Type: ${l}`, `Alias: ${p}`, `Description: ${d ?? "N/A"}`].join(", ");
|
|
384
411
|
}).join(`
|
|
385
412
|
`);
|
|
386
413
|
if (n.length === 0)
|
|
387
|
-
return
|
|
388
|
-
const
|
|
414
|
+
return q(e, { fields: [] });
|
|
415
|
+
const r = {
|
|
389
416
|
existingItemTitle: e.portalItem?.title,
|
|
390
417
|
existingItemDescription: e.portalItem?.description,
|
|
391
418
|
existingLayerTitle: e.title,
|
|
392
419
|
existingLayerDescription: e.portalItem?.description,
|
|
393
420
|
fieldInformation: n
|
|
394
|
-
},
|
|
421
|
+
}, o = await L({
|
|
395
422
|
promptText: s,
|
|
396
|
-
schema:
|
|
397
|
-
inputVariables:
|
|
423
|
+
schema: Ie,
|
|
424
|
+
inputVariables: r
|
|
398
425
|
});
|
|
399
|
-
return
|
|
400
|
-
},
|
|
401
|
-
title:
|
|
402
|
-
description:
|
|
403
|
-
name:
|
|
404
|
-
}),
|
|
405
|
-
const n = await
|
|
406
|
-
fieldInformation: JSON.stringify(
|
|
426
|
+
return q(e, o);
|
|
427
|
+
}, Re = u.object({
|
|
428
|
+
title: u.string(),
|
|
429
|
+
description: u.string(),
|
|
430
|
+
name: u.string().nullable()
|
|
431
|
+
}), Ge = async (e, t) => {
|
|
432
|
+
const n = await R("layer_descriptions_prompt"), r = Array.from(t.values()), o = {
|
|
433
|
+
fieldInformation: JSON.stringify(r, null, 2),
|
|
407
434
|
existingLayerTitle: e.title,
|
|
408
435
|
existingLayerDescription: e.portalItem?.description,
|
|
409
436
|
existingLayerSnippet: e.portalItem?.snippet,
|
|
410
437
|
layerGeometryType: e.geometryType
|
|
411
438
|
};
|
|
412
|
-
return { ...await
|
|
439
|
+
return { ...await L({
|
|
413
440
|
promptText: n,
|
|
414
|
-
schema:
|
|
415
|
-
inputVariables:
|
|
441
|
+
schema: Re,
|
|
442
|
+
inputVariables: o
|
|
416
443
|
}), name: e.title ?? null };
|
|
417
444
|
};
|
|
418
445
|
export {
|
|
419
|
-
|
|
420
|
-
|
|
421
|
-
|
|
422
|
-
|
|
423
|
-
|
|
424
|
-
|
|
425
|
-
|
|
426
|
-
|
|
427
|
-
|
|
428
|
-
|
|
429
|
-
|
|
430
|
-
|
|
431
|
-
|
|
432
|
-
|
|
433
|
-
|
|
434
|
-
|
|
435
|
-
|
|
436
|
-
|
|
437
|
-
|
|
438
|
-
|
|
439
|
-
f as s,
|
|
440
|
-
_e as t
|
|
446
|
+
ze as D,
|
|
447
|
+
Be as W,
|
|
448
|
+
Ge as a,
|
|
449
|
+
be as b,
|
|
450
|
+
v as c,
|
|
451
|
+
b as d,
|
|
452
|
+
We as e,
|
|
453
|
+
Te as f,
|
|
454
|
+
Xe as g,
|
|
455
|
+
He as h,
|
|
456
|
+
L as i,
|
|
457
|
+
ie as j,
|
|
458
|
+
Le as k,
|
|
459
|
+
xe as l,
|
|
460
|
+
ve as m,
|
|
461
|
+
oe as n,
|
|
462
|
+
ce as o,
|
|
463
|
+
Ke as p,
|
|
464
|
+
Ve as q,
|
|
465
|
+
we as s
|
|
441
466
|
};
|