@arcgis/ai-components 5.2.0-next.24 → 5.2.0-next.25

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 (33) hide show
  1. package/dist/cdn/3AXQTBIA.js +134 -0
  2. package/dist/cdn/3EMHTJ2C.js +180 -0
  3. package/dist/cdn/{BGVIBF6M.js → 4D4XBLDN.js} +1 -1
  4. package/dist/cdn/{GH263QNS.js → 4JK6XZLV.js} +1 -1
  5. package/dist/cdn/{SASFHTVY.js → 6ELX5G6N.js} +5 -5
  6. package/dist/cdn/{FWXRFMNO.js → CZCEK4Z5.js} +1 -1
  7. package/dist/cdn/{2EMRDLJG.js → E6CUTFFK.js} +1 -1
  8. package/dist/cdn/{YIJSPLIP.js → G7PX6SLG.js} +1 -1
  9. package/dist/cdn/{GJUD7EA3.js → IGZWQJW7.js} +1 -1
  10. package/dist/cdn/LEPJUN3X.js +22 -0
  11. package/dist/cdn/{OARG3JNP.js → QUXNVDLI.js} +1 -1
  12. package/dist/cdn/{QPHLBARY.js → RQ7Y7JY3.js} +1 -1
  13. package/dist/cdn/{CMTXZ33N.js → TNEA5K7L.js} +1 -1
  14. package/dist/cdn/{2F2U6T5S.js → VD5GRVML.js} +1 -1
  15. package/dist/cdn/W2IHPJ54.js +34 -0
  16. package/dist/cdn/{B4GH4POB.js → X64XUQX2.js} +1 -1
  17. package/dist/cdn/ZMSJQB65.js +99 -0
  18. package/dist/cdn/agent-utils/index.js +1 -1
  19. package/dist/cdn/index.js +1 -1
  20. package/dist/chunks/adapter.js +1179 -1091
  21. package/dist/chunks/arcgisKnowledgeGraph.js +91 -74
  22. package/dist/chunks/arcgis_knowledge_current_lc_context.js +19 -2
  23. package/dist/chunks/arcgis_knowledge_current_map_context.js +31 -2
  24. package/dist/chunks/arcgis_knowledge_cypher_query_prompt.js +102 -0
  25. package/dist/chunks/arcgis_knowledge_summarize_result_prompt.js +116 -27
  26. package/dist/docs/api.json +1 -1
  27. package/dist/docs/docs.json +1 -1
  28. package/dist/docs/web-types.json +1 -1
  29. package/package.json +4 -4
  30. package/dist/cdn/5QAHYX7Y.js +0 -5
  31. package/dist/cdn/AMXYAMAZ.js +0 -161
  32. package/dist/cdn/AXDZBBNL.js +0 -45
  33. package/dist/cdn/KMQ3SP4I.js +0 -5
@@ -1,11 +1,11 @@
1
1
  /* COPYRIGHT Esri - https://js.arcgis.com/5.2/LICENSE.txt */
2
- import { StateGraph as f, START as x, END as h, Command as k } from "@langchain/langgraph/web";
3
- import { a as b, c as _, b as K, d as A, e as T, s as v, q, g as u, h as M, t as c, r as S, i as C, G as E, j as m } from "./adapter.js";
2
+ import { StateGraph as x, START as k, END as c, Command as b } from "@langchain/langgraph/web";
3
+ import { a as K, c as _, b as T, d as A, e as S, s as M, q as v, g as u, h as q, t as g, r as C, i as E, G, j as m } from "./adapter.js";
4
4
  import "@arcgis/core/identity/IdentityManager.js";
5
5
  import "@arcgis/core/portal/Portal.js";
6
6
  import "@arcgis/toolkit/string";
7
- import { h as G, e as N } from "./generateLayerDescriptions.js";
8
- import { AIMessage as R } from "@langchain/core/messages";
7
+ import { h as N, e as R } from "./generateLayerDescriptions.js";
8
+ import { AIMessage as y } from "@langchain/core/messages";
9
9
  import "@langchain/core/callbacks/dispatch/web";
10
10
  import "@langchain/openai";
11
11
  import "@arcgis/core/config.js";
@@ -13,43 +13,44 @@ import "@arcgis/core/core/reactiveUtils.js";
13
13
  import "@arcgis/core/layers/FeatureLayer.js";
14
14
  import "@arcgis/core/request.js";
15
15
  import { ToolNode as L } from "@langchain/langgraph/prebuilt";
16
- import { s as p, a as D } from "./index.js";
16
+ import { s as p, a as z } from "./index.js";
17
17
  import "@langchain/core/prompts";
18
18
  const w = [
19
- b,
20
- _,
21
19
  K,
22
- A,
20
+ _,
23
21
  T,
24
- v,
25
- q
22
+ A,
23
+ S,
24
+ M,
25
+ v
26
26
  ];
27
- async function z(e, a) {
28
- const i = await u("arcgis_knowledge_tool_prompt"), o = M(a), n = {
27
+ async function D(e, t) {
28
+ const o = await u("arcgis_knowledge_tool_prompt"), s = q(t), n = {
29
29
  assignedTask: e.agentExecutionContext.assignedTask,
30
30
  userRequest: e.agentExecutionContext.userRequest,
31
31
  priorSteps: e.agentExecutionContext.priorSteps,
32
- contextType: o
33
- }, s = await G({
34
- promptText: i,
32
+ contextType: s
33
+ }, r = await N({
34
+ promptText: o,
35
35
  messages: e.arcgisKnowledgeMessages,
36
36
  inputVariables: n,
37
- tools: w
38
- }), l = (s.tool_calls?.length ?? 0) > 0, t = typeof s.text == "string" ? s.text.trim() : "", r = t.length > 0, d = s.content.toString();
39
- return !l && (o === "map" || o === "knowledgeGraph") ? {
37
+ tools: w,
38
+ config: t
39
+ }), l = (r.tool_calls?.length ?? 0) > 0, a = typeof r.text == "string" ? r.text.trim() : "", i = a.length > 0, d = r.content.toString();
40
+ return !l && (s === "map" || s === "knowledgeGraph") ? {
40
41
  ...e,
41
- arcgisKnowledgeMessages: [...e.arcgisKnowledgeMessages, s],
42
- outputMessage: o === "map" ? "No tools were found for the current view and prompt. Maps do not support changing nonspatial visibility, layout changes, or generation from queries." : "No tools were found for the current prompt and knowledge graph service. A knowledge graph service only supports search and query.",
42
+ arcgisKnowledgeMessages: [...e.arcgisKnowledgeMessages, r],
43
+ outputMessage: s === "map" ? "No tools were found for the current view and prompt. Maps do not support changing nonspatial visibility, layout changes, or generation from queries." : "No tools were found for the current prompt and knowledge graph service. A knowledge graph service only supports search and query.",
43
44
  status: "success"
44
45
  } : {
45
46
  ...e,
46
- arcgisKnowledgeMessages: [...e.arcgisKnowledgeMessages, s],
47
- outputMessage: l ? d : t,
48
- status: l ? e.status : r ? "success" : "failed",
49
- summary: d ? c(d) : "ArcGIS Knowledge Agent tool executed."
47
+ arcgisKnowledgeMessages: [...e.arcgisKnowledgeMessages, r],
48
+ outputMessage: l ? d : a,
49
+ status: l ? e.status : i ? "success" : "failed",
50
+ summary: d ? g(d) : "ArcGIS Knowledge Agent tool executed."
50
51
  };
51
52
  }
52
- const y = {
53
+ const f = {
53
54
  generateCypher: "generated-cypher-query",
54
55
  queryGraphData: "graph-query-result",
55
56
  searchGraphData: "graph-search-result",
@@ -59,110 +60,126 @@ const y = {
59
60
  createLinkChart: "created-link-chart"
60
61
  };
61
62
  function F(e) {
62
- return !!e && e.status === "success" && !!y[e.toolName];
63
+ return !!e && e.status === "success" && !!f[e.toolName];
63
64
  }
64
65
  function $(e) {
65
66
  return {
66
- type: y[e.toolName],
67
+ type: f[e.toolName],
67
68
  data: e.details
68
69
  };
69
70
  }
70
- async function I(e, a) {
71
- const i = new L(w, { handleToolErrors: !1 });
71
+ async function I(e, t) {
72
+ const o = new L(w, { handleToolErrors: !1 });
72
73
  try {
73
- const o = await i.invoke(
74
+ const s = await o.invoke(
74
75
  {
75
76
  messages: e.arcgisKnowledgeMessages
76
77
  },
77
- a
78
+ t
78
79
  ), n = [];
79
- for (const t of o.messages) {
80
- let r;
81
- if (typeof t.content != "string")
82
- throw new Error(`Unexpected tool message content type: ${typeof t.content}. Expected string.`);
80
+ for (const a of s.messages) {
81
+ let i;
82
+ if (typeof a.content != "string")
83
+ throw new Error(`Unexpected tool message content type: ${typeof a.content}. Expected string.`);
83
84
  try {
84
- r = JSON.parse(t.content);
85
+ i = JSON.parse(a.content);
85
86
  } catch {
86
87
  throw new Error(
87
- `Failed to parse tool message content as JSON. Tool: ${t.name ?? "unknown"}.
88
+ `Failed to parse tool message content as JSON. Tool: ${a.name ?? "unknown"}.
88
89
 
89
- Original Content: ${t.content}`
90
+ Original Content: ${a.content}`
90
91
  );
91
92
  }
92
- if (!r || typeof r != "object" || !("toolName" in r))
93
+ if (!i || typeof i != "object" || !("toolName" in i))
93
94
  throw new Error(
94
- `Parsed tool message content does not have expected structure. Parsed content: ${JSON.stringify(r)}`
95
+ `Parsed tool message content does not have expected structure. Parsed content: ${JSON.stringify(i)}`
95
96
  );
96
- n.push(r);
97
+ n.push(i);
97
98
  }
98
99
  await p(
99
100
  {
100
- text: `Finished executing ArcGIS Knowledge Agent tools: ${o.messages.filter((t) => t.name).map((t) => t.name).join(", ")}`
101
+ text: `Finished executing ArcGIS Knowledge Agent tools: ${s.messages.filter((a) => a.name).map((a) => a.name).join(", ")}`
101
102
  },
102
- a
103
+ t
103
104
  );
104
- const s = n.filter((t) => typeof t != "string").map((t) => `- Called Tool: ${t.toolName}, Status: ${t.status}`), l = n[0];
105
- return l && F(l) && await D($(l), a), {
105
+ const r = n.filter((a) => typeof a != "string").map((a) => `- Called Tool: ${a.toolName}, Status: ${a.status}`), l = n[0];
106
+ return l && F(l) && await z($(l), t), {
106
107
  ...e,
107
- outputMessage: s.join(`
108
+ outputMessage: r.join(`
108
109
  `),
109
- summary: s.length ? c(s.join(`
110
+ summary: r.length ? g(r.join(`
110
111
  `)) : "ArcGIS Knowledge Agent did not execute any tools or return any results.",
111
- arcgisKnowledgeMessages: [...e.arcgisKnowledgeMessages, ...o.messages],
112
+ arcgisKnowledgeMessages: [...e.arcgisKnowledgeMessages, ...s.messages],
112
113
  arcgisKnowledgeToolResult: n
113
114
  };
114
- } catch (o) {
115
- const n = o instanceof Error ? o.message : String(o);
115
+ } catch (s) {
116
+ const n = s instanceof Error ? s.message : String(s);
116
117
  return await p(
117
118
  { text: `ArcGIS Knowledge Agent tool execution failed unexpectedly: ${n}` },
118
- a
119
+ t
119
120
  ), {
120
121
  ...e,
121
122
  outputMessage: `ArcGIS Knowledge Agent tool execution failed unexpectedly: ${n}`,
122
123
  status: "failed",
123
- summary: c(`ArcGIS Knowledge Agent tool execution failed unexpectedly: ${n}`),
124
+ summary: g(`ArcGIS Knowledge Agent tool execution failed unexpectedly: ${n}`),
124
125
  arcgisKnowledgeMessages: [...e.arcgisKnowledgeMessages]
125
126
  };
126
127
  }
127
128
  }
128
- const V = (e, a) => (
129
+ const V = (e, t) => (
129
130
  //agent services (ex: embeddingsWorker) would go in the array below, if required.
130
- S([], "ArcgisKnowledge Agent")(e, a)
131
+ C([], "ArcgisKnowledge Agent")(e, t)
131
132
  );
132
- async function j(e, a) {
133
- const o = (e.arcgisKnowledgeToolResult ?? []).map((d) => ({
133
+ async function j(e, t) {
134
+ const s = (e.arcgisKnowledgeToolResult ?? []).map((d) => ({
134
135
  ...d,
135
136
  details: void 0
136
137
  // Remove details to avoid overwhelming the LLM with too much info
137
- })), { knowledgeGraph: n } = await C(a), s = E.getDataModelTypesSummary(n.dataModel), l = {
138
+ })), { knowledgeGraph: n } = await E(t), r = G.getDataModelTypesSummary(n.dataModel), l = {
138
139
  assignedTask: e.agentExecutionContext.assignedTask,
139
140
  userRequest: e.agentExecutionContext.userRequest,
140
- toolResult: o,
141
- dataModelSummary: s
142
- }, t = await N({
141
+ toolResult: s,
142
+ dataModelSummary: r
143
+ }, a = await R({
143
144
  promptText: await u("arcgis_knowledge_summarize_result_prompt"),
144
145
  modelTier: "default",
145
- inputVariables: l
146
- }), r = typeof t == "string" ? t : t.content;
146
+ inputVariables: l,
147
+ config: t
148
+ }), i = typeof a == "string" ? a : a.content;
149
+ return {
150
+ ...e,
151
+ outputMessage: i,
152
+ status: "success",
153
+ summary: g(i),
154
+ arcgisKnowledgeMessages: [...e.arcgisKnowledgeMessages, new y(i)]
155
+ };
156
+ }
157
+ async function O(e) {
158
+ const t = e.arcgisKnowledgeToolResult?.[0], o = t?.status === "success" ? t.summary : "ArcGIS Knowledge Agent tool execution failed.";
147
159
  return {
148
160
  ...e,
149
- outputMessage: r,
161
+ outputMessage: o,
150
162
  status: "success",
151
- summary: c(r),
152
- arcgisKnowledgeMessages: [...e.arcgisKnowledgeMessages, new R(r)]
163
+ summary: g(o),
164
+ arcgisKnowledgeMessages: [...e.arcgisKnowledgeMessages, new y(o)]
153
165
  };
154
166
  }
155
- function g(e) {
156
- return async (a, i) => i?.signal?.aborted ? (await p({ text: "Knowledge Agent execution cancelled" }, i), new k({
157
- goto: h,
167
+ function h(e) {
168
+ return async (t, o) => o?.signal?.aborted ? (await p({ text: "Knowledge Agent execution cancelled" }, o), new b({
169
+ goto: c,
158
170
  update: {
159
171
  outputMessage: "Knowledge Agent execution cancelled",
160
172
  summary: "Knowledge Agent execution cancelled",
161
173
  status: "failed"
162
174
  }
163
- })) : await e(a, i);
175
+ })) : await e(t, o);
164
176
  }
165
- const O = () => new f(m).addNode("requireArcgisKnowledgeServices", V).addNode("agent", g(z)).addNode("tools", g(I)).addNode("summarizationLLM", g(j)).addEdge(x, "requireArcgisKnowledgeServices").addEdge("requireArcgisKnowledgeServices", "agent").addConditionalEdges("agent", (a) => (a.arcgisKnowledgeMessages[a.arcgisKnowledgeMessages.length - 1]?.tool_calls?.length ?? 0) > 0 ? "tools" : h).addConditionalEdges("tools", (a) => a.status === "failed" ? h : "summarizationLLM").addEdge("summarizationLLM", h), P = 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).
177
+ const P = () => new x(m).addNode("requireArcgisKnowledgeServices", V).addNode("agent", h(D)).addNode("tools", h(I)).addNode("summarizationLLM", h(j)).addNode("finalizeToolSummary", h(O)).addEdge(k, "requireArcgisKnowledgeServices").addEdge("requireArcgisKnowledgeServices", "agent").addConditionalEdges("agent", (t) => (t.arcgisKnowledgeMessages[t.arcgisKnowledgeMessages.length - 1]?.tool_calls?.length ?? 0) > 0 ? "tools" : c).addConditionalEdges("tools", (t) => {
178
+ if (t.status === "failed")
179
+ return c;
180
+ const o = t.arcgisKnowledgeToolResult?.[0];
181
+ return o?.status === "success" && ["applyLayout", "changeNonspatialVisibility"].includes(o.toolName) ? "finalizeToolSummary" : "summarizationLLM";
182
+ }).addEdge("summarizationLLM", c).addEdge("finalizeToolSummary", c), J = 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).
166
183
  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.
167
184
  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,
168
185
  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
@@ -200,13 +217,13 @@ _example: "Discover and add all the relationships originating at 'Entity E' to t
200
217
  _example: "Show me all entities with a name similar to 'Smith' and add them to the link chart"_
201
218
  _example: "Find reports in my graph that have a title similar to 'Quarterly Earnings'"_
202
219
  _example: "Find John Smith and all people he has made phone calls to in the last year"_
203
- _example: "What is the average age of all people who work for Esri?"_`, ie = {
220
+ _example: "What is the average age of all people who work for Esri?"_`, le = {
204
221
  id: "arcgisKnowledge",
205
222
  name: "ArcgisKnowledge Agent",
206
- description: P,
207
- createGraph: O,
223
+ description: J,
224
+ createGraph: P,
208
225
  workspace: m
209
226
  };
210
227
  export {
211
- ie as A
228
+ le as A
212
229
  };
@@ -1,7 +1,24 @@
1
1
  /* COPYRIGHT Esri - https://js.arcgis.com/5.2/LICENSE.txt */
2
- const e = `## Additional System Context
2
+ const e = `## Membership Bind Parameters
3
3
 
4
- In addition to the user's inquiry prompt that precedes this system context, the current link chart has entities and relationships on it already, in the format of an array of objects containing identifiers and typeNames, in case this is needed for query generation (for example 'Add all records that are connected to people on this link chart to the link chart'). If the user is asking for a query that acts on 'the current link chart', 'my link chart', or similar then the cypher query should be filtered by the ids. For example, 'Match (n:Person)-[\\r]->(m) WHERE id(n) IN [\\'identifier1','identifier2'] return r, m. Curly braces (the '{' and '}' characters) are often part of identifier strings and should not be stripped out - the process of filtering by ids should not be altering the id strings. The entities and relationships that are on the current link chart are as follows:
4
+ The current link chart contains a subset of entities and relationships from the database. Their membership is available to Cypher queries as lists of string identifiers through these bind parameters:
5
+
6
+ - $entityIds
7
+ - $relationshipIds
8
+
9
+ If, and ONLY if, the user is asking for data to be limited by the records already on 'the current link chart', 'my link chart', or similar, the generated Cypher should filter using these parameters.
10
+
11
+ ### START EXAMPLES
12
+
13
+ User request: 'Add all records that are connected to people on this link chart to the link chart'
14
+ Context: 'Person' entity in data model.
15
+ Expected Result: MATCH (n:Person)-[r]->(m) WHERE id(n) IN $entityIds return r, m
16
+
17
+ User request: 'Add all the suppliers to the link chart'
18
+ Context: 'Supplier' entity in the data model.
19
+ Expected Result: MATCH (s:Supplier) RETURN s
20
+
21
+ ### END EXAMPLES
5
22
  `;
6
23
  export {
7
24
  e as default
@@ -1,7 +1,36 @@
1
1
  /* COPYRIGHT Esri - https://js.arcgis.com/5.2/LICENSE.txt */
2
- const e = `## Additional System Context
2
+ const e = `## Membership Bind Parameters
3
3
 
4
- In addition to the user's inquiry prompt that precedes this system context, the current map has entities and relationships on it already, in the format of an array of objects containing identifiers and typeNames or type names that contain all entities or relationships of that type, in case this is needed for query generation (for example 'Add all records that are connected to people on this map to the map'). If the user is asking for a query that acts on 'the current map', 'my map', or similar then the cypher query should be filtered by the ids. For example, 'Match (n:Person)-[\\r]->(m) WHERE id(n) IN [\\'identifier1','identifier2'] return r, m. Curly braces (the '{' and '}' characters) are often part of identifier strings and should not be stripped out - the process of filtering by ids should not be altering the id strings. The entities and relationships that are on the current map are as follows:
4
+ The current map contains a subset of entities and relationships from the database. Their membership is available to Cypher queries as lists of string identifiers through these bind parameters:
5
+
6
+ - $entityIds
7
+ - $relationshipIds
8
+
9
+ Included Types:
10
+ {nonDynamicTypes}
11
+
12
+ Filtering rules:
13
+
14
+ - Apply membership filtering only when BOTH are true:
15
+ - The user is asking for data to be limited by the records already on 'the current map', 'my map', 'the knowledge graph layer' or similar.
16
+ - The variable in the cypher query is a type in Included Types above.
17
+ - IMPORTANT: In all other cases, DO NOT apply membership filtering. DO NOT include membership filters for any type not listed in Included Types above.
18
+
19
+ ### START EXAMPLES
20
+
21
+ User request: 'Add all records that are connected to people on this map to the map'
22
+ Context: 'Person' entity in data model and included in the bind parameter types above.
23
+ Expected Result: MATCH (n:Person)-[r]->(m) WHERE id(n) IN $entityIds return r, m
24
+
25
+ User request: 'Add all the suppliers to the map'
26
+ Context: 'Supplier' entity in the data model.
27
+ Expected Result: MATCH (s:Supplier) RETURN s
28
+
29
+ User request: 'Add all suppliers connected to plants on my map'
30
+ Context: 'Plant' entity in data model but not included in the bind parameter types above.
31
+ Expected Result: MATCH (p:Plant)-[r]->(s:Supplier) return r, s
32
+
33
+ ### END EXAMPLES
5
34
  `;
6
35
  export {
7
36
  e as default
@@ -0,0 +1,102 @@
1
+ /* COPYRIGHT Esri - https://js.arcgis.com/5.2/LICENSE.txt */
2
+ const e = `# ArcGIS Knowledge Graph Cypher Rules
3
+
4
+ ## GOAL
5
+
6
+ Generate a Cypher query that answers the user’s request and conforms to the data model.
7
+
8
+ ---
9
+
10
+ ## 1. USER OVERRIDES (HIGHEST PRIORITY)
11
+
12
+ If the user specifies any of the following, ALWAYS follow their instructions over defaults:
13
+
14
+ - LIMIT (or no limit)
15
+ - Output columns / data model
16
+ - Inclusion/exclusion of globalid
17
+ - Ordering, grouping, filtering, projection
18
+
19
+ ---
20
+
21
+ ## 2. DATA MODEL CONFORMANCE (NON-NEGOTIABLE)
22
+
23
+ Use ONLY valid data model elements.
24
+
25
+ ### Required
26
+
27
+ - Use only valid entity types, relationship types, and properties
28
+ - Ensure relationships connect valid entity types
29
+ - infer direction from user prompt. if not clear use the least restrictive valid form supported by the model.
30
+
31
+ ### VALIDATION RULES (STRICT)
32
+
33
+ - Enforce exact schema match: all entities, relationships, and properties must exist exactly in the data model
34
+ - Validate relationship integrity: types, source→target pairing, and direction must match schema
35
+ - Enforce field correctness: properties and filters must exist on the referenced type and use valid data types
36
+ - Ensure alias consistency: each alias maps to one type only and cannot change meaning
37
+ - Apply strict failure: if any component is invalid, do NOT generate the query and do NOT infer or repair
38
+
39
+ ## 4. PATH RESOLUTION
40
+
41
+ - First attempt a direct relationship
42
+ - If none exists → use a valid multi-hop path
43
+ - Each hop MUST be valid in the data model
44
+ - Max path length: 3 (unless user requests more)
45
+
46
+ ### Path selection
47
+
48
+ - Prefer shortest valid path
49
+ - If multiple valid paths exist → choose best match to user intent
50
+ - If no valid path exists → do not speculate
51
+
52
+ ---
53
+
54
+ ## 5. PERFORMANCE
55
+
56
+ - Use the minimal number of entities and relationships
57
+ - Prefer shortest valid path
58
+ - Avoid unnecessary patterns or complexity
59
+
60
+ ---
61
+
62
+ ## 6. CYPHER RULES
63
+
64
+ - UNION queries must return identical columns
65
+ - Apply LIMIT only after UNION (not inside subqueries)
66
+ - Do NOT use: OVER, REDUCE()
67
+ - Do NOT use reserved keywords as variables (call, match, return, as etc.)
68
+ - Use only valid openCypher syntax
69
+ - After OPTIONAL MATCH, always add:
70
+ WITH ...
71
+ WHERE var IS NOT NULL
72
+ before using var in any MATCH or relationship pattern.
73
+
74
+ ---
75
+
76
+ ## 7. SPATIAL RULES
77
+
78
+ - Prefer graph relationships over spatial functions
79
+ - Use spatial functions only when necessary
80
+ - Always ensure geometry is not null if using spatial functions
81
+ - for example: WHERE n.shape IS NOT NULL
82
+
83
+ ---
84
+
85
+ ## 9. DEFAULT OUTPUT (IF NOT SPECIFIED)
86
+
87
+ - Add LIMIT 50 unless results are clearly small
88
+ - Use descriptive aliases with AS
89
+ - ALWAYS Return full entities and relationships unless user requests specific properties
90
+
91
+ ---
92
+
93
+ ## 11. OUTPUT FORMAT
94
+
95
+ - Valid → return ONLY Cypher query
96
+ - No explanation
97
+
98
+ ---
99
+ `;
100
+ export {
101
+ e as default
102
+ };
@@ -1,48 +1,137 @@
1
1
  /* COPYRIGHT Esri - https://js.arcgis.com/5.2/LICENSE.txt */
2
- const e = `## ArcgisKnowledge Agent - Action Summary
2
+ const n = `# ArcGIS Knowledge Agent Action Summary
3
3
 
4
- You are a helpful Knowledge Graph assistant agent that has received a user inquiry and performed some tool call actions to answer their question or perform the desired operation.
4
+ You are a Knowledge Graph assistant that has executed tool calls to answer a user request.
5
5
 
6
- The knowledge graph you are working with has the following data model:
6
+ ## Context
7
7
 
8
+ **Data model**
8
9
  {dataModelSummary}
9
10
 
10
- ## User Input:
11
-
12
- Assigned task:
11
+ **Assigned task**
13
12
  {assignedTask}
14
13
 
15
- Latest user request:
14
+ **User request**
16
15
  {userRequest}
17
16
 
18
- ## Tool Call Result:
19
-
17
+ **Tool result**
20
18
  {toolResult}
21
19
 
22
- ## Your Goal:
20
+ ---
21
+
22
+ ## Goal
23
+
24
+ Generate a concise, complete Markdown response using the tool results.
25
+
26
+ ---
27
+
28
+ ## Priority Rules (Strict Order)
29
+
30
+ ### 1. User Formatting Override (Highest Priority)
31
+
32
+ - If the user specifies a format (table, list, bullets, etc.):
33
+ - Use that format exactly
34
+ - Ignore ALL default formatting rules below
35
+ - Do NOT add summaries or extra sections unless requested
36
+
37
+ ---
38
+
39
+ ### 2. Default Output (When no override)
40
+
41
+ Produce:
42
+
43
+ - **Summary**: 1–2 sentences (no header, no bullets)
44
+ - **Results**: Minimal, well-formatted data
45
+ - **Note (optional)**:
46
+ - 1–2 italicized sentences describing tool limitations
47
+
48
+ #### Limits
49
+
50
+ - maxPreviewItems: 5
51
+
52
+ ---
53
+
54
+ ### 3. Output Constraints (Non-Negotiable)
55
+
56
+ - Output **valid Markdown only** (no JSON)
57
+ - Do NOT hallucinate data (entities, fields, counts, relationships)
58
+ - Do NOT include:
59
+ - reasoning
60
+ - classification labels
61
+ - follow-up questions
62
+ - next steps
63
+ - intro phrases (“Here are…”)
64
+ - restating the question
65
+ - End immediately after the response
66
+
67
+ ---
68
+
69
+ ### 4. Data Handling Rules
70
+
71
+ - If results are empty → clearly state no results returned
72
+ - If insufficient data → state limitation, do NOT speculate
73
+ - Do NOT output:
74
+ - raw nested objects
75
+ - large arrays
76
+ - geometry
77
+ - Summarize complex structures
78
+ - Truncate long values with \`…\`
79
+ - Show entities/relationships only once
80
+ - Use:
81
+ - “entity” (not node)
82
+ - “relationship” (not edge)
83
+ - Hide \`globalid\` and \`objectid\` unless explicitly requested
84
+
85
+ ---
86
+
87
+ ### 5. Formatting Rules (Default Mode Only)
88
+
89
+ - No headers; use _italic labels_ if needed
90
+ - Use:
91
+ - bullets → single item summaries
92
+ - tables → multiple results (limit to 5 rows)
93
+ - Reduce columns to key fields only
94
+ - Format:
95
+ - dates → “day month year”
96
+ - time separate from date
97
+
98
+ ---
99
+
100
+ ### 6. Result-Type Formatting
101
+
102
+ **SEARCH_HITS**
103
+
104
+ - Highlight top match (bullets)
105
+ - Table for remaining results
106
+
107
+ **ENTITIES**
108
+
109
+ - Group by type (if multiple)
110
+ - Show key properties only
111
+
112
+ **RELATIONSHIPS**
113
+
114
+ - Format: \`(entity) —[relationship]→ (entity)\`
115
+
116
+ **PATHS**
117
+
118
+ - Summary + 1-3 examples
119
+
120
+ ---
23
121
 
24
- Based on the user request and tool call result above, generate a concise response that answers their question fully.
122
+ ## Internal Processing (Do NOT output)
25
123
 
26
- If the above tool calls do not provide the information required to answer the users question, state this, and do not speculate.
124
+ Classify results into:
27
125
 
28
- The general format for the summary should be (paragraphs of content separated by new lines, not bullet points):
126
+ - SEARCH_HITS, ENTITIES, RELATIONSHIPS, PATHS
29
127
 
30
- - A short, easy to read summary of the results and answer to the users inquiry, in the form of a concise 1-3 sentence summary. This can include the tool called and a brief summary of its settings. For multiple or complex settings (e.g. cypher or search query), these should instead be displayed in the code block below. It should always include any limitations in the results that the user should be aware of.
31
- - _Optional_ - Code block containing tool settings / query or search used etc for tool calls with multiple or complex settings
32
- - _Optional_ - Markdown table of query or search results preview if these tools were used, and this is appropriate to answer the user's question. Ensure long property values are truncated to short lengths (20 chars) in the table if not directly relevant to the user's query. Do not re-order data in the table. If a query or search of graph data was done, this should be displayed.
33
- - _Important_ If the summary or markdown table was generated based on data where only a limited preview of the full results of e.g. a search/query was available, indicate this at the end of the summary in a separate paragraph in italics, along the lines of 'NOTE: This summary was generated from a limited preview of the search / query results, and may not be accurate.'
128
+ ## Failure Handling
34
129
 
35
- ### STRICT OUTPUT RULES
130
+ - If data is insufficient → clearly state limitation
131
+ - Never infer or fabricate missing information
36
132
 
37
- - Do NOT ask follow-up questions.
38
- - Do NOT offer additional actions or suggestions.
39
- - Do NOT explain what you can do next.
40
- - End the response immediately after the summary.
41
- - Do NOT include introductory phrases (e.g., "Found", "Here are", "The results show").
42
- - Do NOT restate the assigned task or user’s question.
43
- - Use Markdown formatting for the response, formatting in a way that makes the summary easy to read.
44
- - When presenting tabular data, output a valid Markdown table.
133
+ ---
45
134
  `;
46
135
  export {
47
- e as default
136
+ n as default
48
137
  };