@arcgis/ai-components 5.2.0-next.1 → 5.2.0-next.11
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 +22 -22
- package/dist/agent-utils/WorkflowAgent.d.ts +2 -2
- package/dist/agent-utils/index.d.ts +99 -0
- package/dist/agent-utils/index.js +148 -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 +30 -1
- 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/{V2P4AIGG.js → 24QNMEFG.js} +1 -1
- package/dist/cdn/{NAUXSHIE.js → 34SG44C3.js} +2 -2
- package/dist/cdn/3JGWGKT6.js +2 -0
- package/dist/cdn/3NBDVZ2I.js +2 -0
- package/dist/cdn/3VOQD2MR.js +2 -0
- package/dist/cdn/434TAA3J.js +2 -0
- package/dist/cdn/53NTYC4I.js +2 -0
- package/dist/cdn/{4HU7735A.js → 5CV7R5IS.js} +6 -4
- package/dist/cdn/{AMP6IALT.js → 5W7S2RS4.js} +1 -1
- package/dist/cdn/{FL4W4VYN.js → 6ZW7Z36F.js} +16 -0
- package/dist/cdn/7CYGX4F4.js +2 -0
- package/dist/cdn/{DHOVCT6R.js → AZGGTNA3.js} +1 -1
- package/dist/cdn/B7WJFBOZ.js +2 -0
- package/dist/cdn/BX7FSMUU.js +56 -0
- package/dist/cdn/CHPQM77M.js +181 -0
- package/dist/cdn/DHKUXLU3.js +179 -0
- package/dist/cdn/DQSEBKOX.js +2 -0
- package/dist/cdn/DXVU45KM.js +2 -0
- package/dist/cdn/{P6OPJQMC.js → DZ2QWNUA.js} +1 -1
- package/dist/cdn/EBISDZ5H.js +2 -0
- package/dist/cdn/{MDVYQQUG.js → ERL2CB2Y.js} +5 -5
- package/dist/cdn/F6QHMKF5.js +2 -0
- package/dist/cdn/FUIGPHBH.js +2 -0
- package/dist/cdn/{AO7BQHKC.js → H2CHHGGH.js} +1 -1
- package/dist/cdn/{OH64RMOR.js → HWKDNS4K.js} +2 -2
- package/dist/cdn/IMQ4TVHF.js +16 -0
- package/dist/cdn/IOD3GDA7.js +2 -0
- package/dist/cdn/IR7PTESF.js +2 -0
- package/dist/cdn/IRZDTYO2.js +2 -0
- package/dist/cdn/JIWK6QK6.js +2 -0
- package/dist/cdn/{S6W6HV4T.js → JLKGS6Y5.js} +12 -12
- package/dist/cdn/K3JCH4XW.js +2 -0
- package/dist/cdn/KHXUWZHB.js +2 -0
- package/dist/cdn/LIFK3QSD.js +2 -0
- package/dist/cdn/NXKKG5TK.js +2 -0
- package/dist/cdn/{FX5JFRDL.js → O3EN27N5.js} +1 -1
- package/dist/cdn/O3RFFPU3.js +6 -0
- package/dist/cdn/P7DG5T3Z.js +9 -0
- package/dist/cdn/PBO6FZN6.js +2 -0
- package/dist/cdn/Q3ZW4FYA.js +3 -0
- package/dist/cdn/Q6LRANX6.js +2 -0
- package/dist/cdn/Q7TL5Q5N.js +2 -0
- package/dist/cdn/QCSN44H4.js +2 -0
- package/dist/cdn/R56X6ZKR.js +161 -0
- package/dist/cdn/{HB5A5R2E.js → RUURNLTP.js} +1 -1
- package/dist/cdn/T43LEBBE.js +47 -0
- package/dist/cdn/{ZLXN7NMF.js → T537PKP4.js} +9 -7
- package/dist/cdn/TR4GFL7X.js +2 -0
- package/dist/cdn/{3PKJWIC3.js → UPEEHMSY.js} +1 -1
- package/dist/cdn/WAIFKDR3.js +2 -0
- package/dist/cdn/WNS5ZUF5.js +2 -0
- package/dist/cdn/X4XY5HIE.js +2 -0
- package/dist/cdn/XOH56EQ2.js +2 -0
- package/dist/cdn/XON27U6U.js +2 -0
- package/dist/cdn/{H7422XUG.js → YLN2BZ5J.js} +1 -1
- package/dist/cdn/{2AXF774U.js → YUKR4AZW.js} +1 -1
- package/dist/cdn/{JY6LLOUJ.js → Z2G7MP5L.js} +3 -3
- package/dist/cdn/ZEYIBYSF.js +66 -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 +1390 -1323
- package/dist/chunks/arcgisKnowledgeGraph.js +109 -72
- package/dist/chunks/dataExplorationGraph.js +108 -96
- package/dist/chunks/generateLayerDescriptions.js +206 -168
- package/dist/chunks/helpGraph.js +16 -13
- package/dist/chunks/index.js +11 -0
- package/dist/chunks/intent_prompt.js +16 -0
- package/dist/chunks/layerStylingGraph.js +23 -20
- package/dist/chunks/navigationGraph.js +34 -30
- package/dist/chunks/orchestrator.js +241 -201
- package/dist/chunks/slottableRequestUtils.js +3 -7
- package/dist/chunks/summarize_query_response_prompt.js +9 -7
- package/dist/chunks/toolCallResponse.js +5 -3
- package/dist/components/arcgis-assistant/customElement.d.ts +15 -0
- package/dist/components/arcgis-assistant/customElement.js +228 -127
- package/dist/components/arcgis-assistant/index.js +2 -3
- package/dist/components/arcgis-assistant/types.d.ts +14 -1
- package/dist/components/arcgis-assistant-chat/customElement.d.ts +8 -2
- package/dist/components/arcgis-assistant-chat/customElement.js +7 -7
- 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 +1 -0
- package/dist/components/arcgis-assistant-help-agent/customElement.js +1 -0
- package/dist/components/arcgis-assistant-interrupt/customElement.d.ts +4 -1
- package/dist/components/arcgis-assistant-interrupt/customElement.js +13 -9
- 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 +1 -0
- package/dist/components/arcgis-assistant-layer-styling-agent/customElement.js +1 -0
- 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 +4 -1
- package/dist/components/arcgis-assistant-navigation-agent/customElement.js +1 -0
- 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 +1 -1
- 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 +6 -5
- package/dist/orchestrator/registry/agentRegistry.d.ts +33 -0
- package/dist/types/lumina.d.ts +10 -4
- package/dist/types/preact.d.ts +11 -4
- package/dist/types/react.d.ts +12 -4
- package/dist/types/stencil.d.ts +10 -4
- package/dist/utils/index.d.ts +87 -43
- package/dist/utils/index.js +54 -49
- package/package.json +8 -7
- package/dist/cdn/462JBSEV.js +0 -422
- package/dist/cdn/7BCR6TUO.js +0 -2
- package/dist/cdn/7GH7VSB2.js +0 -2
- package/dist/cdn/7PLV4QH6.js +0 -2
- package/dist/cdn/DDLZOMUY.js +0 -2
- package/dist/cdn/FHVXO2WG.js +0 -166
- package/dist/cdn/GSEPHN3A.js +0 -106
- package/dist/cdn/MH5RPXHM.js +0 -2
- package/dist/cdn/NVI3I46B.js +0 -2
- package/dist/cdn/OAVEHGB6.js +0 -2
- package/dist/cdn/ON2V5XI2.js +0 -3
- package/dist/cdn/QR54T33D.js +0 -2
- package/dist/cdn/RVOAPUBN.js +0 -2
- package/dist/cdn/SXDLXCIM.js +0 -2
- package/dist/cdn/USMDJUFS.js +0 -2
- package/dist/cdn/V5YEZSRY.js +0 -16
- package/dist/cdn/Y333DGV6.js +0 -2
- package/dist/cdn/YY2SBO3V.js +0 -2
|
@@ -1,46 +1,47 @@
|
|
|
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 p } from "@langchain/langgraph/web";
|
|
3
|
+
import m, { 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 H, summarizationMiddleware as J, modelCallLimitMiddleware as G } from "langchain";
|
|
8
8
|
import { ChatOpenAI as Q, OpenAIEmbeddings as Y } from "@langchain/openai";
|
|
9
|
-
import
|
|
10
|
-
import
|
|
11
|
-
|
|
9
|
+
import F from "@arcgis/core/portal/Portal.js";
|
|
10
|
+
import Z from "@arcgis/core/identity/IdentityManager.js";
|
|
11
|
+
import ee from "@arcgis/core/config.js";
|
|
12
|
+
const q = {
|
|
12
13
|
advanced: "gpt-5.2",
|
|
13
14
|
default: "gpt-5-mini",
|
|
14
15
|
fast: "gpt-5.4-nano"
|
|
15
16
|
}, k = {
|
|
16
17
|
default: "text-embedding-ada-002"
|
|
17
18
|
}, M = /* @__PURE__ */ new Map();
|
|
18
|
-
let
|
|
19
|
-
const
|
|
20
|
-
const t =
|
|
19
|
+
let x = null;
|
|
20
|
+
const te = () => {
|
|
21
|
+
const t = F.getDefault().helperServices;
|
|
21
22
|
if (!t?.aiModels?.url)
|
|
22
23
|
throw new Error("AI Models Service URL is not defined in the portal's helper services.");
|
|
23
24
|
return t.aiModels.url;
|
|
24
|
-
},
|
|
25
|
-
const t =
|
|
26
|
-
M.size === 0 && (
|
|
25
|
+
}, U = async (e) => {
|
|
26
|
+
const t = te();
|
|
27
|
+
M.size === 0 && (x || (x = (async () => {
|
|
27
28
|
try {
|
|
28
29
|
const n = await fetch(`${t}/models`);
|
|
29
30
|
if (!n.ok)
|
|
30
31
|
throw new Error("Failed to fetch AI service discovery data.");
|
|
31
32
|
(await n.json()).models.forEach((o) => M.set(o.name, o));
|
|
32
33
|
} catch (n) {
|
|
33
|
-
throw
|
|
34
|
+
throw x = null, n;
|
|
34
35
|
}
|
|
35
|
-
})()), await
|
|
36
|
+
})()), await x);
|
|
36
37
|
const s = M.get(e);
|
|
37
38
|
if (!s)
|
|
38
39
|
throw new Error(`Model '${e}' is not available in the discovery service.`);
|
|
39
40
|
return s.endpoint;
|
|
40
|
-
},
|
|
41
|
+
}, ne = async (e = "default") => await U(q[e]), se = async (e = "default") => await U(k[e]), h = (e, t) => t, P = (e, t) => ({
|
|
41
42
|
...e,
|
|
42
43
|
...t
|
|
43
|
-
}),
|
|
44
|
+
}), _ = (e = "", t) => {
|
|
44
45
|
const s = typeof t == "string" ? t.trim() : "";
|
|
45
46
|
if (!s)
|
|
46
47
|
return e;
|
|
@@ -61,62 +62,66 @@ ${s}`;
|
|
|
61
62
|
messages: [],
|
|
62
63
|
priorSteps: [],
|
|
63
64
|
sharedState: {}
|
|
64
|
-
}),
|
|
65
|
-
agentExecutionContext:
|
|
66
|
-
reducer:
|
|
65
|
+
}), ie = () => ({
|
|
66
|
+
agentExecutionContext: p({
|
|
67
|
+
reducer: P,
|
|
67
68
|
default: j
|
|
68
69
|
}),
|
|
69
|
-
outputMessage:
|
|
70
|
-
reducer:
|
|
70
|
+
outputMessage: p({
|
|
71
|
+
reducer: _,
|
|
71
72
|
default: () => ""
|
|
72
73
|
}),
|
|
73
|
-
summary:
|
|
74
|
-
reducer:
|
|
74
|
+
summary: p({
|
|
75
|
+
reducer: h,
|
|
75
76
|
default: () => ""
|
|
76
77
|
}),
|
|
77
|
-
status:
|
|
78
|
-
reducer:
|
|
78
|
+
status: p({
|
|
79
|
+
reducer: h
|
|
79
80
|
})
|
|
80
|
-
}),
|
|
81
|
-
...
|
|
82
|
-
sharedStatePatch:
|
|
83
|
-
reducer:
|
|
81
|
+
}), Pe = () => ({
|
|
82
|
+
...ie(),
|
|
83
|
+
sharedStatePatch: p({
|
|
84
|
+
reducer: h
|
|
84
85
|
})
|
|
85
|
-
}),
|
|
86
|
-
agentExecutionContext:
|
|
86
|
+
}), _e = p.Root({
|
|
87
|
+
agentExecutionContext: p({
|
|
87
88
|
default: j,
|
|
88
|
-
reducer:
|
|
89
|
+
reducer: P
|
|
89
90
|
}),
|
|
90
|
-
currentIntent:
|
|
91
|
+
currentIntent: p({
|
|
91
92
|
default: () => "none",
|
|
92
|
-
reducer:
|
|
93
|
+
reducer: h
|
|
93
94
|
}),
|
|
94
|
-
lastExecutedAgent:
|
|
95
|
+
lastExecutedAgent: p({
|
|
95
96
|
default: () => "",
|
|
96
|
-
reducer:
|
|
97
|
+
reducer: h
|
|
97
98
|
}),
|
|
98
|
-
requiresFollowUp:
|
|
99
|
+
requiresFollowUp: p({
|
|
99
100
|
default: () => !0,
|
|
100
|
-
reducer:
|
|
101
|
+
reducer: h
|
|
101
102
|
}),
|
|
102
|
-
stepCount:
|
|
103
|
+
stepCount: p({
|
|
103
104
|
default: () => 0,
|
|
104
105
|
reducer: (e, t) => t ?? e + 1
|
|
105
106
|
}),
|
|
106
|
-
finalOutputMessage:
|
|
107
|
+
finalOutputMessage: p({
|
|
107
108
|
default: () => "",
|
|
108
|
-
reducer:
|
|
109
|
+
reducer: _
|
|
109
110
|
})
|
|
110
|
-
}),
|
|
111
|
-
|
|
112
|
-
|
|
113
|
-
|
|
114
|
-
|
|
111
|
+
}), oe = (e) => {
|
|
112
|
+
if (!e || typeof e != "object" || !("services" in e))
|
|
113
|
+
return !1;
|
|
114
|
+
const t = e.services;
|
|
115
|
+
return !!t && typeof t == "object" && "agentRegistry" in t;
|
|
116
|
+
}, re = (e) => {
|
|
117
|
+
const t = e?.configurable;
|
|
118
|
+
return oe(t) ? t : void 0;
|
|
119
|
+
}, ae = (e, t, s) => {
|
|
115
120
|
const n = e[t];
|
|
116
121
|
return n ? typeof n == "function" ? n() : Promise.resolve(n) : new Promise((i, o) => {
|
|
117
122
|
(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
123
|
});
|
|
119
|
-
},
|
|
124
|
+
}, I = async (e) => (await ae(/* @__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, ce = async (e) => {
|
|
120
125
|
const { agent: t, messages: s, config: n } = e;
|
|
121
126
|
return { structuredResponse: (await t.invoke(
|
|
122
127
|
{
|
|
@@ -124,75 +129,105 @@ ${s}`;
|
|
|
124
129
|
},
|
|
125
130
|
n
|
|
126
131
|
)).structuredResponse };
|
|
127
|
-
},
|
|
128
|
-
const
|
|
129
|
-
return
|
|
130
|
-
|
|
131
|
-
|
|
132
|
-
|
|
133
|
-
}
|
|
134
|
-
|
|
132
|
+
}, le = (e) => typeof e == "string" && e.length > 0 ? e : void 0, de = (e) => e && typeof e == "object" && "aborted" in e ? e : void 0, pe = (e) => {
|
|
133
|
+
const t = e?.configurable;
|
|
134
|
+
return {
|
|
135
|
+
conversationId: le(t?.thread_id),
|
|
136
|
+
abortSignal: de(t?.abortSignal),
|
|
137
|
+
requestId: ee.applicationName
|
|
138
|
+
};
|
|
139
|
+
}, N = async ({ config: e }) => {
|
|
140
|
+
const t = F.getDefault(), n = (await Z.getCredential(`${t.url}/sharing`))?.token;
|
|
141
|
+
return async (i, o) => {
|
|
142
|
+
const { conversationId: a, abortSignal: d, requestId: c } = pe(e), l = new Headers(o?.headers);
|
|
143
|
+
l.delete("Authorization"), l.delete("api-key"), n && n.length > 0 && (l.set("X-Esri-Authorization", `Bearer ${n}`), l.set("X-Esri-Request-Source", "MapsSDK")), a && a.length > 0 && l.set("X-Esri-Conversation-Id", a), c && c.length > 0 && l.set("X-Esri-Request-Id", c);
|
|
144
|
+
const u = d && o?.signal ? AbortSignal.any([d, o.signal]) : o?.signal ?? d;
|
|
145
|
+
return await fetch(i, {
|
|
146
|
+
...o,
|
|
147
|
+
headers: l,
|
|
148
|
+
signal: u
|
|
149
|
+
});
|
|
150
|
+
};
|
|
151
|
+
}, b = async (e = {}) => {
|
|
152
|
+
const { modelTier: t = "default", temperature: s = 0, config: n } = e, i = q[t], o = await ne(t);
|
|
135
153
|
return new Q({
|
|
136
154
|
modelName: i,
|
|
137
155
|
apiKey: "dummy-key",
|
|
138
156
|
// 5-mini does not support temperature parameter
|
|
139
|
-
...
|
|
157
|
+
...t !== "default" && { temperature: s },
|
|
140
158
|
configuration: {
|
|
141
159
|
baseURL: o,
|
|
142
|
-
fetch: N(n
|
|
160
|
+
fetch: await N({ config: n })
|
|
143
161
|
}
|
|
144
162
|
});
|
|
145
|
-
},
|
|
146
|
-
const t =
|
|
163
|
+
}, je = async (e = {}) => {
|
|
164
|
+
const { tier: t = "default", config: s } = e, n = k[t], i = await se(t);
|
|
147
165
|
return new Y({
|
|
148
166
|
modelName: n,
|
|
149
167
|
apiKey: "dummy-key",
|
|
150
168
|
configuration: {
|
|
151
169
|
baseURL: i,
|
|
152
|
-
fetch: N(s
|
|
170
|
+
fetch: await N({ config: s })
|
|
153
171
|
},
|
|
154
172
|
batchSize: 2048,
|
|
155
173
|
maxConcurrency: 10
|
|
156
174
|
});
|
|
157
|
-
},
|
|
175
|
+
}, me = r.object({
|
|
158
176
|
id: r.string().min(1),
|
|
159
177
|
name: r.string().min(1),
|
|
160
178
|
description: r.string().min(1)
|
|
161
179
|
});
|
|
162
|
-
r.array(
|
|
163
|
-
const
|
|
180
|
+
r.array(me);
|
|
181
|
+
const C = (e) => JSON.stringify(e, null, 2), ue = (e) => {
|
|
164
182
|
const t = e.map((n) => n.id), s = r.enum(t);
|
|
165
183
|
return r.object({
|
|
166
184
|
intent: s.nullable(),
|
|
167
185
|
assignedTask: r.string().nullable(),
|
|
168
186
|
requiresFollowUp: r.boolean()
|
|
169
187
|
});
|
|
170
|
-
},
|
|
188
|
+
}, Ne = async (e, t) => {
|
|
189
|
+
const s = re(t);
|
|
190
|
+
if (s.abortSignal?.aborted)
|
|
191
|
+
return await f({ text: "Run cancelled; skipping intent routing" }, t), {
|
|
192
|
+
...e,
|
|
193
|
+
currentIntent: "none",
|
|
194
|
+
finalOutputMessage: "Operation cancelled.",
|
|
195
|
+
requiresFollowUp: !1
|
|
196
|
+
};
|
|
171
197
|
try {
|
|
172
|
-
await
|
|
173
|
-
const i =
|
|
174
|
-
id:
|
|
175
|
-
name:
|
|
176
|
-
description:
|
|
198
|
+
await f({ text: "Asking LLM to route to an agent" }, t);
|
|
199
|
+
const i = s.services.agentRegistry?.list() ?? [], o = i.map(({ agent: g }) => ({
|
|
200
|
+
id: g.id,
|
|
201
|
+
name: g.name,
|
|
202
|
+
description: g.description
|
|
177
203
|
}));
|
|
178
|
-
if (!
|
|
179
|
-
return await
|
|
180
|
-
|
|
181
|
-
|
|
182
|
-
|
|
204
|
+
if (!o.length)
|
|
205
|
+
return await f({ text: "No agents registered; skipping intent detection" }, t), {
|
|
206
|
+
...e,
|
|
207
|
+
currentIntent: "none",
|
|
208
|
+
finalOutputMessage: "No agents registered; skipping intent detection."
|
|
209
|
+
};
|
|
210
|
+
const a = await I("intent_prompt"), d = C(o), c = ue(o), l = {
|
|
211
|
+
registeredAgents: d,
|
|
212
|
+
priorSteps: C(e.agentExecutionContext.priorSteps),
|
|
183
213
|
userRequest: e.agentExecutionContext.userRequest
|
|
184
|
-
},
|
|
185
|
-
model: await
|
|
214
|
+
}, T = await D.fromTemplate(a).format(l), E = H({
|
|
215
|
+
model: await b({
|
|
216
|
+
modelTier: "fast",
|
|
217
|
+
config: t
|
|
218
|
+
}),
|
|
186
219
|
tools: [],
|
|
187
|
-
systemPrompt:
|
|
188
|
-
checkpointer: !0,
|
|
220
|
+
systemPrompt: T,
|
|
189
221
|
responseFormat: c,
|
|
190
222
|
middleware: [
|
|
191
223
|
// Preserve recent conversation context while summarizing older messages
|
|
192
224
|
// to control token usage without losing important intent signals.
|
|
193
225
|
// The trigger and keep parameters can be tuned based on token limits and behavior.
|
|
194
|
-
|
|
195
|
-
model: await
|
|
226
|
+
J({
|
|
227
|
+
model: await b({
|
|
228
|
+
modelTier: "fast",
|
|
229
|
+
config: t
|
|
230
|
+
}),
|
|
196
231
|
trigger: { tokens: 4e3 },
|
|
197
232
|
keep: { messages: 6 }
|
|
198
233
|
}),
|
|
@@ -200,31 +235,34 @@ const D = (e) => JSON.stringify(e, null, 2), oe = (e) => {
|
|
|
200
235
|
// 1 usual LLM call and 1 optional summarization call.
|
|
201
236
|
G({ runLimit: 2 })
|
|
202
237
|
]
|
|
203
|
-
}), { structuredResponse:
|
|
204
|
-
agent:
|
|
238
|
+
}), { structuredResponse: V } = await ce({
|
|
239
|
+
agent: E,
|
|
205
240
|
messages: e.agentExecutionContext.messages,
|
|
206
241
|
config: t
|
|
207
|
-
}),
|
|
208
|
-
|
|
209
|
-
), v =
|
|
242
|
+
}), y = c.parse(
|
|
243
|
+
V ?? { intent: null, assignedTask: null, requiresFollowUp: !1 }
|
|
244
|
+
), v = y.intent ?? "none", z = {
|
|
210
245
|
...e,
|
|
211
246
|
currentIntent: v,
|
|
212
|
-
requiresFollowUp:
|
|
247
|
+
requiresFollowUp: y.requiresFollowUp,
|
|
213
248
|
agentExecutionContext: {
|
|
214
249
|
...e.agentExecutionContext,
|
|
215
|
-
assignedTask:
|
|
250
|
+
assignedTask: y.assignedTask ?? ""
|
|
216
251
|
}
|
|
217
252
|
};
|
|
218
253
|
if (v === "none") {
|
|
219
|
-
const
|
|
220
|
-
|
|
254
|
+
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(", ")}.
|
|
255
|
+
|
|
256
|
+
Please ask a question that can be answered by one of these agents.`;
|
|
257
|
+
return await f({ text: "LLM did not identify a clear intent." }, t), {
|
|
221
258
|
...e,
|
|
222
259
|
currentIntent: v,
|
|
223
260
|
requiresFollowUp: !1,
|
|
261
|
+
finalOutputMessage: g,
|
|
224
262
|
agentExecutionContext: {
|
|
225
263
|
...e.agentExecutionContext,
|
|
226
264
|
assignedTask: "",
|
|
227
|
-
messages: [...e.agentExecutionContext.messages, new B(
|
|
265
|
+
messages: [...e.agentExecutionContext.messages, new B(g)],
|
|
228
266
|
priorSteps: [
|
|
229
267
|
...e.agentExecutionContext.priorSteps ?? [],
|
|
230
268
|
{
|
|
@@ -237,31 +275,31 @@ const D = (e) => JSON.stringify(e, null, 2), oe = (e) => {
|
|
|
237
275
|
}
|
|
238
276
|
};
|
|
239
277
|
}
|
|
240
|
-
return await
|
|
278
|
+
return await f(
|
|
241
279
|
{
|
|
242
280
|
text: `Agent picked: ${v}
|
|
243
|
-
Task Assigned: ${
|
|
244
|
-
Requires Follow-Up: ${
|
|
281
|
+
Task Assigned: ${y.assignedTask ?? ""}
|
|
282
|
+
Requires Follow-Up: ${y.requiresFollowUp}`
|
|
245
283
|
},
|
|
246
284
|
t
|
|
247
|
-
),
|
|
248
|
-
} catch (
|
|
249
|
-
throw await
|
|
285
|
+
), z;
|
|
286
|
+
} catch (n) {
|
|
287
|
+
throw await f({ text: "Error during intent detection" }, t), new Error(`Error during intent detection: ${n instanceof Error ? n.message : String(n)}`);
|
|
250
288
|
}
|
|
251
|
-
},
|
|
289
|
+
}, ge = "0.1", w = 1536, fe = "openai", he = k.default, ye = `Name: {name}
|
|
252
290
|
Title: {title}
|
|
253
|
-
Description: {description}`,
|
|
291
|
+
Description: {description}`, we = `Name: {name}
|
|
254
292
|
Alias: {alias}
|
|
255
|
-
Description: {description}`,
|
|
256
|
-
schemaVersion: r.literal(
|
|
293
|
+
Description: {description}`, $e = r.object({
|
|
294
|
+
schemaVersion: r.literal(ge),
|
|
257
295
|
modified: r.number().int().nonnegative(),
|
|
258
296
|
embeddings: r.object({
|
|
259
|
-
modelProvider: r.literal(
|
|
260
|
-
model: r.literal(
|
|
297
|
+
modelProvider: r.literal(fe),
|
|
298
|
+
model: r.literal(he),
|
|
261
299
|
dimensions: r.literal(w),
|
|
262
300
|
templates: r.object({
|
|
263
|
-
layer: r.string().default(
|
|
264
|
-
field: r.string().default(
|
|
301
|
+
layer: r.string().default(ye),
|
|
302
|
+
field: r.string().default(we)
|
|
265
303
|
})
|
|
266
304
|
}),
|
|
267
305
|
layers: r.array(
|
|
@@ -285,7 +323,7 @@ Description: {description}`, Fe = r.object({
|
|
|
285
323
|
)
|
|
286
324
|
})
|
|
287
325
|
).default([])
|
|
288
|
-
}),
|
|
326
|
+
}), be = (e) => {
|
|
289
327
|
const t = /* @__PURE__ */ new Set();
|
|
290
328
|
for (const n of e)
|
|
291
329
|
if (W(n)) {
|
|
@@ -295,50 +333,51 @@ Description: {description}`, Fe = r.object({
|
|
|
295
333
|
});
|
|
296
334
|
}
|
|
297
335
|
return e.filter((n) => {
|
|
298
|
-
if (
|
|
336
|
+
if (X(n)) {
|
|
299
337
|
const i = n;
|
|
300
338
|
return t.has(i.tool_call_id);
|
|
301
339
|
}
|
|
302
340
|
return !0;
|
|
303
341
|
});
|
|
304
|
-
},
|
|
342
|
+
}, A = (e, t) => {
|
|
305
343
|
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, c = await (await
|
|
344
|
+
return D.fromMessages([s, ...t]);
|
|
345
|
+
}, ve = async (e) => {
|
|
346
|
+
const { promptText: t, modelTier: s, temperature: n, messages: i, config: o } = e, a = A(t, i ?? []), d = await b({ modelTier: s, temperature: n, config: o });
|
|
347
|
+
return a.pipe(d);
|
|
348
|
+
}, Oe = async (e) => {
|
|
349
|
+
const { promptText: t, modelTier: s = "default", temperature: n = 0, messages: i, inputVariables: o, config: a } = e, c = await (await ve({
|
|
312
350
|
promptText: t,
|
|
313
351
|
modelTier: s,
|
|
314
352
|
temperature: n,
|
|
315
|
-
messages: i
|
|
353
|
+
messages: i,
|
|
354
|
+
config: a
|
|
316
355
|
})).invoke(o ?? {});
|
|
317
356
|
if (typeof c == "string")
|
|
318
357
|
return c;
|
|
319
358
|
const l = c.content;
|
|
320
359
|
return typeof l == "string" ? l : JSON.stringify(l);
|
|
321
|
-
},
|
|
322
|
-
const { promptText: t, modelTier: s = "default", temperature: n = 0, messages: i, inputVariables: o, schema: a } = e, c =
|
|
323
|
-
return await c.pipe(
|
|
324
|
-
},
|
|
325
|
-
const { promptText: t, modelTier: s = "default", temperature: n = 0, messages: i, inputVariables: o, tools: a } = e, c = a.length > 0 ?
|
|
326
|
-
return await l.pipe(
|
|
327
|
-
},
|
|
328
|
-
name:
|
|
329
|
-
description:
|
|
330
|
-
valueType:
|
|
331
|
-
alias:
|
|
332
|
-
}),
|
|
333
|
-
fields:
|
|
334
|
-
}),
|
|
335
|
-
const s =
|
|
360
|
+
}, $ = async (e) => {
|
|
361
|
+
const { promptText: t, modelTier: s = "default", temperature: n = 0, messages: i, inputVariables: o, schema: a, config: d } = e, c = A(t, i ?? []), u = (await b({ modelTier: s, temperature: n, config: d })).withStructuredOutput(a);
|
|
362
|
+
return await c.pipe(u).invoke(o ?? {});
|
|
363
|
+
}, Ve = async (e) => {
|
|
364
|
+
const { promptText: t, modelTier: s = "default", temperature: n = 0, messages: i, inputVariables: o, tools: a, config: d } = e, c = a.length > 0 ? be(i ?? []) : i ?? [], l = A(t, c), u = await b({ modelTier: s, temperature: n, config: d });
|
|
365
|
+
return await l.pipe(u.bindTools(a)).invoke(o ?? {});
|
|
366
|
+
}, xe = m.object({
|
|
367
|
+
name: m.string(),
|
|
368
|
+
description: m.string(),
|
|
369
|
+
valueType: m.string(),
|
|
370
|
+
alias: m.string()
|
|
371
|
+
}), Te = m.object({
|
|
372
|
+
fields: m.array(xe)
|
|
373
|
+
}), O = (e, t) => e.getFieldAlias(t) ?? void 0, S = (e, t) => O(e, t.name) ?? t.alias ?? "", Me = (e, t) => {
|
|
374
|
+
const s = O(e, t.name);
|
|
336
375
|
return !!(s && s !== (t.alias ?? ""));
|
|
337
376
|
};
|
|
338
377
|
function R(e, t) {
|
|
339
378
|
const s = /* @__PURE__ */ new Map();
|
|
340
379
|
for (const n of e.fields) {
|
|
341
|
-
const i = t.fields.find((
|
|
380
|
+
const i = t.fields.find((c) => c.name === n.name), o = S(e, n), a = Me(e, n), d = {
|
|
342
381
|
name: n.name,
|
|
343
382
|
type: n.type,
|
|
344
383
|
alias: a ? o : i?.alias ?? o,
|
|
@@ -346,14 +385,14 @@ function R(e, t) {
|
|
|
346
385
|
valueType: i?.valueType ?? n.valueType ?? "",
|
|
347
386
|
domain: e.getFieldDomain(n.name) ?? void 0
|
|
348
387
|
};
|
|
349
|
-
s.set(n.name,
|
|
388
|
+
s.set(n.name, d);
|
|
350
389
|
}
|
|
351
390
|
return s;
|
|
352
391
|
}
|
|
353
|
-
const
|
|
354
|
-
const s = await
|
|
355
|
-
const { name:
|
|
356
|
-
return [`Name: ${
|
|
392
|
+
const ze = async (e) => {
|
|
393
|
+
const s = await I("field_descriptions_prompt"), n = e.fields.filter((a) => !(S(e, a) && a.description)).map((a) => {
|
|
394
|
+
const { name: d, type: c, description: l } = a, u = S(e, a);
|
|
395
|
+
return [`Name: ${d}`, `Type: ${c}`, `Alias: ${u}`, `Description: ${l ?? "N/A"}`].join(", ");
|
|
357
396
|
}).join(`
|
|
358
397
|
`);
|
|
359
398
|
if (n.length === 0)
|
|
@@ -364,50 +403,49 @@ const Pe = async (e) => {
|
|
|
364
403
|
existingLayerTitle: e.title,
|
|
365
404
|
existingLayerDescription: e.portalItem?.description,
|
|
366
405
|
fieldInformation: n
|
|
367
|
-
}, o = await
|
|
406
|
+
}, o = await $({
|
|
368
407
|
promptText: s,
|
|
369
|
-
schema:
|
|
408
|
+
schema: Te,
|
|
370
409
|
inputVariables: i
|
|
371
410
|
});
|
|
372
411
|
return R(e, o);
|
|
373
|
-
},
|
|
374
|
-
title:
|
|
375
|
-
description:
|
|
376
|
-
name:
|
|
377
|
-
}),
|
|
378
|
-
const n = await
|
|
412
|
+
}, Se = m.object({
|
|
413
|
+
title: m.string(),
|
|
414
|
+
description: m.string(),
|
|
415
|
+
name: m.string().nullable()
|
|
416
|
+
}), Le = async (e, t) => {
|
|
417
|
+
const n = await I("layer_descriptions_prompt"), i = Array.from(t.values()), o = {
|
|
379
418
|
fieldInformation: JSON.stringify(i, null, 2),
|
|
380
419
|
existingLayerTitle: e.title,
|
|
381
420
|
existingLayerDescription: e.portalItem?.description,
|
|
382
421
|
existingLayerSnippet: e.portalItem?.snippet,
|
|
383
422
|
layerGeometryType: e.geometryType
|
|
384
423
|
};
|
|
385
|
-
return { ...await
|
|
424
|
+
return { ...await $({
|
|
386
425
|
promptText: n,
|
|
387
|
-
schema:
|
|
426
|
+
schema: Se,
|
|
388
427
|
inputVariables: o
|
|
389
428
|
}), name: e.title ?? null };
|
|
390
429
|
};
|
|
391
430
|
export {
|
|
392
|
-
|
|
393
|
-
|
|
394
|
-
|
|
395
|
-
|
|
396
|
-
|
|
431
|
+
_e as D,
|
|
432
|
+
$e as W,
|
|
433
|
+
Le as a,
|
|
434
|
+
fe as b,
|
|
435
|
+
b as c,
|
|
397
436
|
w as d,
|
|
398
|
-
|
|
399
|
-
|
|
400
|
-
|
|
401
|
-
|
|
402
|
-
|
|
403
|
-
|
|
404
|
-
|
|
405
|
-
|
|
406
|
-
|
|
407
|
-
|
|
408
|
-
|
|
409
|
-
|
|
410
|
-
|
|
411
|
-
|
|
412
|
-
y as s
|
|
437
|
+
Oe as e,
|
|
438
|
+
we as f,
|
|
439
|
+
ze as g,
|
|
440
|
+
Ve as h,
|
|
441
|
+
$ as i,
|
|
442
|
+
ie as j,
|
|
443
|
+
Pe as k,
|
|
444
|
+
ye as l,
|
|
445
|
+
he as m,
|
|
446
|
+
se as n,
|
|
447
|
+
re as o,
|
|
448
|
+
Ne as p,
|
|
449
|
+
je as q,
|
|
450
|
+
ge as s
|
|
413
451
|
};
|