@arcgis/ai-components 5.2.0-next.1 → 5.2.0-next.10
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/LLMAgent.js +22 -22
- package/dist/cdn/{DHOVCT6R.js → 2SJAOYZT.js} +1 -1
- package/dist/cdn/434TAA3J.js +2 -0
- package/dist/cdn/{AMP6IALT.js → 5W7S2RS4.js} +1 -1
- package/dist/cdn/64PJB5NU.js +2 -0
- package/dist/cdn/{OH64RMOR.js → 6AWNQHCO.js} +2 -2
- package/dist/cdn/BIV2IPHH.js +2 -0
- package/dist/cdn/CCY4TSBO.js +2 -0
- package/dist/cdn/{AO7BQHKC.js → CTSALWEP.js} +1 -1
- package/dist/cdn/{NAUXSHIE.js → D2N2NSRQ.js} +2 -2
- package/dist/cdn/{3PKJWIC3.js → D3TNNRP4.js} +1 -1
- package/dist/cdn/{H7422XUG.js → DOV5ZJ7M.js} +1 -1
- package/dist/cdn/EEUCKMU7.js +2 -0
- package/dist/cdn/EGHBXLNG.js +2 -0
- package/dist/cdn/{GSEPHN3A.js → ETRWZ3MS.js} +31 -29
- package/dist/cdn/{S6W6HV4T.js → EWI4V3GQ.js} +10 -10
- package/dist/cdn/GTLS44GI.js +2 -0
- package/dist/cdn/{YY2SBO3V.js → I6HNBTWY.js} +1 -1
- package/dist/cdn/JBHNHHWO.js +3 -0
- package/dist/cdn/{FX5JFRDL.js → JOFUPKIB.js} +1 -1
- package/dist/cdn/KUEOKIQR.js +2 -0
- package/dist/cdn/{FHVXO2WG.js → LKRAPK4A.js} +30 -31
- package/dist/cdn/{4HU7735A.js → MODWHY3R.js} +2 -2
- package/dist/cdn/NXKKG5TK.js +2 -0
- package/dist/cdn/{2AXF774U.js → OBUZ7HBN.js} +1 -1
- package/dist/cdn/OIVRK7HT.js +2 -0
- package/dist/cdn/{HB5A5R2E.js → RUURNLTP.js} +1 -1
- package/dist/cdn/SWOXSJ62.js +2 -0
- package/dist/cdn/{ZLXN7NMF.js → T537PKP4.js} +9 -7
- package/dist/cdn/{JY6LLOUJ.js → TSZPHE7L.js} +2 -2
- package/dist/cdn/VAZNJSKA.js +16 -0
- package/dist/cdn/{V2P4AIGG.js → VMXLYWUK.js} +1 -1
- package/dist/cdn/{MDVYQQUG.js → VNQN5ZQO.js} +2 -2
- package/dist/cdn/WIDTPVSU.js +2 -0
- package/dist/cdn/{P6OPJQMC.js → XER22VYQ.js} +1 -1
- package/dist/cdn/index.js +1 -1
- package/dist/cdn/main.css +1 -1
- package/dist/chunks/adapter.js +491 -496
- package/dist/chunks/arcgisKnowledgeGraph.js +3 -3
- package/dist/chunks/dataExplorationGraph.js +101 -94
- package/dist/chunks/generateLayerDescriptions.js +236 -209
- package/dist/chunks/helpGraph.js +4 -4
- package/dist/chunks/layerStylingGraph.js +10 -10
- package/dist/chunks/navigationGraph.js +27 -27
- package/dist/chunks/orchestrator.js +240 -201
- package/dist/chunks/slottableRequestUtils.js +3 -7
- package/dist/chunks/summarize_query_response_prompt.js +9 -7
- package/dist/components/arcgis-assistant/customElement.d.ts +15 -0
- package/dist/components/arcgis-assistant/customElement.js +227 -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-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-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-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/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 +85 -42
- package/dist/utils/index.js +22 -18
- package/package.json +7 -7
- 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/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/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
|
@@ -1,43 +1,43 @@
|
|
|
1
1
|
/* COPYRIGHT Esri - https://js.arcgis.com/5.2/LICENSE.txt */
|
|
2
2
|
import { Annotation as d } from "@langchain/langgraph/web";
|
|
3
|
-
import p, { z as
|
|
4
|
-
import { ChatPromptTemplate as
|
|
5
|
-
import { dispatchCustomEvent as
|
|
6
|
-
import { AIMessage as
|
|
7
|
-
import { createAgent as
|
|
8
|
-
import { ChatOpenAI as
|
|
9
|
-
import
|
|
10
|
-
import
|
|
11
|
-
const
|
|
3
|
+
import p, { z as o } from "zod";
|
|
4
|
+
import { ChatPromptTemplate as F, SystemMessagePromptTemplate as W } from "@langchain/core/prompts";
|
|
5
|
+
import { dispatchCustomEvent as U } from "@langchain/core/callbacks/dispatch/web";
|
|
6
|
+
import { AIMessage as H, isAIMessage as J, isToolMessage as X } from "@langchain/core/messages";
|
|
7
|
+
import { createAgent as G, summarizationMiddleware as Q, modelCallLimitMiddleware as Y } from "langchain";
|
|
8
|
+
import { ChatOpenAI as Z, OpenAIEmbeddings as ee } from "@langchain/openai";
|
|
9
|
+
import _ from "@arcgis/core/identity/IdentityManager.js";
|
|
10
|
+
import k from "@arcgis/core/portal/Portal.js";
|
|
11
|
+
const P = {
|
|
12
12
|
advanced: "gpt-5.2",
|
|
13
13
|
default: "gpt-5-mini",
|
|
14
14
|
fast: "gpt-5.4-nano"
|
|
15
|
-
},
|
|
15
|
+
}, A = {
|
|
16
16
|
default: "text-embedding-ada-002"
|
|
17
17
|
}, M = /* @__PURE__ */ new Map();
|
|
18
|
-
let
|
|
19
|
-
const
|
|
20
|
-
const t =
|
|
18
|
+
let v = null;
|
|
19
|
+
const te = () => {
|
|
20
|
+
const t = k.getDefault().helperServices;
|
|
21
21
|
if (!t?.aiModels?.url)
|
|
22
22
|
throw new Error("AI Models Service URL is not defined in the portal's helper services.");
|
|
23
23
|
return t.aiModels.url;
|
|
24
|
-
},
|
|
25
|
-
const t =
|
|
26
|
-
M.size === 0 && (
|
|
24
|
+
}, q = async (e) => {
|
|
25
|
+
const t = te();
|
|
26
|
+
M.size === 0 && (v || (v = (async () => {
|
|
27
27
|
try {
|
|
28
28
|
const n = await fetch(`${t}/models`);
|
|
29
29
|
if (!n.ok)
|
|
30
30
|
throw new Error("Failed to fetch AI service discovery data.");
|
|
31
|
-
(await n.json()).models.forEach((
|
|
31
|
+
(await n.json()).models.forEach((i) => M.set(i.name, i));
|
|
32
32
|
} catch (n) {
|
|
33
|
-
throw
|
|
33
|
+
throw v = null, n;
|
|
34
34
|
}
|
|
35
|
-
})()), await
|
|
35
|
+
})()), await v);
|
|
36
36
|
const s = M.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
|
+
}, ne = async (e = "default") => await q(P[e]), se = async (e = "default") => await q(A[e]), h = (e, t) => t, j = (e, t) => ({
|
|
41
41
|
...e,
|
|
42
42
|
...t
|
|
43
43
|
}), $ = (e = "", t) => {
|
|
@@ -49,55 +49,55 @@ const Z = () => {
|
|
|
49
49
|
return s;
|
|
50
50
|
if (n === s)
|
|
51
51
|
return e;
|
|
52
|
-
const
|
|
52
|
+
const a = n.split(`
|
|
53
53
|
|
|
54
54
|
`);
|
|
55
|
-
return
|
|
55
|
+
return a[a.length - 1]?.trim() === s ? e : `${e}
|
|
56
56
|
|
|
57
57
|
${s}`;
|
|
58
|
-
},
|
|
58
|
+
}, N = () => ({
|
|
59
59
|
userRequest: "",
|
|
60
60
|
assignedTask: "",
|
|
61
61
|
messages: [],
|
|
62
62
|
priorSteps: [],
|
|
63
63
|
sharedState: {}
|
|
64
|
-
}),
|
|
64
|
+
}), ae = () => ({
|
|
65
65
|
agentExecutionContext: d({
|
|
66
|
-
reducer:
|
|
67
|
-
default:
|
|
66
|
+
reducer: j,
|
|
67
|
+
default: N
|
|
68
68
|
}),
|
|
69
69
|
outputMessage: d({
|
|
70
70
|
reducer: $,
|
|
71
71
|
default: () => ""
|
|
72
72
|
}),
|
|
73
73
|
summary: d({
|
|
74
|
-
reducer:
|
|
74
|
+
reducer: h,
|
|
75
75
|
default: () => ""
|
|
76
76
|
}),
|
|
77
77
|
status: d({
|
|
78
|
-
reducer:
|
|
78
|
+
reducer: h
|
|
79
79
|
})
|
|
80
|
-
}),
|
|
81
|
-
...
|
|
80
|
+
}), De = () => ({
|
|
81
|
+
...ae(),
|
|
82
82
|
sharedStatePatch: d({
|
|
83
|
-
reducer:
|
|
83
|
+
reducer: h
|
|
84
84
|
})
|
|
85
|
-
}),
|
|
85
|
+
}), Fe = d.Root({
|
|
86
86
|
agentExecutionContext: d({
|
|
87
|
-
default:
|
|
88
|
-
reducer:
|
|
87
|
+
default: N,
|
|
88
|
+
reducer: j
|
|
89
89
|
}),
|
|
90
90
|
currentIntent: d({
|
|
91
91
|
default: () => "none",
|
|
92
|
-
reducer:
|
|
92
|
+
reducer: h
|
|
93
93
|
}),
|
|
94
94
|
lastExecutedAgent: d({
|
|
95
95
|
default: () => "",
|
|
96
|
-
reducer:
|
|
96
|
+
reducer: h
|
|
97
97
|
}),
|
|
98
98
|
requiresFollowUp: d({
|
|
99
99
|
default: () => !0,
|
|
100
|
-
reducer:
|
|
100
|
+
reducer: h
|
|
101
101
|
}),
|
|
102
102
|
stepCount: d({
|
|
103
103
|
default: () => 0,
|
|
@@ -107,16 +107,24 @@ ${s}`;
|
|
|
107
107
|
default: () => "",
|
|
108
108
|
reducer: $
|
|
109
109
|
})
|
|
110
|
-
}),
|
|
111
|
-
await
|
|
112
|
-
},
|
|
113
|
-
await
|
|
114
|
-
},
|
|
110
|
+
}), f = async (e, t) => {
|
|
111
|
+
await U("trace_message", e, t);
|
|
112
|
+
}, Ue = async (e, t) => {
|
|
113
|
+
await U("graph_ux_suggestion", e, t);
|
|
114
|
+
}, ie = (e) => {
|
|
115
|
+
if (!e || typeof e != "object" || !("services" in e))
|
|
116
|
+
return !1;
|
|
117
|
+
const t = e.services;
|
|
118
|
+
return !!t && typeof t == "object" && "agentRegistry" in t;
|
|
119
|
+
}, oe = (e) => {
|
|
120
|
+
const t = e?.configurable;
|
|
121
|
+
return ie(t) ? t : void 0;
|
|
122
|
+
}, re = (e, t, s) => {
|
|
115
123
|
const n = e[t];
|
|
116
|
-
return n ? typeof n == "function" ? n() : Promise.resolve(n) : new Promise((
|
|
117
|
-
(typeof queueMicrotask == "function" ? queueMicrotask : setTimeout)(
|
|
124
|
+
return n ? typeof n == "function" ? n() : Promise.resolve(n) : new Promise((a, i) => {
|
|
125
|
+
(typeof queueMicrotask == "function" ? queueMicrotask : setTimeout)(i.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
126
|
});
|
|
119
|
-
},
|
|
127
|
+
}, I = async (e) => (await re(/* @__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
128
|
const { agent: t, messages: s, config: n } = e;
|
|
121
129
|
return { structuredResponse: (await t.invoke(
|
|
122
130
|
{
|
|
@@ -124,107 +132,124 @@ ${s}`;
|
|
|
124
132
|
},
|
|
125
133
|
n
|
|
126
134
|
)).structuredResponse };
|
|
127
|
-
},
|
|
128
|
-
const
|
|
129
|
-
|
|
130
|
-
|
|
131
|
-
|
|
135
|
+
}, O = (e, t) => async (s, n) => {
|
|
136
|
+
const a = new Headers(n?.headers);
|
|
137
|
+
a.delete("Authorization"), a.delete("api-key"), e && e.length > 0 && (a.set("X-Esri-Authorization", `Bearer ${e}`), a.set("X-Esri-Request-Source", "MapsSDK"));
|
|
138
|
+
const i = t && n?.signal ? AbortSignal.any([t, n.signal]) : n?.signal ?? t;
|
|
139
|
+
return await fetch(s, {
|
|
140
|
+
...n,
|
|
141
|
+
headers: a,
|
|
142
|
+
signal: i
|
|
132
143
|
});
|
|
133
|
-
},
|
|
134
|
-
const s =
|
|
135
|
-
return new
|
|
136
|
-
modelName:
|
|
144
|
+
}, b = async (e = {}) => {
|
|
145
|
+
const { modelTier: t = "default", temperature: s = 0, abortSignal: n } = e, a = k.getDefault(), i = await _.getCredential(`${a.url}/sharing`), r = P[t], c = await ne(t);
|
|
146
|
+
return new Z({
|
|
147
|
+
modelName: r,
|
|
137
148
|
apiKey: "dummy-key",
|
|
138
149
|
// 5-mini does not support temperature parameter
|
|
139
|
-
...
|
|
150
|
+
...t !== "default" && { temperature: s },
|
|
140
151
|
configuration: {
|
|
141
|
-
baseURL:
|
|
142
|
-
fetch:
|
|
152
|
+
baseURL: c,
|
|
153
|
+
fetch: O(i.token, n)
|
|
143
154
|
}
|
|
144
155
|
});
|
|
145
|
-
},
|
|
146
|
-
const
|
|
147
|
-
return new
|
|
148
|
-
modelName:
|
|
156
|
+
}, _e = async (e = "default", t) => {
|
|
157
|
+
const s = k.getDefault(), n = await _.getCredential(`${s.url}/sharing`), a = A[e], i = await se(e);
|
|
158
|
+
return new ee({
|
|
159
|
+
modelName: a,
|
|
149
160
|
apiKey: "dummy-key",
|
|
150
161
|
configuration: {
|
|
151
162
|
baseURL: i,
|
|
152
|
-
fetch:
|
|
163
|
+
fetch: O(n.token, t)
|
|
153
164
|
},
|
|
154
165
|
batchSize: 2048,
|
|
155
166
|
maxConcurrency: 10
|
|
156
167
|
});
|
|
157
|
-
},
|
|
158
|
-
id:
|
|
159
|
-
name:
|
|
160
|
-
description:
|
|
168
|
+
}, le = o.object({
|
|
169
|
+
id: o.string().min(1),
|
|
170
|
+
name: o.string().min(1),
|
|
171
|
+
description: o.string().min(1)
|
|
161
172
|
});
|
|
162
|
-
|
|
163
|
-
const
|
|
164
|
-
const t = e.map((n) => n.id), s =
|
|
165
|
-
return
|
|
173
|
+
o.array(le);
|
|
174
|
+
const R = (e) => JSON.stringify(e, null, 2), de = (e) => {
|
|
175
|
+
const t = e.map((n) => n.id), s = o.enum(t);
|
|
176
|
+
return o.object({
|
|
166
177
|
intent: s.nullable(),
|
|
167
|
-
assignedTask:
|
|
168
|
-
requiresFollowUp:
|
|
178
|
+
assignedTask: o.string().nullable(),
|
|
179
|
+
requiresFollowUp: o.boolean()
|
|
169
180
|
});
|
|
170
|
-
},
|
|
181
|
+
}, Pe = async (e, t) => {
|
|
182
|
+
const s = oe(t);
|
|
183
|
+
if (s.abortSignal?.aborted)
|
|
184
|
+
return await f({ text: "Run cancelled; skipping intent routing" }, t), {
|
|
185
|
+
...e,
|
|
186
|
+
currentIntent: "none",
|
|
187
|
+
finalOutputMessage: "Operation cancelled.",
|
|
188
|
+
requiresFollowUp: !1
|
|
189
|
+
};
|
|
171
190
|
try {
|
|
172
|
-
await
|
|
173
|
-
const
|
|
174
|
-
id:
|
|
175
|
-
name:
|
|
176
|
-
description:
|
|
191
|
+
await f({ text: "Asking LLM to route to an agent" }, t);
|
|
192
|
+
const a = s.services.agentRegistry?.list() ?? [], i = a.map(({ agent: g }) => ({
|
|
193
|
+
id: g.id,
|
|
194
|
+
name: g.name,
|
|
195
|
+
description: g.description
|
|
177
196
|
}));
|
|
178
197
|
if (!i.length)
|
|
179
|
-
return await
|
|
180
|
-
|
|
181
|
-
|
|
182
|
-
|
|
198
|
+
return await f({ text: "No agents registered; skipping intent detection" }, t), {
|
|
199
|
+
...e,
|
|
200
|
+
currentIntent: "none",
|
|
201
|
+
finalOutputMessage: "No agents registered; skipping intent detection."
|
|
202
|
+
};
|
|
203
|
+
const r = await I("intent_prompt"), c = R(i), l = de(i), m = {
|
|
204
|
+
registeredAgents: c,
|
|
205
|
+
priorSteps: R(e.agentExecutionContext.priorSteps),
|
|
183
206
|
userRequest: e.agentExecutionContext.userRequest
|
|
184
|
-
},
|
|
185
|
-
model: await
|
|
207
|
+
}, T = await F.fromTemplate(r).format(m), C = G({
|
|
208
|
+
model: await b({ modelTier: "fast", abortSignal: s.abortSignal }),
|
|
186
209
|
tools: [],
|
|
187
|
-
systemPrompt:
|
|
188
|
-
|
|
189
|
-
responseFormat: c,
|
|
210
|
+
systemPrompt: T,
|
|
211
|
+
responseFormat: l,
|
|
190
212
|
middleware: [
|
|
191
213
|
// Preserve recent conversation context while summarizing older messages
|
|
192
214
|
// to control token usage without losing important intent signals.
|
|
193
215
|
// The trigger and keep parameters can be tuned based on token limits and behavior.
|
|
194
|
-
|
|
195
|
-
model: await
|
|
216
|
+
Q({
|
|
217
|
+
model: await b({ modelTier: "fast", abortSignal: s.abortSignal }),
|
|
196
218
|
trigger: { tokens: 4e3 },
|
|
197
219
|
keep: { messages: 6 }
|
|
198
220
|
}),
|
|
199
221
|
// Enforce no loop/retry.
|
|
200
222
|
// 1 usual LLM call and 1 optional summarization call.
|
|
201
|
-
|
|
223
|
+
Y({ runLimit: 2 })
|
|
202
224
|
]
|
|
203
|
-
}), { structuredResponse:
|
|
204
|
-
agent:
|
|
225
|
+
}), { structuredResponse: L } = await ce({
|
|
226
|
+
agent: C,
|
|
205
227
|
messages: e.agentExecutionContext.messages,
|
|
206
228
|
config: t
|
|
207
|
-
}),
|
|
208
|
-
|
|
209
|
-
),
|
|
229
|
+
}), y = l.parse(
|
|
230
|
+
L ?? { intent: null, assignedTask: null, requiresFollowUp: !1 }
|
|
231
|
+
), x = y.intent ?? "none", K = {
|
|
210
232
|
...e,
|
|
211
|
-
currentIntent:
|
|
212
|
-
requiresFollowUp:
|
|
233
|
+
currentIntent: x,
|
|
234
|
+
requiresFollowUp: y.requiresFollowUp,
|
|
213
235
|
agentExecutionContext: {
|
|
214
236
|
...e.agentExecutionContext,
|
|
215
|
-
assignedTask:
|
|
237
|
+
assignedTask: y.assignedTask ?? ""
|
|
216
238
|
}
|
|
217
239
|
};
|
|
218
|
-
if (
|
|
219
|
-
const
|
|
220
|
-
|
|
240
|
+
if (x === "none") {
|
|
241
|
+
const g = `I could not find an agent that can handle that request. I have access to the following agents: ${a.map(({ agent: B }) => B.name).join(", ")}.
|
|
242
|
+
|
|
243
|
+
Please ask a question that can be answered by one of these agents.`;
|
|
244
|
+
return await f({ text: "LLM did not identify a clear intent." }, t), {
|
|
221
245
|
...e,
|
|
222
|
-
currentIntent:
|
|
246
|
+
currentIntent: x,
|
|
223
247
|
requiresFollowUp: !1,
|
|
248
|
+
finalOutputMessage: g,
|
|
224
249
|
agentExecutionContext: {
|
|
225
250
|
...e.agentExecutionContext,
|
|
226
251
|
assignedTask: "",
|
|
227
|
-
messages: [...e.agentExecutionContext.messages, new
|
|
252
|
+
messages: [...e.agentExecutionContext.messages, new H(g)],
|
|
228
253
|
priorSteps: [
|
|
229
254
|
...e.agentExecutionContext.priorSteps ?? [],
|
|
230
255
|
{
|
|
@@ -237,177 +262,179 @@ const D = (e) => JSON.stringify(e, null, 2), oe = (e) => {
|
|
|
237
262
|
}
|
|
238
263
|
};
|
|
239
264
|
}
|
|
240
|
-
return await
|
|
265
|
+
return await f(
|
|
241
266
|
{
|
|
242
|
-
text: `Agent picked: ${
|
|
243
|
-
Task Assigned: ${
|
|
244
|
-
Requires Follow-Up: ${
|
|
267
|
+
text: `Agent picked: ${x}
|
|
268
|
+
Task Assigned: ${y.assignedTask ?? ""}
|
|
269
|
+
Requires Follow-Up: ${y.requiresFollowUp}`
|
|
245
270
|
},
|
|
246
271
|
t
|
|
247
|
-
),
|
|
248
|
-
} catch (
|
|
249
|
-
throw await
|
|
272
|
+
), K;
|
|
273
|
+
} catch (n) {
|
|
274
|
+
throw await f({ text: "Error during intent detection" }, t), new Error(`Error during intent detection: ${n instanceof Error ? n.message : String(n)}`);
|
|
250
275
|
}
|
|
251
|
-
},
|
|
276
|
+
}, pe = "0.1", w = 1536, me = "openai", ue = A.default, ge = `Name: {name}
|
|
252
277
|
Title: {title}
|
|
253
|
-
Description: {description}`,
|
|
278
|
+
Description: {description}`, fe = `Name: {name}
|
|
254
279
|
Alias: {alias}
|
|
255
|
-
Description: {description}`,
|
|
256
|
-
schemaVersion:
|
|
257
|
-
modified:
|
|
258
|
-
embeddings:
|
|
259
|
-
modelProvider:
|
|
260
|
-
model:
|
|
261
|
-
dimensions:
|
|
262
|
-
templates:
|
|
263
|
-
layer:
|
|
264
|
-
field:
|
|
280
|
+
Description: {description}`, qe = o.object({
|
|
281
|
+
schemaVersion: o.literal(pe),
|
|
282
|
+
modified: o.number().int().nonnegative(),
|
|
283
|
+
embeddings: o.object({
|
|
284
|
+
modelProvider: o.literal(me),
|
|
285
|
+
model: o.literal(ue),
|
|
286
|
+
dimensions: o.literal(w),
|
|
287
|
+
templates: o.object({
|
|
288
|
+
layer: o.string().default(ge),
|
|
289
|
+
field: o.string().default(fe)
|
|
265
290
|
})
|
|
266
291
|
}),
|
|
267
|
-
layers:
|
|
268
|
-
|
|
269
|
-
id:
|
|
270
|
-
name:
|
|
271
|
-
title:
|
|
272
|
-
description:
|
|
273
|
-
vector:
|
|
292
|
+
layers: o.array(
|
|
293
|
+
o.object({
|
|
294
|
+
id: o.string().min(1),
|
|
295
|
+
name: o.string().min(1),
|
|
296
|
+
title: o.string().catch(""),
|
|
297
|
+
description: o.string().catch(""),
|
|
298
|
+
vector: o.array(o.number()).length(w, {
|
|
274
299
|
message: `Layer vector must be exactly ${w} dimensions`
|
|
275
300
|
}),
|
|
276
|
-
fields:
|
|
277
|
-
|
|
278
|
-
name:
|
|
279
|
-
alias:
|
|
280
|
-
description:
|
|
281
|
-
vector:
|
|
301
|
+
fields: o.array(
|
|
302
|
+
o.object({
|
|
303
|
+
name: o.string().min(1),
|
|
304
|
+
alias: o.string().catch(""),
|
|
305
|
+
description: o.string().catch(""),
|
|
306
|
+
vector: o.array(o.number()).length(w, {
|
|
282
307
|
message: `Field vector must be exactly ${w} dimensions`
|
|
283
308
|
})
|
|
284
309
|
})
|
|
285
310
|
)
|
|
286
311
|
})
|
|
287
312
|
).default([])
|
|
288
|
-
}),
|
|
313
|
+
}), he = (e) => {
|
|
289
314
|
const t = /* @__PURE__ */ new Set();
|
|
290
315
|
for (const n of e)
|
|
291
|
-
if (
|
|
292
|
-
const
|
|
293
|
-
|
|
294
|
-
|
|
316
|
+
if (J(n)) {
|
|
317
|
+
const a = n;
|
|
318
|
+
a.tool_calls && a.tool_calls.length > 0 && a.tool_calls.forEach((i) => {
|
|
319
|
+
i.id && t.add(i.id);
|
|
295
320
|
});
|
|
296
321
|
}
|
|
297
322
|
return e.filter((n) => {
|
|
298
|
-
if (
|
|
299
|
-
const
|
|
300
|
-
return t.has(
|
|
323
|
+
if (X(n)) {
|
|
324
|
+
const a = n;
|
|
325
|
+
return t.has(a.tool_call_id);
|
|
301
326
|
}
|
|
302
327
|
return !0;
|
|
303
328
|
});
|
|
304
329
|
}, E = (e, t) => {
|
|
305
|
-
const s =
|
|
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:
|
|
330
|
+
const s = W.fromTemplate(e);
|
|
331
|
+
return F.fromMessages([s, ...t]);
|
|
332
|
+
}, ye = async (e) => {
|
|
333
|
+
const { promptText: t, modelTier: s, temperature: n, messages: a, abortSignal: i } = e, r = E(t, a ?? []), c = await b({ modelTier: s, temperature: n, abortSignal: i });
|
|
334
|
+
return r.pipe(c);
|
|
335
|
+
}, je = async (e) => {
|
|
336
|
+
const { promptText: t, modelTier: s = "default", temperature: n = 0, messages: a, inputVariables: i, abortSignal: r } = e, l = await (await ye({
|
|
312
337
|
promptText: t,
|
|
313
338
|
modelTier: s,
|
|
314
339
|
temperature: n,
|
|
315
|
-
messages:
|
|
316
|
-
|
|
317
|
-
|
|
318
|
-
|
|
319
|
-
|
|
320
|
-
|
|
321
|
-
|
|
322
|
-
|
|
323
|
-
|
|
324
|
-
|
|
325
|
-
|
|
326
|
-
|
|
327
|
-
|
|
340
|
+
messages: a,
|
|
341
|
+
abortSignal: r
|
|
342
|
+
})).invoke(i ?? {});
|
|
343
|
+
if (typeof l == "string")
|
|
344
|
+
return l;
|
|
345
|
+
const m = l.content;
|
|
346
|
+
return typeof m == "string" ? m : JSON.stringify(m);
|
|
347
|
+
}, V = async (e) => {
|
|
348
|
+
const { promptText: t, modelTier: s = "default", temperature: n = 0, messages: a, inputVariables: i, schema: r, abortSignal: c } = e, l = E(t, a ?? []), u = (await b({ modelTier: s, temperature: n, abortSignal: c })).withStructuredOutput(r);
|
|
349
|
+
return await l.pipe(u).invoke(i ?? {});
|
|
350
|
+
}, $e = async (e) => {
|
|
351
|
+
const { promptText: t, modelTier: s = "default", temperature: n = 0, messages: a, inputVariables: i, tools: r, abortSignal: c } = e, l = r.length > 0 ? he(a ?? []) : a ?? [], m = E(t, l), u = await b({ modelTier: s, temperature: n, abortSignal: c });
|
|
352
|
+
return await m.pipe(u.bindTools(r)).invoke(i ?? {});
|
|
353
|
+
}, we = p.object({
|
|
328
354
|
name: p.string(),
|
|
329
355
|
description: p.string(),
|
|
330
356
|
valueType: p.string(),
|
|
331
357
|
alias: p.string()
|
|
332
|
-
}),
|
|
333
|
-
fields: p.array(
|
|
334
|
-
}),
|
|
335
|
-
const s =
|
|
358
|
+
}), be = p.object({
|
|
359
|
+
fields: p.array(we)
|
|
360
|
+
}), z = (e, t) => e.getFieldAlias(t) ?? void 0, S = (e, t) => z(e, t.name) ?? t.alias ?? "", xe = (e, t) => {
|
|
361
|
+
const s = z(e, t.name);
|
|
336
362
|
return !!(s && s !== (t.alias ?? ""));
|
|
337
363
|
};
|
|
338
|
-
function
|
|
364
|
+
function D(e, t) {
|
|
339
365
|
const s = /* @__PURE__ */ new Map();
|
|
340
366
|
for (const n of e.fields) {
|
|
341
|
-
const
|
|
367
|
+
const a = t.fields.find((l) => l.name === n.name), i = S(e, n), r = xe(e, n), c = {
|
|
342
368
|
name: n.name,
|
|
343
369
|
type: n.type,
|
|
344
|
-
alias:
|
|
345
|
-
description:
|
|
346
|
-
valueType:
|
|
370
|
+
alias: r ? i : a?.alias ?? i,
|
|
371
|
+
description: a?.description ?? n.description ?? "",
|
|
372
|
+
valueType: a?.valueType ?? n.valueType ?? "",
|
|
347
373
|
domain: e.getFieldDomain(n.name) ?? void 0
|
|
348
374
|
};
|
|
349
375
|
s.set(n.name, c);
|
|
350
376
|
}
|
|
351
377
|
return s;
|
|
352
378
|
}
|
|
353
|
-
const
|
|
354
|
-
const s = await
|
|
355
|
-
const { name: c, type: l, description: m } =
|
|
356
|
-
return [`Name: ${c}`, `Type: ${l}`, `Alias: ${
|
|
379
|
+
const Ne = async (e) => {
|
|
380
|
+
const s = await I("field_descriptions_prompt"), n = e.fields.filter((r) => !(S(e, r) && r.description)).map((r) => {
|
|
381
|
+
const { name: c, type: l, description: m } = r, u = S(e, r);
|
|
382
|
+
return [`Name: ${c}`, `Type: ${l}`, `Alias: ${u}`, `Description: ${m ?? "N/A"}`].join(", ");
|
|
357
383
|
}).join(`
|
|
358
384
|
`);
|
|
359
385
|
if (n.length === 0)
|
|
360
|
-
return
|
|
361
|
-
const
|
|
386
|
+
return D(e, { fields: [] });
|
|
387
|
+
const a = {
|
|
362
388
|
existingItemTitle: e.portalItem?.title,
|
|
363
389
|
existingItemDescription: e.portalItem?.description,
|
|
364
390
|
existingLayerTitle: e.title,
|
|
365
391
|
existingLayerDescription: e.portalItem?.description,
|
|
366
392
|
fieldInformation: n
|
|
367
|
-
},
|
|
393
|
+
}, i = await V({
|
|
368
394
|
promptText: s,
|
|
369
|
-
schema:
|
|
370
|
-
inputVariables:
|
|
395
|
+
schema: be,
|
|
396
|
+
inputVariables: a
|
|
371
397
|
});
|
|
372
|
-
return
|
|
373
|
-
},
|
|
398
|
+
return D(e, i);
|
|
399
|
+
}, ve = p.object({
|
|
374
400
|
title: p.string(),
|
|
375
401
|
description: p.string(),
|
|
376
402
|
name: p.string().nullable()
|
|
377
|
-
}),
|
|
378
|
-
const n = await
|
|
379
|
-
fieldInformation: JSON.stringify(
|
|
403
|
+
}), Oe = async (e, t) => {
|
|
404
|
+
const n = await I("layer_descriptions_prompt"), a = Array.from(t.values()), i = {
|
|
405
|
+
fieldInformation: JSON.stringify(a, null, 2),
|
|
380
406
|
existingLayerTitle: e.title,
|
|
381
407
|
existingLayerDescription: e.portalItem?.description,
|
|
382
408
|
existingLayerSnippet: e.portalItem?.snippet,
|
|
383
409
|
layerGeometryType: e.geometryType
|
|
384
410
|
};
|
|
385
|
-
return { ...await
|
|
411
|
+
return { ...await V({
|
|
386
412
|
promptText: n,
|
|
387
|
-
schema:
|
|
388
|
-
inputVariables:
|
|
413
|
+
schema: ve,
|
|
414
|
+
inputVariables: i
|
|
389
415
|
}), name: e.title ?? null };
|
|
390
416
|
};
|
|
391
417
|
export {
|
|
392
|
-
|
|
393
|
-
|
|
394
|
-
|
|
395
|
-
|
|
396
|
-
|
|
418
|
+
Fe as D,
|
|
419
|
+
qe as W,
|
|
420
|
+
Oe as a,
|
|
421
|
+
me as b,
|
|
422
|
+
b as c,
|
|
397
423
|
w as d,
|
|
398
|
-
|
|
399
|
-
|
|
400
|
-
|
|
401
|
-
|
|
402
|
-
|
|
403
|
-
|
|
404
|
-
|
|
405
|
-
|
|
406
|
-
|
|
407
|
-
|
|
408
|
-
|
|
409
|
-
|
|
410
|
-
|
|
411
|
-
|
|
412
|
-
|
|
424
|
+
pe as e,
|
|
425
|
+
fe as f,
|
|
426
|
+
Ne as g,
|
|
427
|
+
je as h,
|
|
428
|
+
V as i,
|
|
429
|
+
$e as j,
|
|
430
|
+
ae as k,
|
|
431
|
+
ge as l,
|
|
432
|
+
ue as m,
|
|
433
|
+
De as n,
|
|
434
|
+
Ue as o,
|
|
435
|
+
se as p,
|
|
436
|
+
oe as q,
|
|
437
|
+
Pe as r,
|
|
438
|
+
f as s,
|
|
439
|
+
_e as t
|
|
413
440
|
};
|