@arcgis/ai-components 5.2.0-next.3 → 5.2.0-next.30
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 +23 -22
- 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/27NEUQN3.js +2 -0
- package/dist/cdn/2NMR43NW.js +2 -0
- package/dist/cdn/3AXQTBIA.js +134 -0
- package/dist/cdn/434TAA3J.js +2 -0
- package/dist/cdn/4I4MCV7V.js +71 -0
- package/dist/cdn/4RZPOYZ7.js +9 -0
- package/dist/cdn/5SBLS4NW.js +2 -0
- package/dist/cdn/{AMP6IALT.js → 5W7S2RS4.js} +1 -1
- package/dist/cdn/6LZ6GOHF.js +56 -0
- package/dist/cdn/7IFCBXV7.js +2 -0
- package/dist/cdn/ADYIXCSG.js +2 -0
- package/dist/cdn/AFLQZIKS.js +180 -0
- package/dist/cdn/AMVOJNWN.js +2 -0
- package/dist/cdn/C7E7MJSR.js +2 -0
- package/dist/cdn/CAECQD75.js +2 -0
- package/dist/cdn/CIW3QMKV.js +2 -0
- package/dist/cdn/CJIV4KJZ.js +179 -0
- package/dist/cdn/CVHJMR5X.js +2 -0
- package/dist/cdn/DEAYZ3MK.js +2 -0
- package/dist/cdn/{H7422XUG.js → E2HENO3T.js} +1 -1
- package/dist/cdn/E7TMP4YV.js +3 -0
- package/dist/cdn/EBRNMPPO.js +48 -0
- package/dist/cdn/FWU6DFIB.js +2 -0
- package/dist/cdn/HBYZSLEZ.js +22 -0
- package/dist/cdn/HOCTVCHH.js +2 -0
- package/dist/cdn/{4HU7735A.js → HXOSLGWU.js} +6 -4
- package/dist/cdn/I64KIZG3.js +2 -0
- package/dist/cdn/IB4WTK74.js +2 -0
- package/dist/cdn/IC5P5NYY.js +2 -0
- package/dist/cdn/IGZWQJW7.js +3 -0
- package/dist/cdn/IKEF7ZHH.js +181 -0
- package/dist/cdn/IXAKT6L3.js +2 -0
- package/dist/cdn/JEIMRNYM.js +2 -0
- package/dist/cdn/JN744CAW.js +2 -0
- package/dist/cdn/KRE4U7V7.js +2 -0
- package/dist/cdn/{NE7E52YR.js → KTK4HNL2.js} +8 -2
- package/dist/cdn/L77BTGXY.js +2 -0
- package/dist/cdn/LEPJUN3X.js +22 -0
- package/dist/cdn/LODKJRS4.js +2 -0
- package/dist/cdn/M3SWPT3M.js +2 -0
- package/dist/cdn/MAV3DW27.js +4 -0
- package/dist/cdn/NOJYPREL.js +3 -0
- package/dist/cdn/NXKKG5TK.js +2 -0
- package/dist/cdn/O3F47IO5.js +2 -0
- package/dist/cdn/O7TGCM5P.js +6 -0
- package/dist/cdn/PBTINZTK.js +65 -0
- package/dist/cdn/PKHQW7QU.js +18 -0
- package/dist/cdn/PSWI3MFB.js +2 -0
- package/dist/cdn/Q73PK7Q7.js +2 -0
- package/dist/cdn/Q7TL5Q5N.js +2 -0
- package/dist/cdn/QSA4T3BU.js +2 -0
- package/dist/cdn/RMLXVQZ5.js +2 -0
- package/dist/cdn/RX45PCYB.js +9 -0
- package/dist/cdn/S27EJSLC.js +14 -0
- package/dist/cdn/SMADRJ67.js +2 -0
- package/dist/cdn/{ZLXN7NMF.js → T537PKP4.js} +9 -7
- package/dist/cdn/{X2ZDYHCG.js → TNMXWUXU.js} +9 -4
- package/dist/cdn/TSEQVE2H.js +36 -0
- package/dist/cdn/VKU4WAQV.js +2 -0
- package/dist/cdn/W2IHPJ54.js +34 -0
- package/dist/cdn/W2JAKE2M.js +2 -0
- package/dist/cdn/WAVKMZA6.js +2 -0
- package/dist/cdn/WDE3HN7K.js +2 -0
- package/dist/cdn/WH6QQK6N.js +2 -0
- package/dist/cdn/WNS5ZUF5.js +2 -0
- package/dist/cdn/{FL4W4VYN.js → X7GE26KU.js} +16 -0
- package/dist/cdn/XVQJBUMY.js +2 -0
- package/dist/cdn/YJ3QQXF6.js +2 -0
- package/dist/cdn/YRBANNQ5.js +2 -0
- package/dist/cdn/YYY7HKYX.js +2 -0
- package/dist/cdn/ZEYIBYSF.js +66 -0
- package/dist/cdn/ZMSJQB65.js +99 -0
- package/dist/cdn/ZOSUDIJH.js +2 -0
- package/dist/cdn/ZPLFFLPF.js +2 -0
- 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 +231 -191
- 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 +267 -226
- 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/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 -42
- package/dist/utils/index.js +54 -49
- package/package.json +8 -7
- package/dist/cdn/2AXF774U.js +0 -2
- package/dist/cdn/3PKJWIC3.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/F2AHA4GB.js +0 -54
- package/dist/cdn/FHVXO2WG.js +0 -166
- package/dist/cdn/FX5JFRDL.js +0 -2
- package/dist/cdn/GSEPHN3A.js +0 -106
- package/dist/cdn/HB5A5R2E.js +0 -2
- package/dist/cdn/JY6LLOUJ.js +0 -22
- package/dist/cdn/KMQ3SP4I.js +0 -5
- package/dist/cdn/MDVYQQUG.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/ON2V5XI2.js +0 -3
- package/dist/cdn/P6OPJQMC.js +0 -3
- package/dist/cdn/QR54T33D.js +0 -2
- package/dist/cdn/RVOAPUBN.js +0 -2
- package/dist/cdn/S6W6HV4T.js +0 -36
- package/dist/cdn/SXDLXCIM.js +0 -2
- package/dist/cdn/USMDJUFS.js +0 -2
- package/dist/cdn/V2P4AIGG.js +0 -2
- package/dist/cdn/V5YEZSRY.js +0 -16
- package/dist/cdn/Y333DGV6.js +0 -2
- package/dist/cdn/YY2SBO3V.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 B, isAIMessage as W, isToolMessage as
|
|
7
|
-
import { createAgent as
|
|
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
8
|
import { ChatOpenAI as Q, OpenAIEmbeddings as Y } from "@langchain/openai";
|
|
9
|
-
import
|
|
10
|
-
import
|
|
11
|
-
|
|
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((o) =>
|
|
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;
|
|
@@ -61,62 +63,66 @@ ${s}`;
|
|
|
61
63
|
messages: [],
|
|
62
64
|
priorSteps: [],
|
|
63
65
|
sharedState: {}
|
|
64
|
-
}),
|
|
65
|
-
agentExecutionContext:
|
|
66
|
-
reducer:
|
|
66
|
+
}), oe = () => ({
|
|
67
|
+
agentExecutionContext: m({
|
|
68
|
+
reducer: P,
|
|
67
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
|
+
}), Ne = m.Root({
|
|
88
|
+
agentExecutionContext: m({
|
|
87
89
|
default: j,
|
|
88
|
-
reducer:
|
|
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
|
-
|
|
112
|
-
|
|
113
|
-
|
|
114
|
-
|
|
112
|
+
}), re = (e) => {
|
|
113
|
+
if (!e || typeof e != "object" || !("services" in e))
|
|
114
|
+
return !1;
|
|
115
|
+
const t = e.services;
|
|
116
|
+
return !!t && typeof t == "object" && "agentRegistry" in t;
|
|
117
|
+
}, ae = (e) => {
|
|
118
|
+
const t = e?.configurable;
|
|
119
|
+
return re(t) ? t : void 0;
|
|
120
|
+
}, ce = (e, t, s) => {
|
|
115
121
|
const n = e[t];
|
|
116
122
|
return n ? typeof n == "function" ? n() : Promise.resolve(n) : new Promise((i, o) => {
|
|
117
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." : ""))));
|
|
118
124
|
});
|
|
119
|
-
},
|
|
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) => {
|
|
120
126
|
const { agent: t, messages: s, config: n } = e;
|
|
121
127
|
return { structuredResponse: (await t.invoke(
|
|
122
128
|
{
|
|
@@ -124,107 +130,141 @@ ${s}`;
|
|
|
124
130
|
},
|
|
125
131
|
n
|
|
126
132
|
)).structuredResponse };
|
|
127
|
-
},
|
|
128
|
-
const
|
|
129
|
-
return
|
|
130
|
-
|
|
131
|
-
|
|
132
|
-
|
|
133
|
-
|
|
134
|
-
|
|
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);
|
|
135
155
|
return new Q({
|
|
136
156
|
modelName: i,
|
|
137
157
|
apiKey: "dummy-key",
|
|
138
158
|
// 5-mini does not support temperature parameter
|
|
139
|
-
...
|
|
159
|
+
...t !== "default" && { temperature: s },
|
|
140
160
|
configuration: {
|
|
141
161
|
baseURL: o,
|
|
142
|
-
fetch:
|
|
162
|
+
fetch: await $({ config: n })
|
|
143
163
|
}
|
|
144
164
|
});
|
|
145
|
-
},
|
|
146
|
-
const t =
|
|
165
|
+
}, Oe = async (e = {}) => {
|
|
166
|
+
const { tier: t = "default", config: s } = e, n = I[t], i = await ie(t);
|
|
147
167
|
return new Y({
|
|
148
168
|
modelName: n,
|
|
149
169
|
apiKey: "dummy-key",
|
|
150
170
|
configuration: {
|
|
151
171
|
baseURL: i,
|
|
152
|
-
fetch:
|
|
172
|
+
fetch: await $({ config: s })
|
|
153
173
|
},
|
|
154
174
|
batchSize: 2048,
|
|
155
175
|
maxConcurrency: 10
|
|
156
176
|
});
|
|
157
|
-
},
|
|
177
|
+
}, ge = r.object({
|
|
158
178
|
id: r.string().min(1),
|
|
159
179
|
name: r.string().min(1),
|
|
160
180
|
description: r.string().min(1)
|
|
161
181
|
});
|
|
162
|
-
r.array(
|
|
163
|
-
const
|
|
182
|
+
r.array(ge);
|
|
183
|
+
const R = (e) => JSON.stringify(e, null, 2), fe = (e) => {
|
|
164
184
|
const t = e.map((n) => n.id), s = r.enum(t);
|
|
165
185
|
return r.object({
|
|
166
186
|
intent: s.nullable(),
|
|
167
187
|
assignedTask: r.string().nullable(),
|
|
168
188
|
requiresFollowUp: r.boolean()
|
|
169
189
|
});
|
|
170
|
-
},
|
|
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), {
|
|
194
|
+
...e,
|
|
195
|
+
currentIntent: "none",
|
|
196
|
+
finalOutputMessage: "Operation cancelled.",
|
|
197
|
+
requiresFollowUp: !1
|
|
198
|
+
};
|
|
171
199
|
try {
|
|
172
|
-
await
|
|
173
|
-
const i =
|
|
174
|
-
id:
|
|
175
|
-
name:
|
|
176
|
-
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
|
|
177
205
|
}));
|
|
178
|
-
if (!
|
|
179
|
-
return await
|
|
180
|
-
|
|
181
|
-
|
|
182
|
-
|
|
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 = {
|
|
213
|
+
registeredAgents: c,
|
|
214
|
+
priorSteps: R(e.agentExecutionContext.priorSteps),
|
|
183
215
|
userRequest: e.agentExecutionContext.userRequest
|
|
184
|
-
},
|
|
185
|
-
model: await
|
|
216
|
+
}, y = await D.fromTemplate(a).format(p), E = G({
|
|
217
|
+
model: await v({
|
|
218
|
+
modelTier: "fast",
|
|
219
|
+
config: t
|
|
220
|
+
}),
|
|
186
221
|
tools: [],
|
|
187
|
-
systemPrompt:
|
|
188
|
-
|
|
189
|
-
responseFormat: c,
|
|
222
|
+
systemPrompt: y,
|
|
223
|
+
responseFormat: l,
|
|
190
224
|
middleware: [
|
|
191
225
|
// Preserve recent conversation context while summarizing older messages
|
|
192
226
|
// to control token usage without losing important intent signals.
|
|
193
227
|
// The trigger and keep parameters can be tuned based on token limits and behavior.
|
|
194
|
-
|
|
195
|
-
model: await
|
|
228
|
+
H({
|
|
229
|
+
model: await v({
|
|
230
|
+
modelTier: "fast",
|
|
231
|
+
config: t
|
|
232
|
+
}),
|
|
196
233
|
trigger: { tokens: 4e3 },
|
|
197
234
|
keep: { messages: 6 }
|
|
198
235
|
}),
|
|
199
236
|
// Enforce no loop/retry.
|
|
200
237
|
// 1 usual LLM call and 1 optional summarization call.
|
|
201
|
-
|
|
238
|
+
J({ runLimit: 2 })
|
|
202
239
|
]
|
|
203
|
-
}), { structuredResponse:
|
|
204
|
-
agent:
|
|
240
|
+
}), { structuredResponse: V } = await le({
|
|
241
|
+
agent: E,
|
|
205
242
|
messages: e.agentExecutionContext.messages,
|
|
206
243
|
config: t
|
|
207
|
-
}),
|
|
208
|
-
|
|
209
|
-
),
|
|
244
|
+
}), w = l.parse(
|
|
245
|
+
V ?? { intent: null, assignedTask: null, requiresFollowUp: !1 }
|
|
246
|
+
), x = w.intent ?? "none", z = {
|
|
210
247
|
...e,
|
|
211
|
-
currentIntent:
|
|
212
|
-
requiresFollowUp:
|
|
248
|
+
currentIntent: x,
|
|
249
|
+
requiresFollowUp: w.requiresFollowUp,
|
|
213
250
|
agentExecutionContext: {
|
|
214
251
|
...e.agentExecutionContext,
|
|
215
|
-
assignedTask:
|
|
252
|
+
assignedTask: w.assignedTask ?? ""
|
|
216
253
|
}
|
|
217
254
|
};
|
|
218
|
-
if (
|
|
219
|
-
const
|
|
220
|
-
|
|
255
|
+
if (x === "none") {
|
|
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), {
|
|
221
260
|
...e,
|
|
222
|
-
currentIntent:
|
|
261
|
+
currentIntent: x,
|
|
223
262
|
requiresFollowUp: !1,
|
|
263
|
+
finalOutputMessage: g,
|
|
224
264
|
agentExecutionContext: {
|
|
225
265
|
...e.agentExecutionContext,
|
|
226
266
|
assignedTask: "",
|
|
227
|
-
messages: [...e.agentExecutionContext.messages, new B(
|
|
267
|
+
messages: [...e.agentExecutionContext.messages, new B(g)],
|
|
228
268
|
priorSteps: [
|
|
229
269
|
...e.agentExecutionContext.priorSteps ?? [],
|
|
230
270
|
{
|
|
@@ -237,31 +277,31 @@ const D = (e) => JSON.stringify(e, null, 2), oe = (e) => {
|
|
|
237
277
|
}
|
|
238
278
|
};
|
|
239
279
|
}
|
|
240
|
-
return await
|
|
280
|
+
return await f(
|
|
241
281
|
{
|
|
242
|
-
text: `Agent picked: ${
|
|
243
|
-
Task Assigned: ${
|
|
244
|
-
Requires Follow-Up: ${
|
|
282
|
+
text: `Agent picked: ${x}
|
|
283
|
+
Task Assigned: ${w.assignedTask ?? ""}
|
|
284
|
+
Requires Follow-Up: ${w.requiresFollowUp}`
|
|
245
285
|
},
|
|
246
286
|
t
|
|
247
|
-
),
|
|
248
|
-
} catch (
|
|
249
|
-
throw await
|
|
287
|
+
), z;
|
|
288
|
+
} catch (n) {
|
|
289
|
+
throw await f({ text: "Error during intent detection" }, t), new Error(`Error during intent detection: ${n instanceof Error ? n.message : String(n)}`);
|
|
250
290
|
}
|
|
251
|
-
},
|
|
291
|
+
}, he = "0.1", b = 1536, ye = "openai", we = I.default, be = `Name: {name}
|
|
252
292
|
Title: {title}
|
|
253
|
-
Description: {description}`,
|
|
293
|
+
Description: {description}`, ve = `Name: {name}
|
|
254
294
|
Alias: {alias}
|
|
255
|
-
Description: {description}`,
|
|
256
|
-
schemaVersion: r.literal(
|
|
295
|
+
Description: {description}`, ze = r.object({
|
|
296
|
+
schemaVersion: r.literal(he),
|
|
257
297
|
modified: r.number().int().nonnegative(),
|
|
258
298
|
embeddings: r.object({
|
|
259
|
-
modelProvider: r.literal(
|
|
260
|
-
model: r.literal(
|
|
261
|
-
dimensions: r.literal(
|
|
299
|
+
modelProvider: r.literal(ye),
|
|
300
|
+
model: r.literal(we),
|
|
301
|
+
dimensions: r.literal(b),
|
|
262
302
|
templates: r.object({
|
|
263
|
-
layer: r.string().default(
|
|
264
|
-
field: r.string().default(
|
|
303
|
+
layer: r.string().default(be),
|
|
304
|
+
field: r.string().default(ve)
|
|
265
305
|
})
|
|
266
306
|
}),
|
|
267
307
|
layers: r.array(
|
|
@@ -270,22 +310,22 @@ Description: {description}`, Fe = r.object({
|
|
|
270
310
|
name: r.string().min(1),
|
|
271
311
|
title: r.string().catch(""),
|
|
272
312
|
description: r.string().catch(""),
|
|
273
|
-
vector: r.array(r.number()).length(
|
|
274
|
-
message: `Layer vector must be exactly ${
|
|
313
|
+
vector: r.array(r.number()).length(b, {
|
|
314
|
+
message: `Layer vector must be exactly ${b} dimensions`
|
|
275
315
|
}),
|
|
276
316
|
fields: r.array(
|
|
277
317
|
r.object({
|
|
278
318
|
name: r.string().min(1),
|
|
279
319
|
alias: r.string().catch(""),
|
|
280
320
|
description: r.string().catch(""),
|
|
281
|
-
vector: r.array(r.number()).length(
|
|
282
|
-
message: `Field vector must be exactly ${
|
|
321
|
+
vector: r.array(r.number()).length(b, {
|
|
322
|
+
message: `Field vector must be exactly ${b} dimensions`
|
|
283
323
|
})
|
|
284
324
|
})
|
|
285
325
|
)
|
|
286
326
|
})
|
|
287
327
|
).default([])
|
|
288
|
-
}),
|
|
328
|
+
}), xe = (e) => {
|
|
289
329
|
const t = /* @__PURE__ */ new Set();
|
|
290
330
|
for (const n of e)
|
|
291
331
|
if (W(n)) {
|
|
@@ -295,50 +335,51 @@ Description: {description}`, Fe = r.object({
|
|
|
295
335
|
});
|
|
296
336
|
}
|
|
297
337
|
return e.filter((n) => {
|
|
298
|
-
if (
|
|
338
|
+
if (X(n)) {
|
|
299
339
|
const i = n;
|
|
300
340
|
return t.has(i.tool_call_id);
|
|
301
341
|
}
|
|
302
342
|
return !0;
|
|
303
343
|
});
|
|
304
|
-
},
|
|
344
|
+
}, A = (e, t) => {
|
|
305
345
|
const s = K.fromTemplate(e);
|
|
306
|
-
return
|
|
307
|
-
},
|
|
308
|
-
const { promptText: t, modelTier: s, temperature: n, messages: i } = e,
|
|
309
|
-
return
|
|
310
|
-
},
|
|
311
|
-
const { promptText: t, modelTier: s = "default", temperature: n = 0, messages: i, inputVariables: o } = 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 });
|
|
349
|
+
return a.pipe(c);
|
|
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({
|
|
312
352
|
promptText: t,
|
|
313
353
|
modelTier: s,
|
|
314
354
|
temperature: n,
|
|
315
|
-
messages: i
|
|
316
|
-
|
|
317
|
-
|
|
318
|
-
|
|
319
|
-
|
|
320
|
-
|
|
321
|
-
|
|
322
|
-
|
|
323
|
-
|
|
324
|
-
|
|
325
|
-
|
|
326
|
-
|
|
327
|
-
|
|
328
|
-
|
|
329
|
-
|
|
330
|
-
|
|
331
|
-
|
|
332
|
-
|
|
333
|
-
|
|
334
|
-
|
|
335
|
-
|
|
355
|
+
messages: i,
|
|
356
|
+
config: a
|
|
357
|
+
})).invoke(o ?? {}, a);
|
|
358
|
+
if (typeof l == "string")
|
|
359
|
+
return l;
|
|
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);
|
|
336
377
|
return !!(s && s !== (t.alias ?? ""));
|
|
337
378
|
};
|
|
338
|
-
function
|
|
379
|
+
function C(e, t) {
|
|
339
380
|
const s = /* @__PURE__ */ new Map();
|
|
340
381
|
for (const n of e.fields) {
|
|
341
|
-
const i = t.fields.find((l) => l.name === n.name), o =
|
|
382
|
+
const i = t.fields.find((l) => l.name === n.name), o = S(e, n), a = Ie(e, n), c = {
|
|
342
383
|
name: n.name,
|
|
343
384
|
type: n.type,
|
|
344
385
|
alias: a ? o : i?.alias ?? o,
|
|
@@ -350,64 +391,63 @@ function R(e, t) {
|
|
|
350
391
|
}
|
|
351
392
|
return s;
|
|
352
393
|
}
|
|
353
|
-
const
|
|
354
|
-
const s = await
|
|
355
|
-
const { name: c, type: l, description:
|
|
356
|
-
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(", ");
|
|
357
398
|
}).join(`
|
|
358
399
|
`);
|
|
359
400
|
if (n.length === 0)
|
|
360
|
-
return
|
|
401
|
+
return C(e, { fields: [] });
|
|
361
402
|
const i = {
|
|
362
403
|
existingItemTitle: e.portalItem?.title,
|
|
363
404
|
existingItemDescription: e.portalItem?.description,
|
|
364
405
|
existingLayerTitle: e.title,
|
|
365
406
|
existingLayerDescription: e.portalItem?.description,
|
|
366
407
|
fieldInformation: n
|
|
367
|
-
}, o = await
|
|
408
|
+
}, o = await N({
|
|
368
409
|
promptText: s,
|
|
369
|
-
schema:
|
|
410
|
+
schema: Se,
|
|
370
411
|
inputVariables: i
|
|
371
412
|
});
|
|
372
|
-
return
|
|
373
|
-
},
|
|
374
|
-
title:
|
|
375
|
-
description:
|
|
376
|
-
name:
|
|
377
|
-
}),
|
|
378
|
-
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 = {
|
|
379
420
|
fieldInformation: JSON.stringify(i, null, 2),
|
|
380
421
|
existingLayerTitle: e.title,
|
|
381
422
|
existingLayerDescription: e.portalItem?.description,
|
|
382
423
|
existingLayerSnippet: e.portalItem?.snippet,
|
|
383
424
|
layerGeometryType: e.geometryType
|
|
384
425
|
};
|
|
385
|
-
return { ...await
|
|
426
|
+
return { ...await N({
|
|
386
427
|
promptText: n,
|
|
387
|
-
schema:
|
|
428
|
+
schema: ke,
|
|
388
429
|
inputVariables: o
|
|
389
430
|
}), name: e.title ?? null };
|
|
390
431
|
};
|
|
391
432
|
export {
|
|
392
|
-
|
|
393
|
-
|
|
394
|
-
|
|
395
|
-
|
|
396
|
-
|
|
397
|
-
|
|
398
|
-
|
|
399
|
-
|
|
400
|
-
|
|
401
|
-
|
|
402
|
-
|
|
403
|
-
|
|
404
|
-
|
|
405
|
-
|
|
406
|
-
|
|
407
|
-
|
|
408
|
-
|
|
409
|
-
|
|
410
|
-
|
|
411
|
-
|
|
412
|
-
y as s
|
|
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
|
|
413
453
|
};
|