@arcgis/ai-components 5.2.0-next.10 → 5.2.0-next.12

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.
Files changed (104) hide show
  1. package/dist/agent-utils/FunctionAgent.d.ts +2 -2
  2. package/dist/agent-utils/LLMAgent.d.ts +2 -2
  3. package/dist/agent-utils/WorkflowAgent.d.ts +2 -2
  4. package/dist/agent-utils/index.d.ts +99 -0
  5. package/dist/agent-utils/index.js +148 -0
  6. package/dist/agent-utils/middlewares/trace.js +25 -33
  7. package/dist/agent-utils/tools/FunctionTool.d.ts +2 -2
  8. package/dist/agent-utils/types.d.ts +30 -1
  9. package/dist/agent-utils/workflows/ConditionalWorkflow.d.ts +2 -2
  10. package/dist/agent-utils/workflows/LoopWorkflow.d.ts +2 -2
  11. package/dist/agent-utils/workflows/ParallelWorkflow.d.ts +2 -2
  12. package/dist/agent-utils/workflows/RouterWorkflow.d.ts +2 -2
  13. package/dist/agent-utils/workflows/SequentialWorkflow.d.ts +2 -2
  14. package/dist/agent-utils/workflows/SwitchWorkflow.d.ts +2 -2
  15. package/dist/cdn/{VMXLYWUK.js → 24QNMEFG.js} +1 -1
  16. package/dist/cdn/{D2N2NSRQ.js → 34SG44C3.js} +1 -1
  17. package/dist/cdn/3JGWGKT6.js +2 -0
  18. package/dist/cdn/{CCY4TSBO.js → 3NBDVZ2I.js} +1 -1
  19. package/dist/cdn/3VOQD2MR.js +2 -0
  20. package/dist/cdn/{BIV2IPHH.js → 53NTYC4I.js} +1 -1
  21. package/dist/cdn/{MODWHY3R.js → 5CV7R5IS.js} +6 -4
  22. package/dist/cdn/{FL4W4VYN.js → 6ZW7Z36F.js} +16 -0
  23. package/dist/cdn/7CYGX4F4.js +2 -0
  24. package/dist/cdn/{2SJAOYZT.js → AZGGTNA3.js} +1 -1
  25. package/dist/cdn/{EGHBXLNG.js → B7WJFBOZ.js} +1 -1
  26. package/dist/cdn/BX7FSMUU.js +56 -0
  27. package/dist/cdn/CHPQM77M.js +181 -0
  28. package/dist/cdn/DHKUXLU3.js +179 -0
  29. package/dist/cdn/DQSEBKOX.js +2 -0
  30. package/dist/cdn/DXVU45KM.js +2 -0
  31. package/dist/cdn/{XER22VYQ.js → DZ2QWNUA.js} +1 -1
  32. package/dist/cdn/EBISDZ5H.js +2 -0
  33. package/dist/cdn/{VNQN5ZQO.js → ERL2CB2Y.js} +5 -5
  34. package/dist/cdn/{SWOXSJ62.js → F6QHMKF5.js} +1 -1
  35. package/dist/cdn/FUIGPHBH.js +2 -0
  36. package/dist/cdn/{CTSALWEP.js → H2CHHGGH.js} +1 -1
  37. package/dist/cdn/{6AWNQHCO.js → HWKDNS4K.js} +1 -1
  38. package/dist/cdn/IMQ4TVHF.js +16 -0
  39. package/dist/cdn/IOD3GDA7.js +2 -0
  40. package/dist/cdn/IR7PTESF.js +2 -0
  41. package/dist/cdn/{EEUCKMU7.js → IRZDTYO2.js} +1 -1
  42. package/dist/cdn/JIWK6QK6.js +2 -0
  43. package/dist/cdn/{EWI4V3GQ.js → JLKGS6Y5.js} +11 -11
  44. package/dist/cdn/K3JCH4XW.js +2 -0
  45. package/dist/cdn/{WIDTPVSU.js → KHXUWZHB.js} +1 -1
  46. package/dist/cdn/LIFK3QSD.js +2 -0
  47. package/dist/cdn/{JOFUPKIB.js → O3EN27N5.js} +1 -1
  48. package/dist/cdn/O3RFFPU3.js +6 -0
  49. package/dist/cdn/P7DG5T3Z.js +9 -0
  50. package/dist/cdn/{OIVRK7HT.js → PBO6FZN6.js} +1 -1
  51. package/dist/cdn/Q3ZW4FYA.js +3 -0
  52. package/dist/cdn/Q6LRANX6.js +2 -0
  53. package/dist/cdn/Q7TL5Q5N.js +2 -0
  54. package/dist/cdn/{KUEOKIQR.js → QCSN44H4.js} +1 -1
  55. package/dist/cdn/R56X6ZKR.js +161 -0
  56. package/dist/cdn/T43LEBBE.js +47 -0
  57. package/dist/cdn/TR4GFL7X.js +2 -0
  58. package/dist/cdn/{D3TNNRP4.js → UPEEHMSY.js} +1 -1
  59. package/dist/cdn/{GTLS44GI.js → WAIFKDR3.js} +1 -1
  60. package/dist/cdn/WNS5ZUF5.js +2 -0
  61. package/dist/cdn/X4XY5HIE.js +2 -0
  62. package/dist/cdn/XOH56EQ2.js +2 -0
  63. package/dist/cdn/{64PJB5NU.js → XON27U6U.js} +1 -1
  64. package/dist/cdn/{DOV5ZJ7M.js → YLN2BZ5J.js} +1 -1
  65. package/dist/cdn/{OBUZ7HBN.js → YUKR4AZW.js} +1 -1
  66. package/dist/cdn/{TSZPHE7L.js → Z2G7MP5L.js} +3 -3
  67. package/dist/cdn/ZEYIBYSF.js +66 -0
  68. package/dist/cdn/agent-utils/index.js +2 -0
  69. package/dist/cdn/agent-utils/middlewares/humanInTheLoop.js +3 -0
  70. package/dist/cdn/agent-utils/middlewares/middleware.js +2 -0
  71. package/dist/cdn/agent-utils/middlewares/trace.js +2 -0
  72. package/dist/cdn/index.js +1 -1
  73. package/dist/chunks/adapter.js +1379 -1307
  74. package/dist/chunks/arcgisKnowledgeGraph.js +109 -72
  75. package/dist/chunks/dataExplorationGraph.js +8 -3
  76. package/dist/chunks/generateLayerDescriptions.js +228 -217
  77. package/dist/chunks/helpGraph.js +14 -11
  78. package/dist/chunks/index.js +11 -0
  79. package/dist/chunks/intent_prompt.js +16 -0
  80. package/dist/chunks/layerStylingGraph.js +25 -22
  81. package/dist/chunks/navigationGraph.js +7 -3
  82. package/dist/chunks/orchestrator.js +9 -8
  83. package/dist/chunks/toolCallResponse.js +5 -3
  84. package/dist/components/arcgis-assistant/customElement.js +1 -0
  85. package/dist/components/arcgis-assistant-data-exploration-agent/customElement.js +1 -0
  86. package/dist/components/arcgis-assistant-help-agent/customElement.js +1 -0
  87. package/dist/components/arcgis-assistant-knowledge-agent/customElement.d.ts +7 -7
  88. package/dist/components/arcgis-assistant-knowledge-agent/customElement.js +1 -0
  89. package/dist/components/arcgis-assistant-layer-styling-agent/customElement.js +1 -0
  90. package/dist/components/arcgis-assistant-navigation-agent/customElement.js +1 -0
  91. package/dist/docs/api.json +1 -1
  92. package/dist/docs/docs.json +1 -1
  93. package/dist/docs/web-types.json +1 -1
  94. package/dist/orchestrator/registry/agentRegistry.d.ts +33 -0
  95. package/dist/utils/index.d.ts +5 -4
  96. package/dist/utils/index.js +48 -47
  97. package/package.json +5 -4
  98. package/dist/cdn/462JBSEV.js +0 -422
  99. package/dist/cdn/ETRWZ3MS.js +0 -108
  100. package/dist/cdn/I6HNBTWY.js +0 -2
  101. package/dist/cdn/JBHNHHWO.js +0 -3
  102. package/dist/cdn/LKRAPK4A.js +0 -165
  103. package/dist/cdn/RVOAPUBN.js +0 -2
  104. 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 d } from "@langchain/langgraph/web";
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 = {
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
- }, A = {
16
+ }, k = {
16
17
  default: "text-embedding-ada-002"
17
18
  }, M = /* @__PURE__ */ new Map();
18
- let v = null;
19
+ let x = null;
19
20
  const te = () => {
20
- const t = k.getDefault().helperServices;
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
- }, q = async (e) => {
25
+ }, U = async (e) => {
25
26
  const t = te();
26
- M.size === 0 && (v || (v = (async () => {
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((i) => M.set(i.name, i));
32
+ (await n.json()).models.forEach((o) => M.set(o.name, o));
32
33
  } catch (n) {
33
- throw v = null, n;
34
+ throw x = null, n;
34
35
  }
35
- })()), await v);
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(P[e]), se = async (e = "default") => await q(A[e]), h = (e, t) => t, j = (e, t) => ({
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
- }), $ = (e = "", t) => {
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 a = n.split(`
53
+ const i = n.split(`
53
54
 
54
55
  `);
55
- return a[a.length - 1]?.trim() === s ? e : `${e}
56
+ return i[i.length - 1]?.trim() === s ? e : `${e}
56
57
 
57
58
  ${s}`;
58
- }, N = () => ({
59
+ }, j = () => ({
59
60
  userRequest: "",
60
61
  assignedTask: "",
61
62
  messages: [],
62
63
  priorSteps: [],
63
64
  sharedState: {}
64
- }), ae = () => ({
65
- agentExecutionContext: d({
66
- reducer: j,
67
- default: N
65
+ }), ie = () => ({
66
+ agentExecutionContext: p({
67
+ reducer: P,
68
+ default: j
68
69
  }),
69
- outputMessage: d({
70
- reducer: $,
70
+ outputMessage: p({
71
+ reducer: _,
71
72
  default: () => ""
72
73
  }),
73
- summary: d({
74
+ summary: p({
74
75
  reducer: h,
75
76
  default: () => ""
76
77
  }),
77
- status: d({
78
+ status: p({
78
79
  reducer: h
79
80
  })
80
- }), De = () => ({
81
- ...ae(),
82
- sharedStatePatch: d({
81
+ }), Pe = () => ({
82
+ ...ie(),
83
+ sharedStatePatch: p({
83
84
  reducer: h
84
85
  })
85
- }), Fe = d.Root({
86
- agentExecutionContext: d({
87
- default: N,
88
- reducer: j
86
+ }), _e = p.Root({
87
+ agentExecutionContext: p({
88
+ default: j,
89
+ reducer: P
89
90
  }),
90
- currentIntent: d({
91
+ currentIntent: p({
91
92
  default: () => "none",
92
93
  reducer: h
93
94
  }),
94
- lastExecutedAgent: d({
95
+ lastExecutedAgent: p({
95
96
  default: () => "",
96
97
  reducer: h
97
98
  }),
98
- requiresFollowUp: d({
99
+ requiresFollowUp: p({
99
100
  default: () => !0,
100
101
  reducer: h
101
102
  }),
102
- stepCount: d({
103
+ stepCount: p({
103
104
  default: () => 0,
104
105
  reducer: (e, t) => t ?? e + 1
105
106
  }),
106
- finalOutputMessage: d({
107
+ finalOutputMessage: p({
107
108
  default: () => "",
108
- reducer: $
109
+ reducer: _
109
110
  })
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) => {
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
- }, oe = (e) => {
116
+ }, re = (e) => {
120
117
  const t = e?.configurable;
121
- return ie(t) ? t : void 0;
122
- }, re = (e, t, s) => {
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((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." : ""))));
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 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) => {
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
- }, 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
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, 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,
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: c,
153
- fetch: O(i.token, n)
159
+ baseURL: o,
160
+ fetch: await N({ config: n })
154
161
  }
155
162
  });
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,
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: O(n.token, t)
170
+ fetch: await N({ config: s })
164
171
  },
165
172
  batchSize: 2048,
166
173
  maxConcurrency: 10
167
174
  });
168
- }, le = o.object({
169
- id: o.string().min(1),
170
- name: o.string().min(1),
171
- description: o.string().min(1)
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
- 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({
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: o.string().nullable(),
179
- requiresFollowUp: o.boolean()
185
+ assignedTask: r.string().nullable(),
186
+ requiresFollowUp: r.boolean()
180
187
  });
181
- }, Pe = async (e, t) => {
182
- const s = oe(t);
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 a = s.services.agentRegistry?.list() ?? [], i = a.map(({ agent: g }) => ({
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 (!i.length)
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 r = await I("intent_prompt"), c = R(i), l = de(i), m = {
204
- registeredAgents: c,
205
- priorSteps: R(e.agentExecutionContext.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 F.fromTemplate(r).format(m), C = G({
208
- model: await b({ modelTier: "fast", abortSignal: s.abortSignal }),
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: l,
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
- Q({
217
- model: await b({ modelTier: "fast", abortSignal: s.abortSignal }),
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
- Y({ runLimit: 2 })
236
+ G({ runLimit: 2 })
224
237
  ]
225
- }), { structuredResponse: L } = await ce({
226
- agent: C,
238
+ }), { structuredResponse: V } = await ce({
239
+ agent: E,
227
240
  messages: e.agentExecutionContext.messages,
228
241
  config: t
229
- }), y = l.parse(
230
- L ?? { intent: null, assignedTask: null, requiresFollowUp: !1 }
231
- ), x = y.intent ?? "none", K = {
242
+ }), y = c.parse(
243
+ V ?? { intent: null, assignedTask: null, requiresFollowUp: !1 }
244
+ ), v = y.intent ?? "none", z = {
232
245
  ...e,
233
- currentIntent: x,
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 (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(", ")}.
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: x,
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 H(g)],
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: ${x}
280
+ text: `Agent picked: ${v}
268
281
  Task Assigned: ${y.assignedTask ?? ""}
269
282
  Requires Follow-Up: ${y.requiresFollowUp}`
270
283
  },
271
284
  t
272
- ), K;
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
- }, pe = "0.1", w = 1536, me = "openai", ue = A.default, ge = `Name: {name}
289
+ }, ge = "0.1", w = 1536, fe = "openai", he = k.default, ye = `Name: {name}
277
290
  Title: {title}
278
- Description: {description}`, fe = `Name: {name}
291
+ Description: {description}`, we = `Name: {name}
279
292
  Alias: {alias}
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)
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: 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, {
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: 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, {
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
- }), he = (e) => {
326
+ }), be = (e) => {
314
327
  const t = /* @__PURE__ */ new Set();
315
328
  for (const n of e)
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);
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 a = n;
325
- return t.has(a.tool_call_id);
337
+ const i = n;
338
+ return t.has(i.tool_call_id);
326
339
  }
327
340
  return !0;
328
341
  });
329
- }, E = (e, t) => {
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({
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: 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({
354
- name: p.string(),
355
- description: p.string(),
356
- valueType: p.string(),
357
- alias: p.string()
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);
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 D(e, t) {
377
+ function R(e, t) {
365
378
  const s = /* @__PURE__ */ new Map();
366
379
  for (const n of e.fields) {
367
- const a = t.fields.find((l) => l.name === n.name), i = S(e, n), r = xe(e, n), c = {
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: r ? i : a?.alias ?? i,
371
- description: a?.description ?? n.description ?? "",
372
- valueType: a?.valueType ?? n.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, c);
388
+ s.set(n.name, d);
376
389
  }
377
390
  return s;
378
391
  }
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(", ");
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 D(e, { fields: [] });
387
- const a = {
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
- }, i = await V({
406
+ }, o = await $({
394
407
  promptText: s,
395
- schema: be,
396
- inputVariables: a
408
+ schema: Te,
409
+ inputVariables: i
397
410
  });
398
- return D(e, i);
399
- }, ve = p.object({
400
- title: p.string(),
401
- description: p.string(),
402
- name: p.string().nullable()
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),
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 V({
424
+ return { ...await $({
412
425
  promptText: n,
413
- schema: ve,
414
- inputVariables: i
426
+ schema: Se,
427
+ inputVariables: o
415
428
  }), name: e.title ?? null };
416
429
  };
417
430
  export {
418
- Fe as D,
419
- qe as W,
420
- Oe as a,
421
- me as b,
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
- 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
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
  };