@arcgis/ai-agents 5.1.0-next.102 → 5.1.0-next.104

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.
@@ -1,4 +1,4 @@
1
1
  import { default as LinkChartView } from '@arcgis/core/views/LinkChartView.js';
2
2
  import { default as MapView } from '@arcgis/core/views/MapView.js';
3
3
  export declare function isMapValid(mapView: MapView): void;
4
- export declare function isMapView(view: LinkChartView | MapView | undefined): boolean;
4
+ export declare function isMapView(view: LinkChartView | MapView | undefined): view is MapView;
package/dist/index.js CHANGED
@@ -1,24 +1,24 @@
1
- import { Annotation as v, StateGraph as W, START as U, END as C, messagesStateReducer as ke, NodeInterrupt as it } from "@langchain/langgraph/web";
2
- import { createAgentRuntimeStateWithSharedState as lt, invokeToolPrompt as P, sendTraceMessage as m, invokeStructuredPrompt as Fe, createAgentRuntimeState as ee, invokeTextPrompt as qe, sendUXSuggestion as k } from "@arcgis/ai-orchestrator";
1
+ import { Annotation as v, StateGraph as W, START as U, END as C, messagesStateReducer as ke, NodeInterrupt as lt } from "@langchain/langgraph/web";
2
+ import { createAgentRuntimeStateWithSharedState as ct, invokeToolPrompt as P, sendTraceMessage as m, invokeStructuredPrompt as Fe, createAgentRuntimeState as ee, invokeTextPrompt as qe, sendUXSuggestion as k } from "@arcgis/ai-orchestrator";
3
3
  import { tool as b } from "@langchain/core/tools";
4
- import ct from "@arcgis/core/Graphic.js";
5
- import dt from "@arcgis/core/symbols/PictureMarkerSymbol.js";
6
- import { addressToLocations as ut } from "@arcgis/core/rest/locator.js";
4
+ import dt from "@arcgis/core/Graphic.js";
5
+ import ut from "@arcgis/core/symbols/PictureMarkerSymbol.js";
6
+ import { addressToLocations as pt } from "@arcgis/core/rest/locator.js";
7
7
  import _ from "@arcgis/core/portal/Portal.js";
8
8
  import oe from "@arcgis/core/config.js";
9
9
  import l, { z as I } from "zod";
10
- import pt from "@arcgis/core/geometry/Extent.js";
11
- import Le from "@arcgis/core/geometry/Point.js";
10
+ import Le from "@arcgis/core/geometry/Extent.js";
11
+ import Ie from "@arcgis/core/geometry/Point.js";
12
12
  import { ToolNode as G } from "@langchain/langgraph/prebuilt";
13
13
  import ht from "@arcgis/core/layers/support/FeatureEffect.js";
14
- import Ie from "@arcgis/core/layers/support/FeatureFilter.js";
14
+ import Ne from "@arcgis/core/layers/support/FeatureFilter.js";
15
15
  import * as mt from "@arcgis/core/geometry/operators/unionOperator.js";
16
16
  import { formatDateOnly as yt, convertDateFormatToIntlOptions as Z, formatTimeOnly as gt, formatDate as fe } from "@arcgis/core/intl.js";
17
- import Ne from "@arcgis/core/smartMapping/statistics/summaryStatistics.js";
18
- import Ae from "@arcgis/core/smartMapping/statistics/uniqueValues.js";
17
+ import Ae from "@arcgis/core/smartMapping/statistics/summaryStatistics.js";
18
+ import Me from "@arcgis/core/smartMapping/statistics/uniqueValues.js";
19
19
  import ft from "@arcgis/core/rest/support/TopFeaturesQuery.js";
20
20
  import wt from "@arcgis/core/rest/support/TopFilter.js";
21
- import { AIMessage as Me } from "@langchain/core/messages";
21
+ import { AIMessage as ze } from "@langchain/core/messages";
22
22
  import { createRenderer as bt } from "@arcgis/core/smartMapping/renderers/pieChart.js";
23
23
  import { getSchemesByTag as St, getSchemes as vt } from "@arcgis/core/smartMapping/symbology/pieChart.js";
24
24
  import { getBackgroundColorTheme as we } from "@arcgis/core/views/support/colorUtils.js";
@@ -39,12 +39,12 @@ import { getSchemesByTag as zt } from "@arcgis/core/smartMapping/symbology/type.
39
39
  import "@arcgis/core/views/LinkChartView.js";
40
40
  import { fetchKnowledgeGraph as be, executeQueryStreaming as _t, executeSearchStreaming as Dt } from "@arcgis/core/rest/knowledgeGraphService.js";
41
41
  import jt from "@arcgis/core/rest/knowledgeGraph/GraphSearchStreaming.js";
42
- import ze from "@arcgis/core/rest/knowledgeGraph/GraphQueryStreaming.js";
42
+ import _e from "@arcgis/core/rest/knowledgeGraph/GraphQueryStreaming.js";
43
43
  import Se from "@arcgis/core/request.js";
44
44
  import ve from "@arcgis/core/identity/IdentityManager.js";
45
45
  import Pt from "@arcgis/core/WebLinkChart.js";
46
- const V = (e, t) => t ?? e, _e = v.Root({
47
- ...lt(),
46
+ const V = (e, t) => t ?? e, De = v.Root({
47
+ ...ct(),
48
48
  // internal to the navigation agent
49
49
  intent: v({
50
50
  reducer: V
@@ -67,17 +67,17 @@ async function Gt(e, t) {
67
67
  const a = _.getDefault().helperServices, o = a.geocode.find((y) => y.name === "ArcGIS World Geocoding Service") ?? a.geocode[0];
68
68
  if (!o)
69
69
  throw new Error("No geocoding service found in helperServices.");
70
- const n = o.url, s = `${oe.assetsPath?.endsWith("/") ? oe.assetsPath : `${oe.assetsPath}/`}esri/images/search/search-symbol-32.png`, c = (await ut(n, {
70
+ const n = o.url, s = `${oe.assetsPath?.endsWith("/") ? oe.assetsPath : `${oe.assetsPath}/`}esri/images/search/search-symbol-32.png`, c = (await pt(n, {
71
71
  address: { SingleLine: e },
72
72
  outFields: ["Match_addr"]
73
73
  }))?.[0];
74
74
  if (!c?.extent || !c.location)
75
75
  throw new Error(`Could not find location for: ${e}`);
76
- const d = new dt({
76
+ const d = new ut({
77
77
  url: s,
78
78
  width: 24,
79
79
  height: 24
80
- }), u = new ct({
80
+ }), u = new dt({
81
81
  geometry: c.location,
82
82
  symbol: d
83
83
  });
@@ -172,7 +172,7 @@ const Yt = I.object({
172
172
  schema: Yt
173
173
  });
174
174
  async function er(e) {
175
- const r = new pt({
175
+ const r = new Le({
176
176
  xmin: -180,
177
177
  ymin: -90,
178
178
  xmax: 180,
@@ -242,7 +242,7 @@ const mr = l.object({
242
242
  });
243
243
  async function gr(e, t, r) {
244
244
  const o = {
245
- target: new Le({
245
+ target: new Ie({
246
246
  longitude: e.longitude,
247
247
  latitude: e.latitude,
248
248
  spatialReference: { wkid: 4326 }
@@ -531,7 +531,7 @@ ${d.results.map((u) => ` - ${u.name} (${u.score.toFixed(2)})`).join(`
531
531
  if (!o?.[n])
532
532
  throw new Error(`${t} requires services.${n} to be available.`);
533
533
  return r;
534
- }, Ir = (e, t) => B(["layerSearch", "layersAndFieldsRegistry"], "Navigation Agent")(e, t), Nr = () => new W(_e).addNode("requireNavigationServices", Ir).addNode("intentLLM", Cr).addNode("vectorSearchLayers", Fr).addNode("vectorSearchFields", Lr).addNode("agent", Er).addNode("tools", $r).addEdge(U, "requireNavigationServices").addEdge("requireNavigationServices", "intentLLM").addConditionalEdges(
534
+ }, Ir = (e, t) => B(["layerSearch", "layersAndFieldsRegistry"], "Navigation Agent")(e, t), Nr = () => new W(De).addNode("requireNavigationServices", Ir).addNode("intentLLM", Cr).addNode("vectorSearchLayers", Fr).addNode("vectorSearchFields", Lr).addNode("agent", Er).addNode("tools", $r).addEdge(U, "requireNavigationServices").addEdge("requireNavigationServices", "intentLLM").addConditionalEdges(
535
535
  "intentLLM",
536
536
  (t) => t.intent === "goToLayer" || t.intent === "goToFeatures" ? "vectorSearchLayers" : "agent",
537
537
  {
@@ -569,8 +569,8 @@ ${d.results.map((u) => ` - ${u.name} (${u.score.toFixed(2)})`).join(`
569
569
  name: "Navigation Agent",
570
570
  description: Ar,
571
571
  createGraph: Nr,
572
- workspace: _e
573
- }, De = v.Root({
572
+ workspace: De
573
+ }, je = v.Root({
574
574
  ...ee(),
575
575
  vectorSearchLayerIds: v(),
576
576
  vectorSearchFieldResults: v(),
@@ -642,7 +642,7 @@ function Q(e) {
642
642
  const te = async (e, t) => {
643
643
  if (Y(e)) {
644
644
  const { point: r } = e;
645
- return { geometry: new Le({
645
+ return { geometry: new Ie({
646
646
  x: r.x,
647
647
  y: r.y,
648
648
  spatialReference: r.spatialReference ? { wkid: r.spatialReference.wkid } : t.spatialReference
@@ -715,7 +715,7 @@ const te = async (e, t) => {
715
715
  i = p.geometry;
716
716
  }
717
717
  if (s.featureEffect = null, s.featureEffect = new ht({
718
- filter: new Ie({
718
+ filter: new Ne({
719
719
  ...e.objectIds?.length ? { objectIds: e.objectIds } : { where: e.where },
720
720
  geometry: i,
721
721
  spatialRelationship: "intersects",
@@ -794,7 +794,7 @@ const te = async (e, t) => {
794
794
  return e;
795
795
  const t = ie(e);
796
796
  return t ? t.toISOString().slice(0, 10) : null;
797
- }, je = () => {
797
+ }, Pe = () => {
798
798
  const e = (/* @__PURE__ */ new Date()).getTimezoneOffset(), t = e <= 0 ? "+" : "-", r = Math.floor(Math.abs(e) / 60).toString().padStart(2, "0"), a = (Math.abs(e) % 60).toString().padStart(2, "0"), o = `${t}${r}:${a}`;
799
799
  return { userTimezone: Intl.DateTimeFormat().resolvedOptions().timeZone, userTimezoneOffset: o };
800
800
  }, Xr = (e, t, r) => {
@@ -817,7 +817,7 @@ const te = async (e, t) => {
817
817
  ...Z("short-date-short-time"),
818
818
  timeZone: Jr(r)
819
819
  }) : e;
820
- }, Pe = (e, t, r) => {
820
+ }, Ge = (e, t, r) => {
821
821
  if (e && typeof e != "function") {
822
822
  const a = "getField" in r && r.getField?.(e), o = a && "getFieldDomain" in r && r.getFieldDomain ? r.getFieldDomain(a.name) : null;
823
823
  if (o?.type === "coded-value") {
@@ -859,15 +859,15 @@ const te = async (e, t) => {
859
859
  } catch {
860
860
  return e;
861
861
  }
862
- }, Ge = (e, t) => e.getFieldAlias?.(t) ?? e.fieldsIndex?.get(t)?.alias ?? e.fieldsIndex?.get(t)?.name ?? t, Oe = (e, t, r, a, o) => {
862
+ }, Oe = (e, t) => e.getFieldAlias?.(t) ?? e.fieldsIndex?.get(t)?.alias ?? e.fieldsIndex?.get(t)?.name ?? t, Ve = (e, t, r, a, o) => {
863
863
  if (r == null)
864
864
  return r;
865
865
  const s = e.getFieldConfiguration?.(t)?.fieldFormat;
866
866
  return s?.type === "number" ? ra(r, s) : s?.type === "date-time" ? aa(r, s, o) : Xr(r, a, o);
867
867
  }, oa = (e, t, r, a) => {
868
- const o = e.fieldsIndex?.get(t), n = Pe(t, r, e) ?? r;
869
- return Oe(e, t, n, o?.type, a);
870
- }, na = (e, t) => Ge(e, t), Ve = (e, t, r) => {
868
+ const o = e.fieldsIndex?.get(t), n = Ge(t, r, e) ?? r;
869
+ return Ve(e, t, n, o?.type, a);
870
+ }, na = (e, t) => Oe(e, t), Qe = (e, t, r) => {
871
871
  const a = e.objectIdField, o = t.features.map(
872
872
  (s) => s.attributes[a]
873
873
  ), n = t.features.map((s) => {
@@ -880,8 +880,8 @@ const te = async (e, t) => {
880
880
  c[d.name] = u;
881
881
  return;
882
882
  }
883
- const p = Pe(d.name, u, e) ?? u, h = Ge(e, d.name);
884
- c[h] = Oe(e, d.name, p, d.type, r);
883
+ const p = Ge(d.name, u, e) ?? u, h = Oe(e, d.name);
884
+ c[h] = Ve(e, d.name, p, d.type, r);
885
885
  }), c;
886
886
  });
887
887
  return { objectIds: o, attributes: n };
@@ -951,7 +951,7 @@ const ua = async (e) => {
951
951
  units: s.units,
952
952
  applied: !0
953
953
  });
954
- y = new Ie({
954
+ y = new Ne({
955
955
  geometry: T.geometry,
956
956
  distance: s.distance,
957
957
  units: s.units,
@@ -972,16 +972,16 @@ const ua = async (e) => {
972
972
  ...y && { filter: y },
973
973
  outStatisticTypes: { include: [a] }
974
974
  };
975
- g = await Ne(T);
975
+ g = await Ae(T);
976
976
  const D = ["string", "small-integer", "integer"], L = u.domain?.type === "coded-value" ? u.domain : null;
977
- (D.includes(u.type) || L) && (f = (await Ae({
977
+ (D.includes(u.type) || L) && (f = (await Me({
978
978
  layer: i,
979
979
  useFeaturesInView: w,
980
980
  view: w ? o : void 0,
981
981
  field: r,
982
982
  sqlWhere: X(i.definitionExpression, t.where),
983
983
  ...y && { filter: y }
984
- })).uniqueValueInfos.sort(($, st) => st.count - $.count).slice(0, x)), f && u.domain?.type === "coded-value" && (f = f.map(($) => ({
984
+ })).uniqueValueInfos.sort(($, it) => it.count - $.count).slice(0, x)), f && u.domain?.type === "coded-value" && (f = f.map(($) => ({
985
985
  ...$,
986
986
  value: L ? L.getName($.value) ?? $.value : $.value
987
987
  })));
@@ -1113,7 +1113,7 @@ Only call this tool when the answer requires computing an aggregate (avg, max, m
1113
1113
  console.warn("Client-side query failed, falling back to server:", x), h = await n.queryFeatures(g);
1114
1114
  }
1115
1115
  }
1116
- const y = h.features.map((g) => g.attributes[u]), { attributes: w } = Ve(n, h, r.timeZone);
1116
+ const y = h.features.map((g) => g.attributes[u]), { attributes: w } = Qe(n, h, r.timeZone);
1117
1117
  return {
1118
1118
  tool: "getTopFeatures",
1119
1119
  layerName: i,
@@ -1228,7 +1228,7 @@ Only call this tool when the answer requires computing an aggregate (avg, max, m
1228
1228
  } catch (g) {
1229
1229
  console.warn("Client-side query failed, falling back to server:", g), p = await o.queryFeatureCount(u), p > 0 && p <= ne && (h = await o.queryFeatures(u));
1230
1230
  }
1231
- const { objectIds: y, attributes: w } = h ? Ve(o, h, t.timeZone) : { objectIds: void 0, attributes: void 0 };
1231
+ const { objectIds: y, attributes: w } = h ? Qe(o, h, t.timeZone) : { objectIds: void 0, attributes: void 0 };
1232
1232
  return {
1233
1233
  tool: "queryFeatures",
1234
1234
  layerName: s,
@@ -1301,12 +1301,12 @@ USE THIS TOOL FOR:
1301
1301
 
1302
1302
  This is the DEFAULT tool for most queries. When in doubt, use this tool.`,
1303
1303
  schema: Ca
1304
- }), Qe = [da, ga, xa, ka], Ke = [Zr, Or, jr], Fa = async (e, t) => {
1304
+ }), Ke = [da, ga, xa, ka], We = [Zr, Or, jr], Fa = async (e, t) => {
1305
1305
  await m({ text: "Requesting LLM for layer filter results" }, t);
1306
1306
  const a = await R("data_explore_filter_prompt");
1307
1307
  if (!t?.configurable)
1308
1308
  throw new Error("config.configurable is required for layer filter tools");
1309
- const { userTimezone: o, userTimezoneOffset: n } = je(), s = {
1309
+ const { userTimezone: o, userTimezoneOffset: n } = Pe(), s = {
1310
1310
  layerFieldInfo: e.layerFieldInfo,
1311
1311
  userTimezone: o,
1312
1312
  userTimezoneOffset: n,
@@ -1319,7 +1319,7 @@ This is the DEFAULT tool for most queries. When in doubt, use this tool.`,
1319
1319
  modelTier: "advanced",
1320
1320
  messages: e.dataExplorationMessages,
1321
1321
  inputVariables: s,
1322
- tools: Ke
1322
+ tools: We
1323
1323
  }), c = [...e.dataExplorationMessages, i];
1324
1324
  if (!((i.tool_calls?.length ?? 0) > 0))
1325
1325
  return await m({ text: "LLM determined no filter changes needed" }, t), {
@@ -1334,7 +1334,7 @@ This is the DEFAULT tool for most queries. When in doubt, use this tool.`,
1334
1334
  const a = await R("data_explore_query_prompt");
1335
1335
  if (!t?.configurable)
1336
1336
  throw new Error("config.configurable is required for layer query tools");
1337
- const { userTimezone: o, userTimezoneOffset: n } = je(), s = {
1337
+ const { userTimezone: o, userTimezoneOffset: n } = Pe(), s = {
1338
1338
  layerFieldInfo: e.layerFieldInfo,
1339
1339
  userTimezone: o,
1340
1340
  userTimezoneOffset: n,
@@ -1346,7 +1346,7 @@ This is the DEFAULT tool for most queries. When in doubt, use this tool.`,
1346
1346
  modelTier: "advanced",
1347
1347
  messages: e.dataExplorationMessages,
1348
1348
  inputVariables: s,
1349
- tools: Qe
1349
+ tools: Ke
1350
1350
  }), c = i.content.toString();
1351
1351
  return await he(i, t), {
1352
1352
  ...e,
@@ -1368,7 +1368,7 @@ This is the DEFAULT tool for most queries. When in doubt, use this tool.`,
1368
1368
  modelTier: "fast",
1369
1369
  messages: e.dataExplorationMessages,
1370
1370
  inputVariables: o
1371
- }), s = typeof n == "string" ? n : n.content, i = new Me(s);
1371
+ }), s = typeof n == "string" ? n : n.content, i = new ze(s);
1372
1372
  await m({ text: `Received response from LLM: ${s}` }, t);
1373
1373
  const c = s;
1374
1374
  return {
@@ -1383,7 +1383,7 @@ This is the DEFAULT tool for most queries. When in doubt, use this tool.`,
1383
1383
  }
1384
1384
  };
1385
1385
  async function Ia(e, t) {
1386
- const a = await new G(Ke).invoke(
1386
+ const a = await new G(We).invoke(
1387
1387
  {
1388
1388
  messages: e.dataExplorationMessages
1389
1389
  },
@@ -1394,7 +1394,7 @@ async function Ia(e, t) {
1394
1394
  t
1395
1395
  ), { ...e };
1396
1396
  }
1397
- const Na = new G(Qe);
1397
+ const Na = new G(Ke);
1398
1398
  async function Aa(e, t) {
1399
1399
  const { messages: r } = await Na.invoke({ messages: e.dataExplorationMessages }, t), a = [], o = [];
1400
1400
  for (const n of r) {
@@ -1438,9 +1438,9 @@ const Ma = 10, za = ["string", "small-integer", "integer"], _a = async (e, t, {
1438
1438
  let o = null, n = null;
1439
1439
  try {
1440
1440
  if (t.type !== "geometry" && t.type !== "oid" && t.type !== "global-id") {
1441
- r && (o = await Ne({ layer: e, field: t.name }));
1441
+ r && (o = await Ae({ layer: e, field: t.name }));
1442
1442
  const s = t.domain?.type === "coded-value" ? t.domain : null;
1443
- a && (za.includes(t.type) || s) && (n = (await Ae({ layer: e, field: t.name })).uniqueValueInfos.sort((i, c) => c.count - i.count).slice(0, Ma), s && (n = n.map((i) => ({
1443
+ a && (za.includes(t.type) || s) && (n = (await Me({ layer: e, field: t.name })).uniqueValueInfos.sort((i, c) => c.count - i.count).slice(0, Ma), s && (n = n.map((i) => ({
1444
1444
  ...i,
1445
1445
  value: s.getName(i.value) ?? i.value
1446
1446
  }))));
@@ -1587,7 +1587,7 @@ ${i}` : c = "Vector search completed. No matching layers found.", await m({ text
1587
1587
  }, Wa = (e, t) => B(["layerSearch", "fieldSearch", "layersAndFieldsRegistry"], "Data Exploration Agent")(
1588
1588
  e,
1589
1589
  t
1590
- ), Ua = () => new W(De).addNode("requireDataExplorationServices", Wa).addNode("vectorSearchLayers", Ka).addNode("vectorSearchFields", Va).addNode("fieldStatistics", Ga).addNode("queryAgent", qa).addNode("queryTools", Aa).addNode("summarizeQueryResponseLLM", La).addNode("filterAgent", Fa).addNode("filterTools", Ia).addNode("earlyExit", Mr).addEdge(U, "requireDataExplorationServices").addEdge("requireDataExplorationServices", "vectorSearchLayers").addConditionalEdges(
1590
+ ), Ua = () => new W(je).addNode("requireDataExplorationServices", Wa).addNode("vectorSearchLayers", Ka).addNode("vectorSearchFields", Va).addNode("fieldStatistics", Ga).addNode("queryAgent", qa).addNode("queryTools", Aa).addNode("summarizeQueryResponseLLM", La).addNode("filterAgent", Fa).addNode("filterTools", Ia).addNode("earlyExit", Mr).addEdge(U, "requireDataExplorationServices").addEdge("requireDataExplorationServices", "vectorSearchLayers").addConditionalEdges(
1591
1591
  "vectorSearchLayers",
1592
1592
  (t) => t.vectorSearchLayerIds.length ? "vectorSearchFields" : "earlyExit"
1593
1593
  ).addConditionalEdges(
@@ -1609,7 +1609,7 @@ ${i}` : c = "Vector search completed. No matching layers found.", await m({ text
1609
1609
  name: "Data Exploration Agent",
1610
1610
  description: Ba,
1611
1611
  createGraph: Ua,
1612
- workspace: De
1612
+ workspace: je
1613
1613
  }, $e = 0.7, Ha = 10, Za = async (e, t) => {
1614
1614
  try {
1615
1615
  await m({ text: "Similarity search to find fields" }, t);
@@ -2525,7 +2525,7 @@ Keywords: categorical, category, type, unique, discrete, point of interest, regi
2525
2525
  Example: Color each feature based on the region it belongs to
2526
2526
  Fields: This style requires a single field which may be a string, number, or date type. It is usually a string.`,
2527
2527
  schema: pn
2528
- }), We = [
2528
+ }), Ue = [
2529
2529
  no,
2530
2530
  po,
2531
2531
  wo,
@@ -2537,7 +2537,7 @@ Fields: This style requires a single field which may be a string, number, or dat
2537
2537
  en,
2538
2538
  sn,
2539
2539
  hn
2540
- ], Ue = (e, t = 3) => {
2540
+ ], Be = (e, t = 3) => {
2541
2541
  const r = e.map((o, n) => o.type === "human" ? n : -1).filter((o) => o !== -1);
2542
2542
  if (r.length === 0)
2543
2543
  return [];
@@ -2553,9 +2553,9 @@ Fields: This style requires a single field which may be a string, number, or dat
2553
2553
  }, o = await P({
2554
2554
  promptText: r,
2555
2555
  modelTier: "advanced",
2556
- messages: Ue(e.agentExecutionContext.messages),
2556
+ messages: Be(e.agentExecutionContext.messages),
2557
2557
  inputVariables: a,
2558
- tools: We
2558
+ tools: Ue
2559
2559
  });
2560
2560
  return await he(o, t), {
2561
2561
  ...e,
@@ -2566,9 +2566,9 @@ Fields: This style requires a single field which may be a string, number, or dat
2566
2566
  };
2567
2567
  };
2568
2568
  async function yn(e, t) {
2569
- const a = await new G(We).invoke(
2569
+ const a = await new G(Ue).invoke(
2570
2570
  {
2571
- messages: Ue(e.agentExecutionContext.messages)
2571
+ messages: Be(e.agentExecutionContext.messages)
2572
2572
  },
2573
2573
  t
2574
2574
  ), o = a.messages.map((s) => s.text).join(`
@@ -2578,7 +2578,7 @@ async function yn(e, t) {
2578
2578
  `);
2579
2579
  return { ...e, outputMessage: n };
2580
2580
  }
2581
- const Be = v.Root({
2581
+ const He = v.Root({
2582
2582
  ...ee(),
2583
2583
  vectorSearchLayerIds: v(),
2584
2584
  vectorSearchFieldResults: v(),
@@ -2628,14 +2628,14 @@ const Be = v.Root({
2628
2628
  message: "Choose a layer to apply the styles.",
2629
2629
  metadata: [...r]
2630
2630
  };
2631
- throw new it(n);
2631
+ throw new lt(n);
2632
2632
  }
2633
2633
  let o = null;
2634
2634
  return Array.isArray(a.payload) && a.payload.length > 0 && (o = a.payload[0]), {
2635
2635
  ...e,
2636
2636
  selectedLayerId: o ?? e.vectorSearchLayerIds[0]
2637
2637
  };
2638
- }, bn = (e, t) => B(["layerSearch", "fieldSearch", "layersAndFieldsRegistry"], "Layer Styling Agent")(e, t), Sn = () => new W(Be).addNode("requireLayerStylingServices", bn).addNode("vectorSearchLayers", Ya).addNode("layerSelectionHITL", wn).addNode("vectorSearchFields", Za).addNode("populateLayerFieldInfo", fn).addNode("agent", mn).addNode("tools", yn).addNode("earlyExit", gn).addEdge(U, "requireLayerStylingServices").addEdge("requireLayerStylingServices", "vectorSearchLayers").addConditionalEdges(
2638
+ }, bn = (e, t) => B(["layerSearch", "fieldSearch", "layersAndFieldsRegistry"], "Layer Styling Agent")(e, t), Sn = () => new W(He).addNode("requireLayerStylingServices", bn).addNode("vectorSearchLayers", Ya).addNode("layerSelectionHITL", wn).addNode("vectorSearchFields", Za).addNode("populateLayerFieldInfo", fn).addNode("agent", mn).addNode("tools", yn).addNode("earlyExit", gn).addEdge(U, "requireLayerStylingServices").addEdge("requireLayerStylingServices", "vectorSearchLayers").addConditionalEdges(
2639
2639
  "layerSelectionHITL",
2640
2640
  (t) => t.vectorSearchLayerIds.length ? "vectorSearchFields" : "earlyExit"
2641
2641
  ).addConditionalEdges(
@@ -2650,8 +2650,8 @@ const Be = v.Root({
2650
2650
  name: "Layer Styling Agent",
2651
2651
  description: vn,
2652
2652
  createGraph: Sn,
2653
- workspace: Be
2654
- }, He = v.Root({
2653
+ workspace: He
2654
+ }, Ze = v.Root({
2655
2655
  ...ee(),
2656
2656
  // internal to the help agent
2657
2657
  helpInternalState: v({
@@ -2682,7 +2682,7 @@ ${o}`;
2682
2682
  schema: l.object({
2683
2683
  layerTitle: l.string().describe("The title or partial title of the layer to list fields for.")
2684
2684
  })
2685
- }), Ze = [En], Rn = (e) => {
2685
+ }), Je = [En], Rn = (e) => {
2686
2686
  if (!e || e.size === 0)
2687
2687
  return "No layers available in this map.";
2688
2688
  const t = Array.from(e.values()).map(({ layerItem: r, fieldRegistry: a }, o) => {
@@ -2706,7 +2706,7 @@ async function Cn(e, t) {
2706
2706
  const n = await P({
2707
2707
  promptText: r,
2708
2708
  modelTier: "fast",
2709
- tools: Ze,
2709
+ tools: Je,
2710
2710
  inputVariables: {
2711
2711
  layerSummary: Rn(a),
2712
2712
  agents: $n(o),
@@ -2737,7 +2737,7 @@ async function Cn(e, t) {
2737
2737
  }
2738
2738
  const kn = (e, t) => B(["agentRegistry"], "Help Agent")(e, t);
2739
2739
  async function Fn(e, t) {
2740
- const r = new G(Ze);
2740
+ const r = new G(Je);
2741
2741
  try {
2742
2742
  const a = e.helpInternalState.toolCallMessage;
2743
2743
  if (!a)
@@ -2768,7 +2768,7 @@ async function Fn(e, t) {
2768
2768
  };
2769
2769
  }
2770
2770
  }
2771
- const qn = () => new W(He).addNode("requireHelpServices", kn).addNode("agent", Cn).addNode("tools", Fn).addEdge(U, "requireHelpServices").addEdge("requireHelpServices", "agent").addConditionalEdges("agent", (t) => t.helpInternalState.toolCallMessage ? "tools" : C).addEdge("tools", C), Ln = String.raw`- **help** — Enables users to ask questions about the map, layers, fields, and it's capabilities.
2771
+ const qn = () => new W(Ze).addNode("requireHelpServices", kn).addNode("agent", Cn).addNode("tools", Fn).addEdge(U, "requireHelpServices").addEdge("requireHelpServices", "agent").addConditionalEdges("agent", (t) => t.helpInternalState.toolCallMessage ? "tools" : C).addEdge("tools", C), Ln = String.raw`- **help** — Enables users to ask questions about the map, layers, fields, and it's capabilities.
2772
2772
 
2773
2773
  _Example: “Tell me about this map”_
2774
2774
  _Example: “List all layers in this map”_
@@ -2786,8 +2786,8 @@ const qn = () => new W(He).addNode("requireHelpServices", kn).addNode("agent", C
2786
2786
  name: "Help Agent",
2787
2787
  description: Ln,
2788
2788
  createGraph: qn,
2789
- workspace: He
2790
- }, Je = v.Root({
2789
+ workspace: Ze
2790
+ }, Ye = v.Root({
2791
2791
  ...ee(),
2792
2792
  intent: v({
2793
2793
  reducer: (e, t) => t
@@ -2803,7 +2803,7 @@ const qn = () => new W(He).addNode("requireHelpServices", kn).addNode("agent", C
2803
2803
  }), J = {
2804
2804
  conversationId: ""
2805
2805
  }, In = ["view"], se = ["knowledgeGraph", "view"];
2806
- function Ye(e) {
2806
+ function Xe(e) {
2807
2807
  const t = e.map?.allLayers.filter((r) => r.type === "knowledge-graph");
2808
2808
  if (!t || t?.length !== 1)
2809
2809
  throw new Error("The Knowledge Agent currently only supports maps with exactly one Knowledge Graph Layer.");
@@ -2819,7 +2819,7 @@ function re(e) {
2819
2819
  if (a.length)
2820
2820
  throw new Error(`View context missing: ${a.join(", ")}`);
2821
2821
  const o = r.view;
2822
- return o.map && !("activeLinkChartLayer" in o.map) && Ye(o), {
2822
+ return o.map && !("activeLinkChartLayer" in o.map) && Xe(o), {
2823
2823
  view: o
2824
2824
  };
2825
2825
  }
@@ -2842,7 +2842,7 @@ async function O(e) {
2842
2842
  knowledgeGraph: await be(n)
2843
2843
  };
2844
2844
  } else {
2845
- Ye(r.view);
2845
+ Xe(r.view);
2846
2846
  const s = (r.view.map?.allLayers.find(
2847
2847
  (c) => c.type === "knowledge-graph"
2848
2848
  )).url;
@@ -3061,7 +3061,7 @@ async function ye(e, t, r, a, o) {
3061
3061
  return { graphQuery: u, explanation: p };
3062
3062
  }
3063
3063
  const z = 3;
3064
- function Xe(e, t = 100) {
3064
+ function et(e, t = 100) {
3065
3065
  const r = {};
3066
3066
  for (const a of Object.entries(e.properties ?? {})) {
3067
3067
  const [o, n] = a;
@@ -3111,7 +3111,7 @@ const Pn = async ({
3111
3111
  }
3112
3112
  return { type: "success", rowLimitReached: !1, resultHeader: i, processedResult: c };
3113
3113
  };
3114
- async function et({
3114
+ async function tt({
3115
3115
  prompt: e,
3116
3116
  kg: t,
3117
3117
  graphQueryServiceUrl: r,
@@ -3142,7 +3142,7 @@ async function et({
3142
3142
  );
3143
3143
  const h = await Pn({
3144
3144
  kg: t,
3145
- queryParams: new ze({
3145
+ queryParams: new _e({
3146
3146
  openCypherQuery: p.graphQuery
3147
3147
  }),
3148
3148
  targetStructure: a,
@@ -3296,7 +3296,7 @@ function Un(e) {
3296
3296
  return { allNamedTypesFullyDynamic: !1, idTypePairs: t, dynamicTypes: r };
3297
3297
  }
3298
3298
  async function Bn(e, t, r, a, o) {
3299
- const { view: n } = a, s = await et({
3299
+ const { view: n } = a, s = await tt({
3300
3300
  prompt: e,
3301
3301
  kg: t,
3302
3302
  graphQueryServiceUrl: r,
@@ -3322,22 +3322,21 @@ async function Bn(e, t, r, a, o) {
3322
3322
  text: `Query Results parsed into ${u.length} unique relationships and entities. Atempting to add to link chart...`
3323
3323
  },
3324
3324
  o
3325
- ), H(n))
3326
- return await n?.map?.allLayers.find(
3327
- (h) => h.type === "knowledge-graph"
3328
- )?.addRecords(u), `Map updated successfully. Cypher Query used:
3325
+ ), !H(n) && n?.map) {
3326
+ const p = n.map;
3327
+ return await p.addRecords(u), n.goTo(p.diagramNodesExtent ?? new Le()), `Link Chart updated successfully. Cypher Query used:
3329
3328
  ${i}
3330
3329
 
3331
3330
  Explanation: ${c}`;
3332
- {
3333
- const p = n;
3334
- return await p.map.addRecords(u), p.goTo(p.map.diagramNodesExtent), `Link Chart updated successfully. Cypher Query used:
3331
+ } else
3332
+ return await n?.map?.allLayers.find(
3333
+ (h) => h.type === "knowledge-graph"
3334
+ )?.addRecords(u), `Map updated successfully. Cypher Query used:
3335
3335
  ${i}
3336
3336
 
3337
3337
  Explanation: ${c}`;
3338
- }
3339
3338
  }
3340
- const tt = "addRecords", Hn = l.object({
3339
+ const rt = "addRecords", Hn = l.object({
3341
3340
  prompt: l.string().describe("The user's inquiry into the knowledge graph that needs to be run.")
3342
3341
  }), Zn = async ({ prompt: e }, t) => {
3343
3342
  const { knowledgeGraph: r } = await O(t), a = re(t), { view: o } = a, s = _.getDefault().helperServices;
@@ -3364,17 +3363,17 @@ ${u}${JSON.stringify(p)}`;
3364
3363
  t
3365
3364
  );
3366
3365
  return {
3367
- toolName: tt,
3366
+ toolName: rt,
3368
3367
  status: "success",
3369
3368
  summary: c
3370
3369
  };
3371
3370
  }, Jn = b(Zn, {
3372
- name: tt,
3371
+ name: rt,
3373
3372
  description: "Adds records (entities or relationships) to the current link chart visualization from an inquiry into the knowledge graph data. The inquiry will retrieve data from the graph database that will serve as the basis for the records to be added to the link chart. The user should have explicitly requested to add records to the current link chart from their prompt.",
3374
3373
  schema: Hn
3375
3374
  });
3376
3375
  async function Yn(e, t) {
3377
- return await t.map.applyLayout(e), `Successfully applied layout: ${e}.`;
3376
+ return await t.map?.applyLayout(e), `Successfully applied layout: ${e}.`;
3378
3377
  }
3379
3378
  const le = "applyLayout", Xn = l.object({
3380
3379
  layout: l.enum([
@@ -3413,7 +3412,7 @@ const le = "applyLayout", Xn = l.object({
3413
3412
  schema: Xn
3414
3413
  });
3415
3414
  function rs(e, t) {
3416
- return t.map.changeNonspatialDataDisplay(e), `Successfully applied nonspatial visibility setting: ${e}.`;
3415
+ return t.map?.changeNonspatialDataDisplay(e), `Successfully applied nonspatial visibility setting: ${e}.`;
3417
3416
  }
3418
3417
  const ce = "changeNonspatialVisibility", as = l.object({
3419
3418
  setting: l.enum(["hidden", "visible"]).describe("The setting of nonspatial visibility")
@@ -3453,7 +3452,7 @@ async function ss(e, t, r, a, o) {
3453
3452
  await m({ text: `Attempting to create link chart from derived query: ${i}` }, o);
3454
3453
  const d = await Pt.fromCypherQuery(
3455
3454
  t,
3456
- new ze({
3455
+ new _e({
3457
3456
  openCypherQuery: i
3458
3457
  })
3459
3458
  );
@@ -3509,7 +3508,7 @@ const de = "createLinkChart", is = l.object({
3509
3508
  name: de,
3510
3509
  description: "Creates a new link chart visualization from an inquiry into the knowledge graph data. The inquiry will retrieve data from the graph database that will serve as the basis for the new link chart. The user should have explicitly requested the creation of a new link chart from their prompt.",
3511
3510
  schema: is
3512
- }), rt = "queryGraphData", ds = l.object({
3511
+ }), at = "queryGraphData", ds = l.object({
3513
3512
  prompt: l.string().describe(
3514
3513
  `The user's inquiry into the knowledge graph, from which a cypher query will be generated and executed to answer the inquiry. IMPORTANT:
3515
3514
 
@@ -3518,7 +3517,7 @@ REQUEST LIMIT: If the user does not specifically request for no limits or an exp
3518
3517
  DESCRIPTIVE COLUMN NAMES: If the user's prompt does not explicitly request for specific column names in the result, ensure that the generated query has descriptive column names (using AS statements) to make the results easier to understand when displayed in a table format.`
3519
3518
  )
3520
3519
  }), us = async ({ prompt: e }, t) => {
3521
- const { knowledgeGraph: r } = await O(t), o = _.getDefault().helperServices, n = await et({
3520
+ const { knowledgeGraph: r } = await O(t), o = _.getDefault().helperServices, n = await tt({
3522
3521
  prompt: e,
3523
3522
  kg: r,
3524
3523
  graphQueryServiceUrl: `${o.aiAssistantServices.url}${o.aiAssistantServices.graphQueryAssistant}`,
@@ -3539,11 +3538,11 @@ DESCRIPTIVE COLUMN NAMES: If the user's prompt does not explicitly request for s
3539
3538
  for (const y of h)
3540
3539
  j(
3541
3540
  y,
3542
- (w) => Xe(w)
3541
+ (w) => et(w)
3543
3542
  );
3544
3543
  const u = 50, p = i.slice(0, u).map((h) => JSON.stringify(h));
3545
3544
  return {
3546
- toolName: rt,
3545
+ toolName: at,
3547
3546
  status: "success",
3548
3547
  summary: `To answer the inquiry, the following cypher query was executed against the knowledge graph:
3549
3548
 
@@ -3570,10 +3569,10 @@ ${p.length > u ? `Showing top ${u} results:
3570
3569
  }
3571
3570
  };
3572
3571
  }, ps = b(us, {
3573
- name: rt,
3572
+ name: at,
3574
3573
  description: "Allows users to explore the data in their knowledge graph via cypher query. Generates and executes a cypher query based on the user's inquiry into the knowledge graph, and displays the results in the chat pane without modifying the user's link chart if any. Use this tool when the user is asking an exploratory question about their data as a whole that can be answered via cypher query, for example 'What are the top 5 suppliers by total parts cost?' or 'How many employees do we have in each department?'.",
3575
3574
  schema: ds
3576
- }), at = "generateCypher", hs = l.object({
3575
+ }), ot = "generateCypher", hs = l.object({
3577
3576
  prompt: l.string().describe("The user's inquiry into the knowledge graph that needs to be translated into a cypher query.")
3578
3577
  }), ms = async ({ prompt: e }, t) => {
3579
3578
  const { knowledgeGraph: r } = await O(t), o = _.getDefault().helperServices, n = await jn(
@@ -3583,12 +3582,12 @@ ${p.length > u ? `Showing top ${u} results:
3583
3582
  t
3584
3583
  );
3585
3584
  return {
3586
- toolName: at,
3585
+ toolName: ot,
3587
3586
  status: "success",
3588
3587
  summary: n
3589
3588
  };
3590
3589
  }, ys = b(ms, {
3591
- name: at,
3590
+ name: ot,
3592
3591
  description: "Generates an Open Cypher query based on the user's prompt which represents an inquiry into the data of the knowledge service and its graph database, attempting to filter based on certain conditions and traverse specified relationships. The generated query should be syntactically correct and optimized for performance.",
3593
3592
  schema: hs
3594
3593
  }), gs = (e) => {
@@ -3632,7 +3631,7 @@ async function fs(e, t) {
3632
3631
  schema: i
3633
3632
  });
3634
3633
  }
3635
- const ot = "searchGraphData", ws = l.object({
3634
+ const nt = "searchGraphData", ws = l.object({
3636
3635
  prompt: l.string().describe(
3637
3636
  "The user's inquiry into the knowledge graph, from which a lucene search query will be generated and executed against the graph to return relevant results."
3638
3637
  )
@@ -3659,11 +3658,11 @@ const ot = "searchGraphData", ws = l.object({
3659
3658
  for (const i of o.results)
3660
3659
  j(
3661
3660
  i,
3662
- (c) => Xe(c)
3661
+ (c) => et(c)
3663
3662
  );
3664
3663
  const n = 10, s = o.results.slice(0, n);
3665
3664
  return {
3666
- toolName: ot,
3665
+ toolName: nt,
3667
3666
  status: "success",
3668
3667
  summary: `To answer the query, the following lucene query was generated and executed:
3669
3668
  Query: ${a.query}
@@ -3685,10 +3684,10 @@ const ot = "searchGraphData", ws = l.object({
3685
3684
  }
3686
3685
  };
3687
3686
  }, Ss = b(bs, {
3688
- name: ot,
3687
+ name: nt,
3689
3688
  description: "Allows users to search the knowledge graph for text matching their inquiry, using lucene search syntax, against indexed string properties defined on their entities and relationships. Use this tool when the user asks a question about their knowledge graph data as a whole, that could be answered via lucene text search of properties stored on graph elements, e.g requiring fuzzy matching. Otherwise if the inquiry is looking for connected records (e.g. paths), data aggregations, etc explore the data via the queryGraphData tool.",
3690
3689
  schema: ws
3691
- }), nt = [
3690
+ }), st = [
3692
3691
  ts,
3693
3692
  ns,
3694
3693
  ys,
@@ -3706,7 +3705,7 @@ async function vs(e, t) {
3706
3705
  promptText: r,
3707
3706
  messages: e.arcgisKnowledgeMessages,
3708
3707
  inputVariables: a,
3709
- tools: nt
3708
+ tools: st
3710
3709
  }), n = (o.tool_calls?.length ?? 0) > 0, s = typeof o.text == "string" ? o.text.trim() : "", i = s.length > 0, c = o.content.toString();
3711
3710
  return {
3712
3711
  ...e,
@@ -3717,7 +3716,7 @@ async function vs(e, t) {
3717
3716
  };
3718
3717
  }
3719
3718
  async function xs(e, t) {
3720
- const r = new G(nt);
3719
+ const r = new G(st);
3721
3720
  try {
3722
3721
  const a = await r.invoke(
3723
3722
  {
@@ -3791,10 +3790,10 @@ async function Es(e, t) {
3791
3790
  outputMessage: c,
3792
3791
  status: "success",
3793
3792
  summary: N(c),
3794
- arcgisKnowledgeMessages: [...e.arcgisKnowledgeMessages, new Me(c)]
3793
+ arcgisKnowledgeMessages: [...e.arcgisKnowledgeMessages, new ze(c)]
3795
3794
  };
3796
3795
  }
3797
- const Rs = () => new W(Je).addNode("requireArcgisKnowledgeServices", Ts).addNode("agent", vs).addNode("tools", xs).addNode("summarizationLLM", Es).addEdge(U, "requireArcgisKnowledgeServices").addEdge("requireArcgisKnowledgeServices", "agent").addConditionalEdges("agent", (t) => (t.arcgisKnowledgeMessages[t.arcgisKnowledgeMessages.length - 1]?.tool_calls?.length ?? 0) > 0 ? "tools" : C).addConditionalEdges("tools", (t) => t.status === "failed" ? C : "summarizationLLM").addEdge("summarizationLLM", C), $s = String.raw`The purpose of this agent is to work with Knowledge Graph data, a graph database technology that represents and stores data as interconnected entities (nodes) and relationships (edges).
3796
+ const Rs = () => new W(Ye).addNode("requireArcgisKnowledgeServices", Ts).addNode("agent", vs).addNode("tools", xs).addNode("summarizationLLM", Es).addEdge(U, "requireArcgisKnowledgeServices").addEdge("requireArcgisKnowledgeServices", "agent").addConditionalEdges("agent", (t) => (t.arcgisKnowledgeMessages[t.arcgisKnowledgeMessages.length - 1]?.tool_calls?.length ?? 0) > 0 ? "tools" : C).addConditionalEdges("tools", (t) => t.status === "failed" ? C : "summarizationLLM").addEdge("summarizationLLM", C), $s = String.raw`The purpose of this agent is to work with Knowledge Graph data, a graph database technology that represents and stores data as interconnected entities (nodes) and relationships (edges).
3798
3797
  This agent has two categories of skills: those that work with an active link chart visualization of a subset of the data in the knowledge graph, and those that work with the knowledge graph data more generally against the entire dataset in the service and database.
3799
3798
  For link charts, the agent enables users to interact with a link chart by adding new entities (also called nodes) or relationships (also called edges), removing existing entities or relationships,
3800
3799
  expanding the graph from particular entities, finding relationships between specified entities on the link chart and adding them to the link chart, finding all relationships
@@ -3837,7 +3836,7 @@ _example: "What is the average age of all people who work for Esri?"_`, Si = {
3837
3836
  name: "ArcgisKnowledge Agent",
3838
3837
  description: $s,
3839
3838
  createGraph: Rs,
3840
- workspace: Je
3839
+ workspace: Ye
3841
3840
  };
3842
3841
  export {
3843
3842
  Si as ArcgisKnowledgeAgent,
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@arcgis/ai-agents",
3
- "version": "5.1.0-next.102",
3
+ "version": "5.1.0-next.104",
4
4
  "description": "ArcGIS AI Agents Package",
5
5
  "homepage": "https://developers.arcgis.com/javascript/latest/",
6
6
  "type": "module",
@@ -20,7 +20,7 @@
20
20
  "@langchain/langgraph": "^1.2.6",
21
21
  "tslib": "^2.8.1",
22
22
  "zod": "^4.3.6",
23
- "@arcgis/ai-orchestrator": "5.1.0-next.102"
23
+ "@arcgis/ai-orchestrator": "5.1.0-next.104"
24
24
  },
25
25
  "peerDependencies": {
26
26
  "@arcgis/core": "^5.1.0-next"