@arcgis/ai-components 5.2.0-next.6 → 5.2.0-next.60
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/242OOJML.js +2 -0
- package/dist/cdn/2WDZIJQR.js +2 -0
- package/dist/cdn/2XQAM2Q3.js +4 -0
- package/dist/cdn/3DJDRAGV.js +2 -0
- package/dist/cdn/{AMP6IALT.js → 3UEKINYC.js} +1 -1
- package/dist/cdn/3YCSUTGV.js +14 -0
- package/dist/cdn/3ZPPYCNL.js +2 -0
- package/dist/cdn/434TAA3J.js +2 -0
- package/dist/cdn/4CEMUECT.js +2 -0
- package/dist/cdn/57OMVTIU.js +2 -0
- package/dist/cdn/5L7VPEQM.js +2 -0
- package/dist/cdn/6U7TEAAJ.js +2 -0
- package/dist/cdn/7NP7WGR5.js +2 -0
- package/dist/cdn/AHLLB5QW.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/BI3LK5D3.js +2 -0
- package/dist/cdn/{FL4W4VYN.js → BL273EGZ.js} +17 -1
- package/dist/cdn/BSP6IJY4.js +2 -0
- package/dist/cdn/{5ZZGKP7N.js → CEKOEHB3.js} +1 -1
- package/dist/cdn/CWZEQ4R6.js +2 -0
- package/dist/cdn/EF7OV7SR.js +2 -0
- package/dist/cdn/{VOQX4AVB.js → FC45FF2D.js} +6 -4
- package/dist/cdn/FNPLHH4E.js +3 -0
- package/dist/cdn/FVDFPK3V.js +18 -0
- package/dist/cdn/{ZLXN7NMF.js → FYZATVB3.js} +10 -8
- package/dist/cdn/GLOALVJR.js +3 -0
- package/dist/cdn/HBLRVXEB.js +2 -0
- package/dist/cdn/HJG7QM2R.js +9 -0
- package/dist/cdn/HLO655UO.js +2 -0
- package/dist/cdn/HPSVZVAR.js +2 -0
- package/dist/cdn/HQXPPYMD.js +2 -0
- package/dist/cdn/HWBVWBDF.js +36 -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/JHFOZPBP.js +2 -0
- package/dist/cdn/L4SS54EZ.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/MSDNERUF.js +2 -0
- package/dist/cdn/MWYBF3F3.js +66 -0
- package/dist/cdn/NEV6OZN3.js +71 -0
- package/dist/cdn/NQROZZHC.js +65 -0
- package/dist/cdn/OI7EGYZU.js +2 -0
- package/dist/cdn/{23EQTPO3.js → OKVLGJAG.js} +1 -1
- package/dist/cdn/OY2P2O47.js +180 -0
- package/dist/cdn/OYNIFMCJ.js +2 -0
- package/dist/cdn/PDKH5ED3.js +22 -0
- package/dist/cdn/PJ3UN2RU.js +2 -0
- package/dist/cdn/{LQ6R5YRN.js → PQ2DPOFM.js} +1 -1
- package/dist/cdn/PVE7Q43N.js +2 -0
- package/dist/cdn/QBINZNXI.js +9 -0
- package/dist/cdn/QZLE7B6X.js +2 -0
- package/dist/cdn/R74ZHFA6.js +2 -0
- package/dist/cdn/RAAV47KU.js +3 -0
- package/dist/cdn/RLEHNAIA.js +2 -0
- package/dist/cdn/{X2ZDYHCG.js → SDWWUWAF.js} +10 -5
- package/dist/cdn/SLXOVE7Y.js +2 -0
- package/dist/cdn/TFT6HK3O.js +208 -0
- package/dist/cdn/TPULIO6I.js +34 -0
- package/dist/cdn/U4Z5XNJ5.js +2 -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/{H7422XUG.js → VCXSQWGA.js} +1 -1
- package/dist/cdn/VXFQANGJ.js +2 -0
- package/dist/cdn/WHOZT5H5.js +48 -0
- package/dist/cdn/WY7B6IMH.js +2 -0
- package/dist/cdn/XCRR2EEG.js +6 -0
- package/dist/cdn/XVPBO2JC.js +2 -0
- package/dist/cdn/YHQJ66WJ.js +2 -0
- package/dist/cdn/YIA7O2XZ.js +2 -0
- package/dist/cdn/YZIUJNAR.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 +1794 -1597
- 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 +239 -225
- package/dist/chunks/helpGraph.js +21 -17
- 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 +34 -29
- 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 +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 +94 -47
- package/dist/utils/index.js +80 -65
- package/package.json +13 -12
- 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
|
|
11
|
-
|
|
2
|
+
import { Annotation as p } from "@langchain/langgraph/web";
|
|
3
|
+
import u, { z as r } from "zod";
|
|
4
|
+
import { ChatPromptTemplate as q, SystemMessagePromptTemplate as K } from "@langchain/core/prompts";
|
|
5
|
+
import { s as f } from "./index.js";
|
|
6
|
+
import { AIMessage as W, isAIMessage as B, 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 F from "@arcgis/core/portal/Portal.js";
|
|
10
|
+
import Z 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";
|
|
14
|
+
const U = {
|
|
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 S = 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
|
+
}, P = async (e) => {
|
|
28
|
+
const t = se();
|
|
29
|
+
k.size === 0 && (S || (S = (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 Z(`${t}/models`)).data.models.forEach((o) => k.set(o.name, o));
|
|
32
32
|
} catch (n) {
|
|
33
|
-
throw
|
|
33
|
+
throw S = null, n;
|
|
34
34
|
}
|
|
35
|
-
})()), await
|
|
36
|
-
const s =
|
|
35
|
+
})()), await S);
|
|
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
|
+
}, ie = async (e = "default") => await P(U[e]), oe = async (e = "default") => await P(E[e]), h = (e, t) => t, _ = (e, t) => ({
|
|
41
41
|
...e,
|
|
42
42
|
...t
|
|
43
43
|
}), $ = (e = "", t) => {
|
|
@@ -49,82 +49,78 @@ const te = () => {
|
|
|
49
49
|
return s;
|
|
50
50
|
if (n === s)
|
|
51
51
|
return e;
|
|
52
|
-
const
|
|
52
|
+
const i = n.split(`
|
|
53
53
|
|
|
54
54
|
`);
|
|
55
|
-
return
|
|
55
|
+
return i[i.length - 1]?.trim() === s ? e : `${e}
|
|
56
56
|
|
|
57
57
|
${s}`;
|
|
58
|
-
},
|
|
58
|
+
}, j = () => ({
|
|
59
59
|
userRequest: "",
|
|
60
60
|
assignedTask: "",
|
|
61
61
|
messages: [],
|
|
62
62
|
priorSteps: [],
|
|
63
63
|
sharedState: {}
|
|
64
|
-
}),
|
|
65
|
-
agentExecutionContext:
|
|
66
|
-
reducer:
|
|
67
|
-
default:
|
|
64
|
+
}), re = () => ({
|
|
65
|
+
agentExecutionContext: p({
|
|
66
|
+
reducer: _,
|
|
67
|
+
default: j
|
|
68
68
|
}),
|
|
69
|
-
outputMessage:
|
|
69
|
+
outputMessage: p({
|
|
70
70
|
reducer: $,
|
|
71
71
|
default: () => ""
|
|
72
72
|
}),
|
|
73
|
-
summary:
|
|
73
|
+
summary: p({
|
|
74
74
|
reducer: h,
|
|
75
75
|
default: () => ""
|
|
76
76
|
}),
|
|
77
|
-
status:
|
|
77
|
+
status: p({
|
|
78
78
|
reducer: h
|
|
79
79
|
})
|
|
80
|
-
}),
|
|
81
|
-
...
|
|
82
|
-
sharedStatePatch:
|
|
80
|
+
}), Oe = () => ({
|
|
81
|
+
...re(),
|
|
82
|
+
sharedStatePatch: p({
|
|
83
83
|
reducer: h
|
|
84
84
|
})
|
|
85
|
-
}),
|
|
86
|
-
agentExecutionContext:
|
|
87
|
-
default:
|
|
88
|
-
reducer:
|
|
85
|
+
}), ze = p.Root({
|
|
86
|
+
agentExecutionContext: p({
|
|
87
|
+
default: j,
|
|
88
|
+
reducer: _
|
|
89
89
|
}),
|
|
90
|
-
currentIntent:
|
|
90
|
+
currentIntent: p({
|
|
91
91
|
default: () => "none",
|
|
92
92
|
reducer: h
|
|
93
93
|
}),
|
|
94
|
-
lastExecutedAgent:
|
|
94
|
+
lastExecutedAgent: p({
|
|
95
95
|
default: () => "",
|
|
96
96
|
reducer: h
|
|
97
97
|
}),
|
|
98
|
-
requiresFollowUp:
|
|
98
|
+
requiresFollowUp: p({
|
|
99
99
|
default: () => !0,
|
|
100
100
|
reducer: h
|
|
101
101
|
}),
|
|
102
|
-
stepCount:
|
|
102
|
+
stepCount: p({
|
|
103
103
|
default: () => 0,
|
|
104
104
|
reducer: (e, t) => t ?? e + 1
|
|
105
105
|
}),
|
|
106
|
-
finalOutputMessage:
|
|
106
|
+
finalOutputMessage: p({
|
|
107
107
|
default: () => "",
|
|
108
108
|
reducer: $
|
|
109
109
|
})
|
|
110
|
-
}),
|
|
111
|
-
await U("trace_message", e, t);
|
|
112
|
-
}, Ue = async (e, t) => {
|
|
113
|
-
await U("graph_ux_suggestion", e, t);
|
|
114
|
-
}, ie = (e) => {
|
|
110
|
+
}), ae = (e) => {
|
|
115
111
|
if (!e || typeof e != "object" || !("services" in e))
|
|
116
112
|
return !1;
|
|
117
113
|
const t = e.services;
|
|
118
114
|
return !!t && typeof t == "object" && "agentRegistry" in t;
|
|
119
|
-
},
|
|
115
|
+
}, ce = (e) => {
|
|
120
116
|
const t = e?.configurable;
|
|
121
|
-
return
|
|
122
|
-
},
|
|
117
|
+
return ae(t) ? t : void 0;
|
|
118
|
+
}, le = (e, t, s) => {
|
|
123
119
|
const n = e[t];
|
|
124
|
-
return n ? typeof n == "function" ? n() : Promise.resolve(n) : new Promise((
|
|
125
|
-
(typeof queueMicrotask == "function" ? queueMicrotask : setTimeout)(
|
|
120
|
+
return n ? typeof n == "function" ? n() : Promise.resolve(n) : new Promise((i, o) => {
|
|
121
|
+
(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
122
|
});
|
|
127
|
-
},
|
|
123
|
+
}, 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
124
|
const { agent: t, messages: s, config: n } = e;
|
|
129
125
|
return { structuredResponse: (await t.invoke(
|
|
130
126
|
{
|
|
@@ -132,55 +128,70 @@ ${s}`;
|
|
|
132
128
|
},
|
|
133
129
|
n
|
|
134
130
|
)).structuredResponse };
|
|
135
|
-
},
|
|
136
|
-
const
|
|
137
|
-
|
|
138
|
-
|
|
139
|
-
|
|
140
|
-
|
|
141
|
-
|
|
142
|
-
|
|
143
|
-
|
|
144
|
-
|
|
145
|
-
|
|
146
|
-
|
|
147
|
-
|
|
131
|
+
}, me = (e) => typeof e == "string" && e.length > 0 ? e : void 0, pe = () => te(), ue = (e) => typeof e != "string" || e.trim().length === 0 ? "MapsSDK" : `MapsSDK - ${e.trim()}`, ge = (e) => {
|
|
132
|
+
const t = e?.configurable;
|
|
133
|
+
return {
|
|
134
|
+
conversationId: me(t?.thread_id),
|
|
135
|
+
abortSignal: e?.signal,
|
|
136
|
+
requestId: pe(),
|
|
137
|
+
requestSource: ue(ne.applicationName)
|
|
138
|
+
};
|
|
139
|
+
}, N = async ({ config: e }) => {
|
|
140
|
+
const t = F.getDefault(), n = (await ee.getCredential(`${t.url}/sharing`))?.token;
|
|
141
|
+
return async (i, o) => {
|
|
142
|
+
const { conversationId: a, abortSignal: c, requestId: l, requestSource: d } = ge(e), m = new Headers(o?.headers);
|
|
143
|
+
for (const w of [...m.keys()]) {
|
|
144
|
+
const b = w.toLowerCase();
|
|
145
|
+
(b === "authorization" || b === "api-key" || b.startsWith("x-stainless-")) && m.delete(w);
|
|
146
|
+
}
|
|
147
|
+
n && n.length > 0 && m.set("X-Esri-Authorization", `Bearer ${n}`), t.isPortal || (d && d.length > 0 && m.set("X-Esri-Request-Source", d), a && a.length > 0 && m.set("X-Esri-Conversation-Id", a), l.length > 0 && m.set("X-Esri-Request-Id", l));
|
|
148
|
+
const y = c && o?.signal ? AbortSignal.any([c, o.signal]) : o?.signal ?? c;
|
|
149
|
+
return await fetch(i, {
|
|
150
|
+
...o,
|
|
151
|
+
headers: m,
|
|
152
|
+
signal: y
|
|
153
|
+
});
|
|
154
|
+
};
|
|
155
|
+
}, M = async (e = {}) => {
|
|
156
|
+
const { modelTier: t = "default", temperature: s = 0, config: n } = e, i = U[t], o = await ie(t);
|
|
157
|
+
return new Q({
|
|
158
|
+
modelName: i,
|
|
148
159
|
apiKey: "dummy-key",
|
|
149
160
|
// 5-mini does not support temperature parameter
|
|
150
161
|
...t !== "default" && { temperature: s },
|
|
151
162
|
configuration: {
|
|
152
|
-
baseURL:
|
|
153
|
-
fetch:
|
|
163
|
+
baseURL: o,
|
|
164
|
+
fetch: await N({ config: n })
|
|
154
165
|
}
|
|
155
166
|
});
|
|
156
|
-
},
|
|
157
|
-
const
|
|
158
|
-
return new
|
|
159
|
-
modelName:
|
|
167
|
+
}, Le = async (e = {}) => {
|
|
168
|
+
const { tier: t = "default", config: s } = e, n = E[t], i = await oe(t);
|
|
169
|
+
return new Y({
|
|
170
|
+
modelName: n,
|
|
160
171
|
apiKey: "dummy-key",
|
|
161
172
|
configuration: {
|
|
162
173
|
baseURL: i,
|
|
163
|
-
fetch:
|
|
174
|
+
fetch: await N({ config: s })
|
|
164
175
|
},
|
|
165
176
|
batchSize: 2048,
|
|
166
177
|
maxConcurrency: 10
|
|
167
178
|
});
|
|
168
|
-
},
|
|
169
|
-
id:
|
|
170
|
-
name:
|
|
171
|
-
description:
|
|
179
|
+
}, fe = r.object({
|
|
180
|
+
id: r.string().min(1),
|
|
181
|
+
name: r.string().min(1),
|
|
182
|
+
description: r.string().min(1)
|
|
172
183
|
});
|
|
173
|
-
|
|
174
|
-
const
|
|
175
|
-
const t = e.map((n) => n.id), s =
|
|
176
|
-
return
|
|
184
|
+
r.array(fe);
|
|
185
|
+
const C = (e) => JSON.stringify(e, null, 2), he = (e) => {
|
|
186
|
+
const t = e.map((n) => n.id), s = r.enum(t);
|
|
187
|
+
return r.object({
|
|
177
188
|
intent: s.nullable(),
|
|
178
|
-
assignedTask:
|
|
179
|
-
requiresFollowUp:
|
|
189
|
+
assignedTask: r.string().nullable(),
|
|
190
|
+
requiresFollowUp: r.boolean()
|
|
180
191
|
});
|
|
181
|
-
},
|
|
182
|
-
const s =
|
|
183
|
-
if (
|
|
192
|
+
}, Ve = async (e, t) => {
|
|
193
|
+
const s = ce(t);
|
|
194
|
+
if (t?.signal?.aborted)
|
|
184
195
|
return await f({ text: "Run cancelled; skipping intent routing" }, t), {
|
|
185
196
|
...e,
|
|
186
197
|
currentIntent: "none",
|
|
@@ -189,68 +200,73 @@ const R = (e) => JSON.stringify(e, null, 2), de = (e) => {
|
|
|
189
200
|
};
|
|
190
201
|
try {
|
|
191
202
|
await f({ text: "Asking LLM to route to an agent" }, t);
|
|
192
|
-
const
|
|
203
|
+
const i = s.services.agentRegistry?.list() ?? [], o = i.map(({ agent: g }) => ({
|
|
193
204
|
id: g.id,
|
|
194
205
|
name: g.name,
|
|
195
206
|
description: g.description
|
|
196
207
|
}));
|
|
197
|
-
if (!
|
|
208
|
+
if (!o.length)
|
|
198
209
|
return await f({ text: "No agents registered; skipping intent detection" }, t), {
|
|
199
210
|
...e,
|
|
200
211
|
currentIntent: "none",
|
|
201
212
|
finalOutputMessage: "No agents registered; skipping intent detection."
|
|
202
213
|
};
|
|
203
|
-
const
|
|
214
|
+
const a = await R("intent_prompt"), c = C(o), l = he(o), d = {
|
|
204
215
|
registeredAgents: c,
|
|
205
|
-
priorSteps:
|
|
216
|
+
priorSteps: C(e.agentExecutionContext.priorSteps),
|
|
206
217
|
userRequest: e.agentExecutionContext.userRequest
|
|
207
|
-
},
|
|
208
|
-
model: await
|
|
218
|
+
}, y = await q.fromTemplate(a).format(d), w = G({
|
|
219
|
+
model: await M({
|
|
220
|
+
modelTier: "fast",
|
|
221
|
+
config: t
|
|
222
|
+
}),
|
|
209
223
|
tools: [],
|
|
210
|
-
systemPrompt:
|
|
211
|
-
checkpointer: !0,
|
|
224
|
+
systemPrompt: y,
|
|
212
225
|
responseFormat: l,
|
|
213
226
|
middleware: [
|
|
214
227
|
// Preserve recent conversation context while summarizing older messages
|
|
215
228
|
// to control token usage without losing important intent signals.
|
|
216
229
|
// The trigger and keep parameters can be tuned based on token limits and behavior.
|
|
217
|
-
|
|
218
|
-
model: await
|
|
230
|
+
H({
|
|
231
|
+
model: await M({
|
|
232
|
+
modelTier: "fast",
|
|
233
|
+
config: t
|
|
234
|
+
}),
|
|
219
235
|
trigger: { tokens: 4e3 },
|
|
220
236
|
keep: { messages: 6 }
|
|
221
237
|
}),
|
|
222
238
|
// Enforce no loop/retry.
|
|
223
239
|
// 1 usual LLM call and 1 optional summarization call.
|
|
224
|
-
|
|
240
|
+
J({ runLimit: 2 })
|
|
225
241
|
]
|
|
226
|
-
}), { structuredResponse:
|
|
227
|
-
agent:
|
|
242
|
+
}), { structuredResponse: b } = await de({
|
|
243
|
+
agent: w,
|
|
228
244
|
messages: e.agentExecutionContext.messages,
|
|
229
245
|
config: t
|
|
230
|
-
}),
|
|
231
|
-
|
|
232
|
-
),
|
|
246
|
+
}), v = l.parse(
|
|
247
|
+
b ?? { intent: null, assignedTask: null, requiresFollowUp: !1 }
|
|
248
|
+
), T = v.intent ?? "none", L = {
|
|
233
249
|
...e,
|
|
234
|
-
currentIntent:
|
|
235
|
-
requiresFollowUp:
|
|
250
|
+
currentIntent: T,
|
|
251
|
+
requiresFollowUp: v.requiresFollowUp,
|
|
236
252
|
agentExecutionContext: {
|
|
237
253
|
...e.agentExecutionContext,
|
|
238
|
-
assignedTask:
|
|
254
|
+
assignedTask: v.assignedTask ?? ""
|
|
239
255
|
}
|
|
240
256
|
};
|
|
241
|
-
if (
|
|
242
|
-
const g = `I could not find an agent that can handle that request. I have access to the following agents: ${
|
|
257
|
+
if (T === "none") {
|
|
258
|
+
const g = `I could not find an agent that can handle that request. I have access to the following agents: ${i.map(({ agent: V }) => V.name).join(", ")}.
|
|
243
259
|
|
|
244
260
|
Please ask a question that can be answered by one of these agents.`;
|
|
245
261
|
return await f({ text: "LLM did not identify a clear intent." }, t), {
|
|
246
262
|
...e,
|
|
247
|
-
currentIntent:
|
|
263
|
+
currentIntent: T,
|
|
248
264
|
requiresFollowUp: !1,
|
|
249
265
|
finalOutputMessage: g,
|
|
250
266
|
agentExecutionContext: {
|
|
251
267
|
...e.agentExecutionContext,
|
|
252
268
|
assignedTask: "",
|
|
253
|
-
messages: [...e.agentExecutionContext.messages, new
|
|
269
|
+
messages: [...e.agentExecutionContext.messages, new W(g)],
|
|
254
270
|
priorSteps: [
|
|
255
271
|
...e.agentExecutionContext.priorSteps ?? [],
|
|
256
272
|
{
|
|
@@ -265,177 +281,175 @@ Please ask a question that can be answered by one of these agents.`;
|
|
|
265
281
|
}
|
|
266
282
|
return await f(
|
|
267
283
|
{
|
|
268
|
-
text: `Agent picked: ${
|
|
269
|
-
Task Assigned: ${
|
|
270
|
-
Requires Follow-Up: ${
|
|
284
|
+
text: `Agent picked: ${T}
|
|
285
|
+
Task Assigned: ${v.assignedTask ?? ""}
|
|
286
|
+
Requires Follow-Up: ${v.requiresFollowUp}`
|
|
271
287
|
},
|
|
272
288
|
t
|
|
273
|
-
),
|
|
289
|
+
), L;
|
|
274
290
|
} catch (n) {
|
|
275
291
|
throw await f({ text: "Error during intent detection" }, t), new Error(`Error during intent detection: ${n instanceof Error ? n.message : String(n)}`);
|
|
276
292
|
}
|
|
277
|
-
},
|
|
293
|
+
}, ye = "0.1", x = 1536, we = "openai", be = E.default, ve = `Name: {name}
|
|
278
294
|
Title: {title}
|
|
279
|
-
Description: {description}`,
|
|
295
|
+
Description: {description}`, xe = `Name: {name}
|
|
280
296
|
Alias: {alias}
|
|
281
|
-
Description: {description}`,
|
|
282
|
-
schemaVersion:
|
|
283
|
-
modified:
|
|
284
|
-
embeddings:
|
|
285
|
-
modelProvider:
|
|
286
|
-
model:
|
|
287
|
-
dimensions:
|
|
288
|
-
templates:
|
|
289
|
-
layer:
|
|
290
|
-
field:
|
|
297
|
+
Description: {description}`, Ke = r.object({
|
|
298
|
+
schemaVersion: r.literal(ye),
|
|
299
|
+
modified: r.number().int().nonnegative(),
|
|
300
|
+
embeddings: r.object({
|
|
301
|
+
modelProvider: r.literal(we),
|
|
302
|
+
model: r.literal(be),
|
|
303
|
+
dimensions: r.literal(x),
|
|
304
|
+
templates: r.object({
|
|
305
|
+
layer: r.string().default(ve),
|
|
306
|
+
field: r.string().default(xe)
|
|
291
307
|
})
|
|
292
308
|
}),
|
|
293
|
-
layers:
|
|
294
|
-
|
|
295
|
-
id:
|
|
296
|
-
name:
|
|
297
|
-
title:
|
|
298
|
-
description:
|
|
299
|
-
vector:
|
|
300
|
-
message: `Layer vector must be exactly ${
|
|
309
|
+
layers: r.array(
|
|
310
|
+
r.object({
|
|
311
|
+
id: r.string().min(1),
|
|
312
|
+
name: r.string().min(1),
|
|
313
|
+
title: r.string().catch(""),
|
|
314
|
+
description: r.string().catch(""),
|
|
315
|
+
vector: r.array(r.number()).length(x, {
|
|
316
|
+
message: `Layer vector must be exactly ${x} dimensions`
|
|
301
317
|
}),
|
|
302
|
-
fields:
|
|
303
|
-
|
|
304
|
-
name:
|
|
305
|
-
alias:
|
|
306
|
-
description:
|
|
307
|
-
vector:
|
|
308
|
-
message: `Field vector must be exactly ${
|
|
318
|
+
fields: r.array(
|
|
319
|
+
r.object({
|
|
320
|
+
name: r.string().min(1),
|
|
321
|
+
alias: r.string().catch(""),
|
|
322
|
+
description: r.string().catch(""),
|
|
323
|
+
vector: r.array(r.number()).length(x, {
|
|
324
|
+
message: `Field vector must be exactly ${x} dimensions`
|
|
309
325
|
})
|
|
310
326
|
})
|
|
311
327
|
)
|
|
312
328
|
})
|
|
313
329
|
).default([])
|
|
314
|
-
}),
|
|
330
|
+
}), Me = (e) => {
|
|
315
331
|
const t = /* @__PURE__ */ new Set();
|
|
316
332
|
for (const n of e)
|
|
317
|
-
if (
|
|
318
|
-
const
|
|
319
|
-
|
|
320
|
-
|
|
333
|
+
if (B(n)) {
|
|
334
|
+
const i = n;
|
|
335
|
+
i.tool_calls && i.tool_calls.length > 0 && i.tool_calls.forEach((o) => {
|
|
336
|
+
o.id && t.add(o.id);
|
|
321
337
|
});
|
|
322
338
|
}
|
|
323
339
|
return e.filter((n) => {
|
|
324
340
|
if (X(n)) {
|
|
325
|
-
const
|
|
326
|
-
return t.has(
|
|
341
|
+
const i = n;
|
|
342
|
+
return t.has(i.tool_call_id);
|
|
327
343
|
}
|
|
328
344
|
return !0;
|
|
329
345
|
});
|
|
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:
|
|
346
|
+
}, A = (e, t) => {
|
|
347
|
+
const s = K.fromTemplate(e);
|
|
348
|
+
return q.fromMessages([s, ...t]);
|
|
349
|
+
}, Te = async (e) => {
|
|
350
|
+
const { promptText: t, modelTier: s, temperature: n, messages: i, config: o } = e, a = A(t, i ?? []), c = await M({ modelTier: s, temperature: n, config: o });
|
|
351
|
+
return a.pipe(c);
|
|
352
|
+
}, We = async (e) => {
|
|
353
|
+
const { promptText: t, modelTier: s = "default", temperature: n = 0, messages: i, inputVariables: o, config: a } = e, l = await (await Te({
|
|
338
354
|
promptText: t,
|
|
339
355
|
modelTier: s,
|
|
340
356
|
temperature: n,
|
|
341
|
-
messages:
|
|
342
|
-
|
|
343
|
-
})).invoke(
|
|
357
|
+
messages: i,
|
|
358
|
+
config: a
|
|
359
|
+
})).invoke(o ?? {}, a);
|
|
344
360
|
if (typeof l == "string")
|
|
345
361
|
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,
|
|
362
|
+
const d = l.content;
|
|
363
|
+
return typeof d == "string" ? d : JSON.stringify(d);
|
|
364
|
+
}, O = async (e) => {
|
|
365
|
+
const { promptText: t, modelTier: s = "default", temperature: n = 0, messages: i, inputVariables: o, schema: a, config: c } = e, l = A(t, i ?? []), m = (await M({ modelTier: s, temperature: n, config: c })).withStructuredOutput(a);
|
|
366
|
+
return await l.pipe(m).invoke(o ?? {}, c);
|
|
367
|
+
}, Be = async (e) => {
|
|
368
|
+
const { promptText: t, modelTier: s = "default", temperature: n = 0, messages: i, inputVariables: o, tools: a, config: c } = e, l = a.length > 0 ? Me(i ?? []) : i ?? [], d = A(t, l), m = await M({ modelTier: s, temperature: n, config: c });
|
|
369
|
+
return await d.pipe(m.bindTools(a)).invoke(o ?? {}, c);
|
|
370
|
+
}, Se = u.object({
|
|
371
|
+
name: u.string(),
|
|
372
|
+
description: u.string(),
|
|
373
|
+
valueType: u.string(),
|
|
374
|
+
alias: u.string()
|
|
375
|
+
}), ke = u.object({
|
|
376
|
+
fields: u.array(Se)
|
|
377
|
+
}), z = (e, t) => e.getFieldAlias(t) ?? void 0, I = (e, t) => z(e, t.name) ?? t.alias ?? "", Ie = (e, t) => {
|
|
362
378
|
const s = z(e, t.name);
|
|
363
379
|
return !!(s && s !== (t.alias ?? ""));
|
|
364
380
|
};
|
|
365
381
|
function D(e, t) {
|
|
366
382
|
const s = /* @__PURE__ */ new Map();
|
|
367
383
|
for (const n of e.fields) {
|
|
368
|
-
const
|
|
384
|
+
const i = t.fields.find((l) => l.name === n.name), o = I(e, n), a = Ie(e, n), c = {
|
|
369
385
|
name: n.name,
|
|
370
386
|
type: n.type,
|
|
371
|
-
alias:
|
|
372
|
-
description:
|
|
373
|
-
valueType:
|
|
387
|
+
alias: a ? o : i?.alias ?? o,
|
|
388
|
+
description: i?.description ?? n.description ?? "",
|
|
389
|
+
valueType: i?.valueType ?? n.valueType ?? "",
|
|
374
390
|
domain: e.getFieldDomain(n.name) ?? void 0
|
|
375
391
|
};
|
|
376
392
|
s.set(n.name, c);
|
|
377
393
|
}
|
|
378
394
|
return s;
|
|
379
395
|
}
|
|
380
|
-
const
|
|
381
|
-
const s = await
|
|
382
|
-
const { name: c, type: l, description:
|
|
383
|
-
return [`Name: ${c}`, `Type: ${l}`, `Alias: ${
|
|
396
|
+
const Xe = async (e) => {
|
|
397
|
+
const s = await R("field_descriptions_prompt"), n = e.fields.filter((a) => !(I(e, a) && a.description)).map((a) => {
|
|
398
|
+
const { name: c, type: l, description: d } = a, m = I(e, a);
|
|
399
|
+
return [`Name: ${c}`, `Type: ${l}`, `Alias: ${m}`, `Description: ${d ?? "N/A"}`].join(", ");
|
|
384
400
|
}).join(`
|
|
385
401
|
`);
|
|
386
402
|
if (n.length === 0)
|
|
387
403
|
return D(e, { fields: [] });
|
|
388
|
-
const
|
|
404
|
+
const i = {
|
|
389
405
|
existingItemTitle: e.portalItem?.title,
|
|
390
406
|
existingItemDescription: e.portalItem?.description,
|
|
391
407
|
existingLayerTitle: e.title,
|
|
392
408
|
existingLayerDescription: e.portalItem?.description,
|
|
393
409
|
fieldInformation: n
|
|
394
|
-
},
|
|
410
|
+
}, o = await O({
|
|
395
411
|
promptText: s,
|
|
396
|
-
schema:
|
|
397
|
-
inputVariables:
|
|
412
|
+
schema: ke,
|
|
413
|
+
inputVariables: i
|
|
398
414
|
});
|
|
399
|
-
return D(e,
|
|
400
|
-
},
|
|
401
|
-
title:
|
|
402
|
-
description:
|
|
403
|
-
name:
|
|
404
|
-
}),
|
|
405
|
-
const n = await
|
|
406
|
-
fieldInformation: JSON.stringify(
|
|
415
|
+
return D(e, o);
|
|
416
|
+
}, Ee = u.object({
|
|
417
|
+
title: u.string(),
|
|
418
|
+
description: u.string(),
|
|
419
|
+
name: u.string().nullable()
|
|
420
|
+
}), Ge = async (e, t) => {
|
|
421
|
+
const n = await R("layer_descriptions_prompt"), i = Array.from(t.values()), o = {
|
|
422
|
+
fieldInformation: JSON.stringify(i, null, 2),
|
|
407
423
|
existingLayerTitle: e.title,
|
|
408
424
|
existingLayerDescription: e.portalItem?.description,
|
|
409
425
|
existingLayerSnippet: e.portalItem?.snippet,
|
|
410
426
|
layerGeometryType: e.geometryType
|
|
411
427
|
};
|
|
412
|
-
return { ...await
|
|
428
|
+
return { ...await O({
|
|
413
429
|
promptText: n,
|
|
414
|
-
schema:
|
|
415
|
-
inputVariables:
|
|
430
|
+
schema: Ee,
|
|
431
|
+
inputVariables: o
|
|
416
432
|
}), name: e.title ?? null };
|
|
417
433
|
};
|
|
418
434
|
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
|
|
435
|
+
ze as D,
|
|
436
|
+
Ke as W,
|
|
437
|
+
Ge as a,
|
|
438
|
+
we as b,
|
|
439
|
+
M as c,
|
|
440
|
+
x as d,
|
|
441
|
+
We as e,
|
|
442
|
+
xe as f,
|
|
443
|
+
Xe as g,
|
|
444
|
+
Be as h,
|
|
445
|
+
O as i,
|
|
446
|
+
re as j,
|
|
447
|
+
Oe as k,
|
|
448
|
+
ve as l,
|
|
449
|
+
be as m,
|
|
450
|
+
oe as n,
|
|
451
|
+
ce as o,
|
|
452
|
+
Ve as p,
|
|
453
|
+
Le as q,
|
|
454
|
+
ye as s
|
|
441
455
|
};
|