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