@arcgis/ai-components 5.2.0-next.10 → 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/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/{VMXLYWUK.js → 24QNMEFG.js} +1 -1
- package/dist/cdn/{D2N2NSRQ.js → 34SG44C3.js} +1 -1
- package/dist/cdn/3JGWGKT6.js +2 -0
- package/dist/cdn/{CCY4TSBO.js → 3NBDVZ2I.js} +1 -1
- package/dist/cdn/3VOQD2MR.js +2 -0
- package/dist/cdn/{BIV2IPHH.js → 53NTYC4I.js} +1 -1
- package/dist/cdn/{MODWHY3R.js → 5CV7R5IS.js} +6 -4
- package/dist/cdn/{FL4W4VYN.js → 6ZW7Z36F.js} +16 -0
- package/dist/cdn/7CYGX4F4.js +2 -0
- package/dist/cdn/{2SJAOYZT.js → AZGGTNA3.js} +1 -1
- package/dist/cdn/{EGHBXLNG.js → B7WJFBOZ.js} +1 -1
- 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/{XER22VYQ.js → DZ2QWNUA.js} +1 -1
- package/dist/cdn/EBISDZ5H.js +2 -0
- package/dist/cdn/{VNQN5ZQO.js → ERL2CB2Y.js} +5 -5
- package/dist/cdn/{SWOXSJ62.js → F6QHMKF5.js} +1 -1
- package/dist/cdn/FUIGPHBH.js +2 -0
- package/dist/cdn/{CTSALWEP.js → H2CHHGGH.js} +1 -1
- package/dist/cdn/{6AWNQHCO.js → HWKDNS4K.js} +1 -1
- package/dist/cdn/IMQ4TVHF.js +16 -0
- package/dist/cdn/IOD3GDA7.js +2 -0
- package/dist/cdn/IR7PTESF.js +2 -0
- package/dist/cdn/{EEUCKMU7.js → IRZDTYO2.js} +1 -1
- package/dist/cdn/JIWK6QK6.js +2 -0
- package/dist/cdn/{EWI4V3GQ.js → JLKGS6Y5.js} +11 -11
- package/dist/cdn/K3JCH4XW.js +2 -0
- package/dist/cdn/{WIDTPVSU.js → KHXUWZHB.js} +1 -1
- package/dist/cdn/LIFK3QSD.js +2 -0
- package/dist/cdn/{JOFUPKIB.js → O3EN27N5.js} +1 -1
- package/dist/cdn/O3RFFPU3.js +6 -0
- package/dist/cdn/P7DG5T3Z.js +9 -0
- package/dist/cdn/{OIVRK7HT.js → PBO6FZN6.js} +1 -1
- package/dist/cdn/Q3ZW4FYA.js +3 -0
- package/dist/cdn/Q6LRANX6.js +2 -0
- package/dist/cdn/Q7TL5Q5N.js +2 -0
- package/dist/cdn/{KUEOKIQR.js → QCSN44H4.js} +1 -1
- package/dist/cdn/R56X6ZKR.js +161 -0
- package/dist/cdn/T43LEBBE.js +47 -0
- package/dist/cdn/TR4GFL7X.js +2 -0
- package/dist/cdn/{D3TNNRP4.js → UPEEHMSY.js} +1 -1
- package/dist/cdn/{GTLS44GI.js → WAIFKDR3.js} +1 -1
- package/dist/cdn/WNS5ZUF5.js +2 -0
- package/dist/cdn/X4XY5HIE.js +2 -0
- package/dist/cdn/XOH56EQ2.js +2 -0
- package/dist/cdn/{64PJB5NU.js → XON27U6U.js} +1 -1
- package/dist/cdn/{DOV5ZJ7M.js → YLN2BZ5J.js} +1 -1
- package/dist/cdn/{OBUZ7HBN.js → YUKR4AZW.js} +1 -1
- package/dist/cdn/{TSZPHE7L.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/chunks/adapter.js +1379 -1307
- package/dist/chunks/arcgisKnowledgeGraph.js +109 -72
- package/dist/chunks/dataExplorationGraph.js +8 -3
- package/dist/chunks/generateLayerDescriptions.js +228 -217
- package/dist/chunks/helpGraph.js +14 -11
- package/dist/chunks/index.js +11 -0
- package/dist/chunks/intent_prompt.js +16 -0
- package/dist/chunks/layerStylingGraph.js +25 -22
- package/dist/chunks/navigationGraph.js +7 -3
- package/dist/chunks/orchestrator.js +9 -8
- package/dist/chunks/toolCallResponse.js +5 -3
- package/dist/components/arcgis-assistant/customElement.js +1 -0
- 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-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-navigation-agent/customElement.js +1 -0
- package/dist/docs/api.json +1 -1
- package/dist/docs/docs.json +1 -1
- package/dist/docs/web-types.json +1 -1
- package/dist/orchestrator/registry/agentRegistry.d.ts +33 -0
- package/dist/utils/index.d.ts +5 -4
- package/dist/utils/index.js +48 -47
- package/package.json +5 -4
- package/dist/cdn/462JBSEV.js +0 -422
- package/dist/cdn/ETRWZ3MS.js +0 -108
- package/dist/cdn/I6HNBTWY.js +0 -2
- package/dist/cdn/JBHNHHWO.js +0 -3
- package/dist/cdn/LKRAPK4A.js +0 -165
- package/dist/cdn/RVOAPUBN.js +0 -2
- package/dist/cdn/VAZNJSKA.js +0 -16
|
@@ -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
|
|
7
|
-
import { createAgent as
|
|
8
|
-
import { ChatOpenAI as
|
|
9
|
-
import
|
|
10
|
-
import
|
|
11
|
-
|
|
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
|
+
import { ChatOpenAI as Q, OpenAIEmbeddings as Y } from "@langchain/openai";
|
|
9
|
+
import F from "@arcgis/core/portal/Portal.js";
|
|
10
|
+
import Z from "@arcgis/core/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
|
+
let x = null;
|
|
19
20
|
const te = () => {
|
|
20
|
-
const t =
|
|
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
|
+
}, U = async (e) => {
|
|
25
26
|
const t = te();
|
|
26
|
-
M.size === 0 && (
|
|
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
|
-
(await n.json()).models.forEach((
|
|
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
|
-
}, ne = async (e = "default") => await q
|
|
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;
|
|
@@ -49,82 +50,78 @@ const te = () => {
|
|
|
49
50
|
return s;
|
|
50
51
|
if (n === s)
|
|
51
52
|
return e;
|
|
52
|
-
const
|
|
53
|
+
const i = n.split(`
|
|
53
54
|
|
|
54
55
|
`);
|
|
55
|
-
return
|
|
56
|
+
return i[i.length - 1]?.trim() === s ? e : `${e}
|
|
56
57
|
|
|
57
58
|
${s}`;
|
|
58
|
-
},
|
|
59
|
+
}, j = () => ({
|
|
59
60
|
userRequest: "",
|
|
60
61
|
assignedTask: "",
|
|
61
62
|
messages: [],
|
|
62
63
|
priorSteps: [],
|
|
63
64
|
sharedState: {}
|
|
64
|
-
}),
|
|
65
|
-
agentExecutionContext:
|
|
66
|
-
reducer:
|
|
67
|
-
default:
|
|
65
|
+
}), ie = () => ({
|
|
66
|
+
agentExecutionContext: p({
|
|
67
|
+
reducer: P,
|
|
68
|
+
default: j
|
|
68
69
|
}),
|
|
69
|
-
outputMessage:
|
|
70
|
-
reducer:
|
|
70
|
+
outputMessage: p({
|
|
71
|
+
reducer: _,
|
|
71
72
|
default: () => ""
|
|
72
73
|
}),
|
|
73
|
-
summary:
|
|
74
|
+
summary: p({
|
|
74
75
|
reducer: h,
|
|
75
76
|
default: () => ""
|
|
76
77
|
}),
|
|
77
|
-
status:
|
|
78
|
+
status: p({
|
|
78
79
|
reducer: h
|
|
79
80
|
})
|
|
80
|
-
}),
|
|
81
|
-
...
|
|
82
|
-
sharedStatePatch:
|
|
81
|
+
}), Pe = () => ({
|
|
82
|
+
...ie(),
|
|
83
|
+
sharedStatePatch: p({
|
|
83
84
|
reducer: h
|
|
84
85
|
})
|
|
85
|
-
}),
|
|
86
|
-
agentExecutionContext:
|
|
87
|
-
default:
|
|
88
|
-
reducer:
|
|
86
|
+
}), _e = p.Root({
|
|
87
|
+
agentExecutionContext: p({
|
|
88
|
+
default: j,
|
|
89
|
+
reducer: P
|
|
89
90
|
}),
|
|
90
|
-
currentIntent:
|
|
91
|
+
currentIntent: p({
|
|
91
92
|
default: () => "none",
|
|
92
93
|
reducer: h
|
|
93
94
|
}),
|
|
94
|
-
lastExecutedAgent:
|
|
95
|
+
lastExecutedAgent: p({
|
|
95
96
|
default: () => "",
|
|
96
97
|
reducer: h
|
|
97
98
|
}),
|
|
98
|
-
requiresFollowUp:
|
|
99
|
+
requiresFollowUp: p({
|
|
99
100
|
default: () => !0,
|
|
100
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
|
-
await U("trace_message", e, t);
|
|
112
|
-
}, Ue = async (e, t) => {
|
|
113
|
-
await U("graph_ux_suggestion", e, t);
|
|
114
|
-
}, ie = (e) => {
|
|
111
|
+
}), oe = (e) => {
|
|
115
112
|
if (!e || typeof e != "object" || !("services" in e))
|
|
116
113
|
return !1;
|
|
117
114
|
const t = e.services;
|
|
118
115
|
return !!t && typeof t == "object" && "agentRegistry" in t;
|
|
119
|
-
},
|
|
116
|
+
}, re = (e) => {
|
|
120
117
|
const t = e?.configurable;
|
|
121
|
-
return
|
|
122
|
-
},
|
|
118
|
+
return oe(t) ? t : void 0;
|
|
119
|
+
}, ae = (e, t, s) => {
|
|
123
120
|
const n = e[t];
|
|
124
|
-
return n ? typeof n == "function" ? n() : Promise.resolve(n) : new Promise((
|
|
125
|
-
(typeof queueMicrotask == "function" ? queueMicrotask : setTimeout)(
|
|
121
|
+
return n ? typeof n == "function" ? n() : Promise.resolve(n) : new Promise((i, o) => {
|
|
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." : ""))));
|
|
126
123
|
});
|
|
127
|
-
}, I = async (e) => (await
|
|
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) => {
|
|
128
125
|
const { agent: t, messages: s, config: n } = e;
|
|
129
126
|
return { structuredResponse: (await t.invoke(
|
|
130
127
|
{
|
|
@@ -132,54 +129,64 @@ ${s}`;
|
|
|
132
129
|
},
|
|
133
130
|
n
|
|
134
131
|
)).structuredResponse };
|
|
135
|
-
},
|
|
136
|
-
const
|
|
137
|
-
|
|
138
|
-
|
|
139
|
-
|
|
140
|
-
|
|
141
|
-
|
|
142
|
-
|
|
143
|
-
});
|
|
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
|
+
};
|
|
144
151
|
}, b = async (e = {}) => {
|
|
145
|
-
const { modelTier: t = "default", temperature: s = 0,
|
|
146
|
-
return new
|
|
147
|
-
modelName:
|
|
152
|
+
const { modelTier: t = "default", temperature: s = 0, config: n } = e, i = q[t], o = await ne(t);
|
|
153
|
+
return new Q({
|
|
154
|
+
modelName: i,
|
|
148
155
|
apiKey: "dummy-key",
|
|
149
156
|
// 5-mini does not support temperature parameter
|
|
150
157
|
...t !== "default" && { temperature: s },
|
|
151
158
|
configuration: {
|
|
152
|
-
baseURL:
|
|
153
|
-
fetch:
|
|
159
|
+
baseURL: o,
|
|
160
|
+
fetch: await N({ config: n })
|
|
154
161
|
}
|
|
155
162
|
});
|
|
156
|
-
},
|
|
157
|
-
const
|
|
158
|
-
return new
|
|
159
|
-
modelName:
|
|
163
|
+
}, je = async (e = {}) => {
|
|
164
|
+
const { tier: t = "default", config: s } = e, n = k[t], i = await se(t);
|
|
165
|
+
return new Y({
|
|
166
|
+
modelName: n,
|
|
160
167
|
apiKey: "dummy-key",
|
|
161
168
|
configuration: {
|
|
162
169
|
baseURL: i,
|
|
163
|
-
fetch:
|
|
170
|
+
fetch: await N({ config: s })
|
|
164
171
|
},
|
|
165
172
|
batchSize: 2048,
|
|
166
173
|
maxConcurrency: 10
|
|
167
174
|
});
|
|
168
|
-
},
|
|
169
|
-
id:
|
|
170
|
-
name:
|
|
171
|
-
description:
|
|
175
|
+
}, me = r.object({
|
|
176
|
+
id: r.string().min(1),
|
|
177
|
+
name: r.string().min(1),
|
|
178
|
+
description: r.string().min(1)
|
|
172
179
|
});
|
|
173
|
-
|
|
174
|
-
const
|
|
175
|
-
const t = e.map((n) => n.id), s =
|
|
176
|
-
return
|
|
180
|
+
r.array(me);
|
|
181
|
+
const C = (e) => JSON.stringify(e, null, 2), ue = (e) => {
|
|
182
|
+
const t = e.map((n) => n.id), s = r.enum(t);
|
|
183
|
+
return r.object({
|
|
177
184
|
intent: s.nullable(),
|
|
178
|
-
assignedTask:
|
|
179
|
-
requiresFollowUp:
|
|
185
|
+
assignedTask: r.string().nullable(),
|
|
186
|
+
requiresFollowUp: r.boolean()
|
|
180
187
|
});
|
|
181
|
-
},
|
|
182
|
-
const s =
|
|
188
|
+
}, Ne = async (e, t) => {
|
|
189
|
+
const s = re(t);
|
|
183
190
|
if (s.abortSignal?.aborted)
|
|
184
191
|
return await f({ text: "Run cancelled; skipping intent routing" }, t), {
|
|
185
192
|
...e,
|
|
@@ -189,67 +196,73 @@ const R = (e) => JSON.stringify(e, null, 2), de = (e) => {
|
|
|
189
196
|
};
|
|
190
197
|
try {
|
|
191
198
|
await f({ text: "Asking LLM to route to an agent" }, t);
|
|
192
|
-
const
|
|
199
|
+
const i = s.services.agentRegistry?.list() ?? [], o = i.map(({ agent: g }) => ({
|
|
193
200
|
id: g.id,
|
|
194
201
|
name: g.name,
|
|
195
202
|
description: g.description
|
|
196
203
|
}));
|
|
197
|
-
if (!
|
|
204
|
+
if (!o.length)
|
|
198
205
|
return await f({ text: "No agents registered; skipping intent detection" }, t), {
|
|
199
206
|
...e,
|
|
200
207
|
currentIntent: "none",
|
|
201
208
|
finalOutputMessage: "No agents registered; skipping intent detection."
|
|
202
209
|
};
|
|
203
|
-
const
|
|
204
|
-
registeredAgents:
|
|
205
|
-
priorSteps:
|
|
210
|
+
const a = await I("intent_prompt"), d = C(o), c = ue(o), l = {
|
|
211
|
+
registeredAgents: d,
|
|
212
|
+
priorSteps: C(e.agentExecutionContext.priorSteps),
|
|
206
213
|
userRequest: e.agentExecutionContext.userRequest
|
|
207
|
-
}, T = await
|
|
208
|
-
model: await b({
|
|
214
|
+
}, T = await D.fromTemplate(a).format(l), E = H({
|
|
215
|
+
model: await b({
|
|
216
|
+
modelTier: "fast",
|
|
217
|
+
config: t
|
|
218
|
+
}),
|
|
209
219
|
tools: [],
|
|
210
220
|
systemPrompt: T,
|
|
211
|
-
responseFormat:
|
|
221
|
+
responseFormat: c,
|
|
212
222
|
middleware: [
|
|
213
223
|
// Preserve recent conversation context while summarizing older messages
|
|
214
224
|
// to control token usage without losing important intent signals.
|
|
215
225
|
// The trigger and keep parameters can be tuned based on token limits and behavior.
|
|
216
|
-
|
|
217
|
-
model: await b({
|
|
226
|
+
J({
|
|
227
|
+
model: await b({
|
|
228
|
+
modelTier: "fast",
|
|
229
|
+
config: t
|
|
230
|
+
}),
|
|
218
231
|
trigger: { tokens: 4e3 },
|
|
219
232
|
keep: { messages: 6 }
|
|
220
233
|
}),
|
|
221
234
|
// Enforce no loop/retry.
|
|
222
235
|
// 1 usual LLM call and 1 optional summarization call.
|
|
223
|
-
|
|
236
|
+
G({ runLimit: 2 })
|
|
224
237
|
]
|
|
225
|
-
}), { structuredResponse:
|
|
226
|
-
agent:
|
|
238
|
+
}), { structuredResponse: V } = await ce({
|
|
239
|
+
agent: E,
|
|
227
240
|
messages: e.agentExecutionContext.messages,
|
|
228
241
|
config: t
|
|
229
|
-
}), y =
|
|
230
|
-
|
|
231
|
-
),
|
|
242
|
+
}), y = c.parse(
|
|
243
|
+
V ?? { intent: null, assignedTask: null, requiresFollowUp: !1 }
|
|
244
|
+
), v = y.intent ?? "none", z = {
|
|
232
245
|
...e,
|
|
233
|
-
currentIntent:
|
|
246
|
+
currentIntent: v,
|
|
234
247
|
requiresFollowUp: y.requiresFollowUp,
|
|
235
248
|
agentExecutionContext: {
|
|
236
249
|
...e.agentExecutionContext,
|
|
237
250
|
assignedTask: y.assignedTask ?? ""
|
|
238
251
|
}
|
|
239
252
|
};
|
|
240
|
-
if (
|
|
241
|
-
const g = `I could not find an agent that can handle that request. I have access to the following agents: ${
|
|
253
|
+
if (v === "none") {
|
|
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(", ")}.
|
|
242
255
|
|
|
243
256
|
Please ask a question that can be answered by one of these agents.`;
|
|
244
257
|
return await f({ text: "LLM did not identify a clear intent." }, t), {
|
|
245
258
|
...e,
|
|
246
|
-
currentIntent:
|
|
259
|
+
currentIntent: v,
|
|
247
260
|
requiresFollowUp: !1,
|
|
248
261
|
finalOutputMessage: g,
|
|
249
262
|
agentExecutionContext: {
|
|
250
263
|
...e.agentExecutionContext,
|
|
251
264
|
assignedTask: "",
|
|
252
|
-
messages: [...e.agentExecutionContext.messages, new
|
|
265
|
+
messages: [...e.agentExecutionContext.messages, new B(g)],
|
|
253
266
|
priorSteps: [
|
|
254
267
|
...e.agentExecutionContext.priorSteps ?? [],
|
|
255
268
|
{
|
|
@@ -264,177 +277,175 @@ Please ask a question that can be answered by one of these agents.`;
|
|
|
264
277
|
}
|
|
265
278
|
return await f(
|
|
266
279
|
{
|
|
267
|
-
text: `Agent picked: ${
|
|
280
|
+
text: `Agent picked: ${v}
|
|
268
281
|
Task Assigned: ${y.assignedTask ?? ""}
|
|
269
282
|
Requires Follow-Up: ${y.requiresFollowUp}`
|
|
270
283
|
},
|
|
271
284
|
t
|
|
272
|
-
),
|
|
285
|
+
), z;
|
|
273
286
|
} catch (n) {
|
|
274
287
|
throw await f({ text: "Error during intent detection" }, t), new Error(`Error during intent detection: ${n instanceof Error ? n.message : String(n)}`);
|
|
275
288
|
}
|
|
276
|
-
},
|
|
289
|
+
}, ge = "0.1", w = 1536, fe = "openai", he = k.default, ye = `Name: {name}
|
|
277
290
|
Title: {title}
|
|
278
|
-
Description: {description}`,
|
|
291
|
+
Description: {description}`, we = `Name: {name}
|
|
279
292
|
Alias: {alias}
|
|
280
|
-
Description: {description}`,
|
|
281
|
-
schemaVersion:
|
|
282
|
-
modified:
|
|
283
|
-
embeddings:
|
|
284
|
-
modelProvider:
|
|
285
|
-
model:
|
|
286
|
-
dimensions:
|
|
287
|
-
templates:
|
|
288
|
-
layer:
|
|
289
|
-
field:
|
|
293
|
+
Description: {description}`, $e = r.object({
|
|
294
|
+
schemaVersion: r.literal(ge),
|
|
295
|
+
modified: r.number().int().nonnegative(),
|
|
296
|
+
embeddings: r.object({
|
|
297
|
+
modelProvider: r.literal(fe),
|
|
298
|
+
model: r.literal(he),
|
|
299
|
+
dimensions: r.literal(w),
|
|
300
|
+
templates: r.object({
|
|
301
|
+
layer: r.string().default(ye),
|
|
302
|
+
field: r.string().default(we)
|
|
290
303
|
})
|
|
291
304
|
}),
|
|
292
|
-
layers:
|
|
293
|
-
|
|
294
|
-
id:
|
|
295
|
-
name:
|
|
296
|
-
title:
|
|
297
|
-
description:
|
|
298
|
-
vector:
|
|
305
|
+
layers: r.array(
|
|
306
|
+
r.object({
|
|
307
|
+
id: r.string().min(1),
|
|
308
|
+
name: r.string().min(1),
|
|
309
|
+
title: r.string().catch(""),
|
|
310
|
+
description: r.string().catch(""),
|
|
311
|
+
vector: r.array(r.number()).length(w, {
|
|
299
312
|
message: `Layer vector must be exactly ${w} dimensions`
|
|
300
313
|
}),
|
|
301
|
-
fields:
|
|
302
|
-
|
|
303
|
-
name:
|
|
304
|
-
alias:
|
|
305
|
-
description:
|
|
306
|
-
vector:
|
|
314
|
+
fields: r.array(
|
|
315
|
+
r.object({
|
|
316
|
+
name: r.string().min(1),
|
|
317
|
+
alias: r.string().catch(""),
|
|
318
|
+
description: r.string().catch(""),
|
|
319
|
+
vector: r.array(r.number()).length(w, {
|
|
307
320
|
message: `Field vector must be exactly ${w} dimensions`
|
|
308
321
|
})
|
|
309
322
|
})
|
|
310
323
|
)
|
|
311
324
|
})
|
|
312
325
|
).default([])
|
|
313
|
-
}),
|
|
326
|
+
}), be = (e) => {
|
|
314
327
|
const t = /* @__PURE__ */ new Set();
|
|
315
328
|
for (const n of e)
|
|
316
|
-
if (
|
|
317
|
-
const
|
|
318
|
-
|
|
319
|
-
|
|
329
|
+
if (W(n)) {
|
|
330
|
+
const i = n;
|
|
331
|
+
i.tool_calls && i.tool_calls.length > 0 && i.tool_calls.forEach((o) => {
|
|
332
|
+
o.id && t.add(o.id);
|
|
320
333
|
});
|
|
321
334
|
}
|
|
322
335
|
return e.filter((n) => {
|
|
323
336
|
if (X(n)) {
|
|
324
|
-
const
|
|
325
|
-
return t.has(
|
|
337
|
+
const i = n;
|
|
338
|
+
return t.has(i.tool_call_id);
|
|
326
339
|
}
|
|
327
340
|
return !0;
|
|
328
341
|
});
|
|
329
|
-
},
|
|
330
|
-
const s =
|
|
331
|
-
return
|
|
332
|
-
},
|
|
333
|
-
const { promptText: t, modelTier: s, temperature: n, messages:
|
|
334
|
-
return
|
|
335
|
-
},
|
|
336
|
-
const { promptText: t, modelTier: s = "default", temperature: n = 0, messages:
|
|
342
|
+
}, A = (e, t) => {
|
|
343
|
+
const s = K.fromTemplate(e);
|
|
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({
|
|
337
350
|
promptText: t,
|
|
338
351
|
modelTier: s,
|
|
339
352
|
temperature: n,
|
|
340
|
-
messages:
|
|
341
|
-
|
|
342
|
-
})).invoke(
|
|
343
|
-
if (typeof
|
|
344
|
-
return
|
|
345
|
-
const
|
|
346
|
-
return typeof
|
|
347
|
-
},
|
|
348
|
-
const { promptText: t, modelTier: s = "default", temperature: n = 0, messages:
|
|
349
|
-
return await
|
|
350
|
-
},
|
|
351
|
-
const { promptText: t, modelTier: s = "default", temperature: n = 0, messages:
|
|
352
|
-
return await
|
|
353
|
-
},
|
|
354
|
-
name:
|
|
355
|
-
description:
|
|
356
|
-
valueType:
|
|
357
|
-
alias:
|
|
358
|
-
}),
|
|
359
|
-
fields:
|
|
360
|
-
}),
|
|
361
|
-
const s =
|
|
353
|
+
messages: i,
|
|
354
|
+
config: a
|
|
355
|
+
})).invoke(o ?? {});
|
|
356
|
+
if (typeof c == "string")
|
|
357
|
+
return c;
|
|
358
|
+
const l = c.content;
|
|
359
|
+
return typeof l == "string" ? l : JSON.stringify(l);
|
|
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);
|
|
362
375
|
return !!(s && s !== (t.alias ?? ""));
|
|
363
376
|
};
|
|
364
|
-
function
|
|
377
|
+
function R(e, t) {
|
|
365
378
|
const s = /* @__PURE__ */ new Map();
|
|
366
379
|
for (const n of e.fields) {
|
|
367
|
-
const
|
|
380
|
+
const i = t.fields.find((c) => c.name === n.name), o = S(e, n), a = Me(e, n), d = {
|
|
368
381
|
name: n.name,
|
|
369
382
|
type: n.type,
|
|
370
|
-
alias:
|
|
371
|
-
description:
|
|
372
|
-
valueType:
|
|
383
|
+
alias: a ? o : i?.alias ?? o,
|
|
384
|
+
description: i?.description ?? n.description ?? "",
|
|
385
|
+
valueType: i?.valueType ?? n.valueType ?? "",
|
|
373
386
|
domain: e.getFieldDomain(n.name) ?? void 0
|
|
374
387
|
};
|
|
375
|
-
s.set(n.name,
|
|
388
|
+
s.set(n.name, d);
|
|
376
389
|
}
|
|
377
390
|
return s;
|
|
378
391
|
}
|
|
379
|
-
const
|
|
380
|
-
const s = await I("field_descriptions_prompt"), n = e.fields.filter((
|
|
381
|
-
const { name:
|
|
382
|
-
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(", ");
|
|
383
396
|
}).join(`
|
|
384
397
|
`);
|
|
385
398
|
if (n.length === 0)
|
|
386
|
-
return
|
|
387
|
-
const
|
|
399
|
+
return R(e, { fields: [] });
|
|
400
|
+
const i = {
|
|
388
401
|
existingItemTitle: e.portalItem?.title,
|
|
389
402
|
existingItemDescription: e.portalItem?.description,
|
|
390
403
|
existingLayerTitle: e.title,
|
|
391
404
|
existingLayerDescription: e.portalItem?.description,
|
|
392
405
|
fieldInformation: n
|
|
393
|
-
},
|
|
406
|
+
}, o = await $({
|
|
394
407
|
promptText: s,
|
|
395
|
-
schema:
|
|
396
|
-
inputVariables:
|
|
408
|
+
schema: Te,
|
|
409
|
+
inputVariables: i
|
|
397
410
|
});
|
|
398
|
-
return
|
|
399
|
-
},
|
|
400
|
-
title:
|
|
401
|
-
description:
|
|
402
|
-
name:
|
|
403
|
-
}),
|
|
404
|
-
const n = await I("layer_descriptions_prompt"),
|
|
405
|
-
fieldInformation: JSON.stringify(
|
|
411
|
+
return R(e, o);
|
|
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 = {
|
|
418
|
+
fieldInformation: JSON.stringify(i, null, 2),
|
|
406
419
|
existingLayerTitle: e.title,
|
|
407
420
|
existingLayerDescription: e.portalItem?.description,
|
|
408
421
|
existingLayerSnippet: e.portalItem?.snippet,
|
|
409
422
|
layerGeometryType: e.geometryType
|
|
410
423
|
};
|
|
411
|
-
return { ...await
|
|
424
|
+
return { ...await $({
|
|
412
425
|
promptText: n,
|
|
413
|
-
schema:
|
|
414
|
-
inputVariables:
|
|
426
|
+
schema: Se,
|
|
427
|
+
inputVariables: o
|
|
415
428
|
}), name: e.title ?? null };
|
|
416
429
|
};
|
|
417
430
|
export {
|
|
418
|
-
|
|
419
|
-
|
|
420
|
-
|
|
421
|
-
|
|
431
|
+
_e as D,
|
|
432
|
+
$e as W,
|
|
433
|
+
Le as a,
|
|
434
|
+
fe as b,
|
|
422
435
|
b as c,
|
|
423
436
|
w as d,
|
|
424
|
-
|
|
425
|
-
|
|
426
|
-
|
|
427
|
-
|
|
428
|
-
|
|
429
|
-
|
|
430
|
-
|
|
431
|
-
|
|
432
|
-
|
|
433
|
-
|
|
434
|
-
|
|
435
|
-
|
|
436
|
-
|
|
437
|
-
|
|
438
|
-
f as s,
|
|
439
|
-
_e as t
|
|
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
|
|
440
451
|
};
|